
load xsub;
load y;
load ycoord;
load xcoord;

[n,p]=size(xsub);

%Performing OLS
tic;
[alphamax,loglik,emax,bmax,likratios,prhigher]=fols1(xsub,y);
toc;

elapsed_time =

          0.13


sse=emax'*emax;
ydif=y-mean(y);
ssq=ydif'*ydif;
r2=1-sse/ssq

r2 =

          0.52


[bmax likratios prhigher]

ans =

         -0.85       1205.56             0
          0.52        954.36             0
          0.43        529.31             0
         -0.14         52.38          0.00
          0.98        411.20             0


%Plotting observations over space
plot(xcoord,ycoord,'.');

%Computing Delaunay weights
tic;
[wswdel,wwsdel,wmatdel]=fdelw1(xcoord,ycoord);
toc;

elapsed_time =

          0.63


%Computing log-determinants
tic;
detvalz=fdetinterp1(wswdel);
toc;

elapsed_time =

          6.51


wws=wwsdel;
wsw=wswdel;


%Computing mixed model
tic;
[alphamaxmix,loglikmix,emaxmix,bmaxmix,likratiosmix,prhighermix]=fmix1(xsub,y,detvalz,wws);
toc;

elapsed_time =

          0.17

[alphamaxmix max(max(loglikmix))]

ans =

          0.67      -5641.91

[bmaxmix ]

ans =

         -0.73
          0.18
          0.46
          0.04
          0.47
          0.04
         -0.33
         -0.14
          0.41

[likratiosmix prhighermix]

ans =

        904.75             0
        209.85             0
        753.56             0
         24.99          0.00
         66.97          0.00


%Computing SAR
tic;
[alphamaxsar,logliksar,emaxsar,bmaxsar,likratiossar,prhighersar]=fsar1(xsub,y,detvalz,wws);
toc

elapsed_time =

          1.98

[alphamaxsar max(max(logliksar))]

ans =

          0.72      -5688.52

[bmaxsar likratiossar prhighersar]

ans =

         -0.77       1017.99             0
          0.27        132.19             0
          0.45        725.38             0
          0.01          0.22          0.64
          0.53         82.86             0


%Computing CAR
tic;
[alphamaxcar,loglikcar,emaxcar,bmaxcar,likratioscar,prhighercar]=fcar1(xsub,y,detvalz,wsw);
toc;

elapsed_time =

          1.62

[alphamaxcar max(max(loglikcar))]

ans =

          0.99      -5600.11

[bmaxcar likratioscar prhighercar]

ans =

         -0.75        973.32             0
          0.21         92.82             0
          0.46        769.90             0
          0.03          2.14          0.14
          0.44         59.08          0.00





diary off;
