
%This example program program does the vectorized spatial pure autoregressive estimation for the data used in:
%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. 

%Written by Kelley Pace, 6/23/97

%Only a mean is estimated for each variable (constant independent variable for X [1] for each series)

%This provides a way of quickly testing for spatial autocorrelation for a set of variables

%detvalz contains the spatial differencing parmameter values and associated log-dets
%wws is the row-stochastic spatial weight matrix

%This function accepts a matrix of n by p matrix of y values where p is the number of series
%and n is the number of observations in each of the series. Hence, this function computes
%the optimal autoregressive parameter and likelihood ratio for alpha=0 for each of the series



%loads x,y,delaunay weights, associated log-dets over grid of alpha
load xsub;
load y;
load wwsdel;
wws=wwsdel;
load detvalzdel;
detvalz=detvalzdel;


y=[y xsub];


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

elapsed_time =

    0.1500


alphamax

alphamax =

    0.7500    0.7300    0.7400    0.7300    0.7400


bmax

bmax =

   -0.1437    2.6255    2.3366    2.3503    3.0810


likratios

likratios =

  1.0e+003 *

    1.8016    1.5453    1.5627    1.5672    1.6217

prhigher

prhigher =

     0     0     0     0     0


plot(detvalz(:,1),loglik)
title('Profile Log-likelihoods By Variable')
xlabel('Alpha')
ylabel('Log-likelihood by Variable')

diary off;
