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 Pearsons correlation of explanatory and response variables. It failed 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]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.