我已经在下面编写了代码
ERV1 = read.delim("wm1_ex_vol_SDM2_NEW.txt", row.names = 1) #spatial weight 1
ERV1 = as.matrix(ERV1, zero.policy=TRUE); ERV1 <- mat2listw(ERV1)
ERV2 = read.delim("wm2_ex_vol_SDM2_NEW.txt", row.names = 1) #spatial weight 2
ERV2 = as.matrix(ERV2, zero.policy=TRUE); ERV2 <- mat2listw(ERV2)
spa.sak = read.csv("SPATIAL_xyz.csv",header=TRUE,sep=",");spa.sakp= spa.sak[,-c(1)]
is.pbalanced(spa.sakp)
#spatial lags are derived below: ERV1 and ERV2 are spatial weights, and slag computes the spatial lags for each weights.
slervcredTx1 <- slag(spa.sakp$credT, listw=ERV1)
slervchecxTx1 <- slag(spa.sakp$chexT, listw=ERV1);
slervuninfTx1 <- slag(spa.sakp$uninfT, listw=ERV1)
slervgdpTx1 <- slag(spa.sakp$gdpT, listw=ERV1);
slervchintTx1 <- slag(spa.sakp$chintT, listw=ERV1)
sllagervx2 = slag(lagret, listw=ERV2)
slervcredTx2 <- slag(spa.sakp$credT, listw=ERV2)
slervchecxTx2 <- slag(spa.sakp$chexT, listw=ERV2);
slervuninfTx2 <- slag(spa.sakp$uninfT, listw=ERV2)
slervgdpTx2 <- slag(spa.sakp$gdpT, listw=ERV2);
slervchintTx2 <- slag(spa.sakp$chintT, listw=ERV2)
#formula: Those with spa.sakp are the indepedent variables and with (sl..) are spatia lags
fmerv2s = (spa.sakp$indexT ~
spa.sakp$credT+ spa.sakp$chexT +spa.sakp$uninfT +spa.sakp$gdpT + spa.sakp$chintT
+slervcredTx1 +slervchecxTx1 +slervuninfTx1 +slervgdpTx1 +slervchintTx1
+slervcredTx2+slervchecxTx2 +slervuninfTx2 +slervgdpTx2 +slervchintTx2)
#Computation
ERVM2s<- spml(formula = fmerv2s, data = spa.sakp, index = c('id','months'),listw = ERV1, listw2=ERV2 , model = "within", lag = TRUE, effect = "time", spatial.error = "none")
我期望像
Spatial autoregressive coefficient:
Estimate Std. Error t-value Pr(>|t|)
rho1 -0.137605 0.033528 -4.1042 4.057e-05 ***
rho2 -0.129102 0.039558 -4.1142 4.057e-05 ***
......
但是我得到的是
Spatial autoregressive coefficient:
Estimate Std. Error t-value Pr(>|t|)
rho1 -0.137605 0.033528 -4.1042 4.057e-05 ***
...
问题可能出在公式ERV1
内寻址ERV2
和ERVM2 <- spml(.....)
有什么帮助吗?