我有一个问题spdep()
。从函数产生的非缺失距离矩阵开始
dist_m <- geoDistMatrix(data1, group = 'fips_dist')
dist_m[upper.tri(dist_m)] <- t(dist_m)[upper.tri(dist_m)]
然后我们变成具有线性逆的权重
max_dist <- max(dist_m)
w1 <- (max_dist + 1 - dist_m)/(max_dist + 1)
现在
lw <- mat2listw(w1, row.names = rownames(w1), style = 'M')
我检查以确保没有丢失重量:
any(is.na(lw$weights))
既然没有,请继续:
errorsarlm(cvote ~ inc, data = data1, lw, method = 'eigen', quiet = F, zero.policy = TRUE)
导致以下错误:
Error in subset.listw(listw, subset, zero.policy = zero.policy) :
Not yet able to subset general weights lists