Open MPaw18 opened 7 months ago
The crime rate for these 20 units does show spatial autocorrelation:
> lm.morantest(lm_null, listw=lw, alternative="two.sided")
Global Moran I for regression residuals
data:
model: lm(formula = ratecrimes ~ 1, data = wpom3)
weights: lw
Moran I statistic standard deviate = 2.5909, p-value = 0.009571
alternative hypothesis: two.sided
sample estimates:
Observed Moran I Expectation Variance
0.34570598 -0.05263158 0.02363659
However, when the linear model has explanatory variables, the residual spatial autocorrelation is removed, probably because one or more of the independent variables has a similar map pattern to the crime rate:
> lm.morantest(lm_obj_pre, listw=lw, alternative="two.sided")
Global Moran I for regression residuals
data:
model: lm(formula = form_pre, data = wpom3)
weights: lw
Moran I statistic standard deviate = -0.22291, p-value = 0.8236
alternative hypothesis: two.sided
sample estimates:
Observed Moran I Expectation Variance
-0.14407690 -0.11006321 0.02328247
Look at:
cor(model.matrix(~ -1 + ratecrimes + log(density) + avgsal + unemp + ssusers, wpom3))
The variables are highly correlated; are they all needed?
https://github.com/wikpur/Spacial-Econometrics-Project/blob/f12e530994bb4025f811a1ba6b30d68c48c33c41/Spacial-Econometrics-Project.Rmd#L303
@rsbivand