

%This example program uses the data from:
%Pace, R. Kelley, and Ronald Barry, "Quick Computation of Regressions with a Spatially Autoregressive Dependent Variable,"
%Geographical Analysis, Volume 29, Number 3, July 1997, p. 232-247. 

%The functions used here are described in
%"Closed-Form Maximum Likelihood Estimates of Nearest Neighbor Spatial Dependence", 
%Pace and Zou(forthcoming), Geographical Analysis

%The function fclosestnn1 finds the very nearest (closest) neighbor to each observation
%The function fclosestmix1 computes the maximum liklelihood estimates given spatial dependence on the very nearest neighbor.



%Written by Kelley Pace, 8/98

load latlon;
xcoord=latlon(:,2);
ycoord=latlon(:,1);
%locations on a plane

load xsub;
load y;

%finds the very closest neighbor - supplied as a list
tic;
[nnlist]=fclosestnn1(xcoord,ycoord);
toc

elapsed_time =

    0.7650


%computes mixed estimates
tic;
[alphamax,loglik,emax,bmax,likratios,prhigher]=fclosestmix1(xsub,y,nnlist);
toc

elapsed_time =

    0.1250


%autoregressive parameter
alphamax

alphamax =

    0.3352


%other parameters
bmax

bmax =

   -0.7489
    0.2899
    0.4457
   -0.0332
    0.1878
    0.0975
   -0.1569
   -0.1079
    0.7495



diary off;
