

%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. 

%This program computes nearest neighbor spatial weight matrices
%Important parameters include the number of neighbors, m, and rho, the decline of the weight of the jth neighbor with j

%Written by Kelley Pace, 6/23/97



m=8;
%number of nearest neighbors

rho=1;
% weight given to the jth neighbor equals a constant time j^(rho)



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

load wswdel;
%loads Delaunay adjacency matrix

fnndel1(wswdel,xcoord,ycoord,m);

tic;
[wwsasymnn,wmatasymnn]=fnnasym1(m,rho);
toc;

elapsed_time =

    0.5010



tic;
[detvalz]=fdetinterpasym1(wwsasymnn);
toc;

elapsed_time =

   36.7630



load xsub;
load y;
wws=wwsasymnn;

tic;
[alphamax,loglik,emax,bmax,likratios,prhigher]=fsar1(xsub,y,detvalz,wws);
toc;

elapsed_time =

    2.0330


alphamax

alphamax =

    0.7600


[bmax likratios prhigher]

ans =

  1.0e+003 *

   -0.0008    1.0251         0
    0.0003    0.1263         0
    0.0005    0.7487         0
    0.0000    0.0004    0.0005
    0.0005    0.0772         0



diary off;
