Weighted Matrix computed with inverse Distances

## Loading required package: Matrix
## 
## Call:lagsarlm(formula = CRIME ~ INC + HOVAL, data = mydata, listw = listw)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -26.9544  -4.1300  -0.2163   5.0070  22.1583 
## 
## Type: lag 
## Coefficients: (asymptotic standard errors) 
##             Estimate Std. Error z value  Pr(>|z|)
## (Intercept) 25.66912    6.49873  3.9499 7.819e-05
## INC         -0.68652    0.26260 -2.6143  0.008940
## HOVAL       -0.20245    0.07307 -2.7706  0.005595
## 
## Rho: 0.09928, LR test value: 29.89, p-value: 4.5754e-08
## Asymptotic standard error: 0.0131
##     z-value: 7.58, p-value: 3.4417e-14
## Wald statistic: 57.46, p-value: 3.4528e-14
## 
## Log likelihood: -172.4 for lag model
## ML residual variance (sigma squared): 64.47, (sigma: 8.029)
## Number of observations: 49 
## Number of parameters estimated: 5 
## AIC: 354.9, (AIC for lm: 382.8)
## LM test for residual autocorrelation
## test value: 0.01792, p-value: 0.89353
## 
## Call:
## errorsarlm(formula = CRIME ~ INC + HOVAL, data = mydata, listw = listw)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -25.55680  -3.24142   0.12039   6.33597  23.13540 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##              Estimate Std. Error z value Pr(>|z|)
## (Intercept) 22.856475   8.219319  2.7808 0.005422
## INC         -0.642584   0.277641 -2.3144 0.020644
## HOVAL       -0.198204   0.074467 -2.6616 0.007776
## 
## Lambda: 0.1256, LR test value: 25.77, p-value: 3.8361e-07
## Asymptotic standard error: 0.003476
##     z-value: 36.13, p-value: < 2.22e-16
## Wald statistic: 1306, p-value: < 2.22e-16
## 
## Log likelihood: -174.5 for error model
## ML residual variance (sigma squared): 65.25, (sigma: 8.078)
## Number of observations: 49 
## Number of parameters estimated: 5 
## AIC: 359, (AIC for lm: 382.8)

You can also embed plots, for example:

moran.test(CRIME, listw)
## 
##  Moran's I test under randomisation
## 
## data:  CRIME  
## weights: listw  
##  
## Moran I statistic standard deviate = 9.68, p-value < 2.2e-16
## alternative hypothesis: greater 
## sample estimates:
## Moran I statistic       Expectation          Variance 
##         0.2044123        -0.0208333         0.0005414
moran.plot(CRIME, listw)

plot of chunk unnamed-chunk-2

## 
## Call:lagsarlm(formula = CRIME ~ INC + HOVAL, data = mydata, listw = listw)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -35.68762  -7.01341  -0.83503   8.40003  27.44614 
## 
## Type: lag 
## Coefficients: (asymptotic standard errors) 
##              Estimate Std. Error z value  Pr(>|z|)
## (Intercept) 51.627459  11.817848  4.3686 1.250e-05
## INC         -1.384654   0.334827 -4.1354 3.543e-05
## HOVAL       -0.281171   0.098167 -2.8642  0.004181
## 
## Rho: 0.3754, LR test value: 1.942, p-value: 0.16342
## Asymptotic standard error: 0.2688
##     z-value: 1.397, p-value: 0.16254
## Wald statistic: 1.95, p-value: 0.16254
## 
## Log likelihood: -186.4 for lag model
## ML residual variance (sigma squared): 117.1, (sigma: 10.82)
## Number of observations: 49 
## Number of parameters estimated: 5 
## AIC: 382.8, (AIC for lm: 382.8)
## LM test for residual autocorrelation
## test value: 1.492, p-value: 0.22187
## 
## Call:
## errorsarlm(formula = CRIME ~ INC + HOVAL, data = mydata, listw = listw)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -34.85406  -6.71581  -0.46122   8.91963  28.71276 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##              Estimate Std. Error z value  Pr(>|z|)
## (Intercept) 67.311097   4.836926 13.9161 < 2.2e-16
## INC         -1.538356   0.330112 -4.6601 3.161e-06
## HOVAL       -0.268478   0.098726 -2.7194  0.006539
## 
## Lambda: 0.1823, LR test value: 0.1482, p-value: 0.70022
## Asymptotic standard error: 0.4012
##     z-value: 0.4544, p-value: 0.64953
## Wald statistic: 0.2065, p-value: 0.64953
## 
## Log likelihood: -187.3 for error model
## ML residual variance (sigma squared): 122.2, (sigma: 11.05)
## Number of observations: 49 
## Number of parameters estimated: 5 
## AIC: 384.6, (AIC for lm: 382.8)
moran.test(CRIME, listw)
## 
##  Moran's I test under randomisation
## 
## data:  CRIME  
## weights: listw  
##  
## Moran I statistic standard deviate = 5.619, p-value = 9.629e-09
## alternative hypothesis: greater 
## sample estimates:
## Moran I statistic       Expectation          Variance 
##          0.167362         -0.020833          0.001122
moran.plot(CRIME, listw)

plot of chunk unnamed-chunk-4