

%This example program estimates a mixed model with Nearest Neighbor weights using 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 routine fits a model Y=[X (spatially lagged X=DX) intercept]*parameters+alpha*spatially lagged Y+error
%This model has several names in the literature such as mixed regressive spatially autoregressive models

%Written by Kelley Pace, 6/23/97


%This example uses Nearest Neighbor weights


load xsub;
load y;
load wwsnn;
wws=wwsnn;
load detvalznn;
detvalz=detvalznn;


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

elapsed_time =

    0.2110


alphamax

alphamax =

    0.6000


bmax

bmax =

   -0.7162
    0.1926
    0.4494
    0.0262
    0.3794
    0.0577
   -0.2787
   -0.1240
    0.4686


[ likratios prhigher]

ans =

  878.4623         0
  264.1965         0
  726.7064         0
   24.6721    0.0000
   90.6410         0


%This plots the profile log-likelihood curves for the overall model and each delete-1 subset
plot(detvalz(:,1),loglik)
title('Profile Likelihoods by Variable (plus unrestricted)');
xlabel('Alpha');
ylabel('Log-Likelihood');


diary off;
