On Mon, 22 Nov 2010, elaine kuo wrote:

Dear List,



I am comparing the squared R values of linear models and its spatial
autoregressive counterparts. (SARerror)

(1. lm (Y~X1)

2. lm (Y~ X1+X2)

3. lm(Y~X1+X2+X3))



The squared R values of linear models are generated by command summary (lm).


Similarly, I tried to produce those of spatial autoregressive models based on the squared Pearson?s correlation of explanatory and response variables. It failed

Don't. There is no direct equivalent to the OLS R-squared, these models are fitted by maximum likelihood. You may choose to compare likelihood-based measures, so a likelihood ratio test (as reported in the output of the summary method for the fitted model) between the fitted model and an OLS model with the spatial coefficient fixed at zero is OK. If you want something like an R-squared, try the Nagelkerke R-bar-squared, based on the likelihood, reported optionally in the summary object - see ?summary.sarlm. You should then compare this with a Nagelkerke value for your OLS model if you feel that this would be helpful.

Roger




The code is as followed.

Please kindly modify the code and thank you.



1. single predictor

sar.x1 <-errorsarlm(Y~X1,data=datam.std,listw=nb8.w, na.action=na.omit,
method="Matrix", zero.policy=TRUE)

summary(sar.x1)

cor(sar.x1$X1, sar.x1$Y, method = "pearson")



error message

error in cor(sar.x1$ X1, sar.x1$Y, method = "pearson") :

 supply both 'x' and 'y' or a matrix-like 'x'



2. multiple predictors

sar.all <-errorsarlm(Y~X1+X2+X3,data=datam.std,listw=nb8.w,
na.action=na.omit, method="Matrix", zero.policy=TRUE)

summary(sar.all)

cor(sar.all$X1+ sar.all$X2+ sar.all$X3, sar.x1$Y, method = "pearson")



error message

error in cor(sar.all$X1+ sar.all$X2+ sar.all$X3, sar.x1$Y, method =
"pearson") :

 supply both 'x' and 'y' or a matrix-like 'x'



Elaine

        [[alternative HTML version deleted]]



--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to