SPML空间面板模型:lag.listw中的错误|不平衡面板

问题描述

我正在从splm库制作空间面板模型,但由于它是不平衡的面板,所以无法制作固定或随机效果模型。

数据

datashp files

可复制的示例

library(dplyr)
library(Hmisc)
library(sf)
library(plm)
library(splm)
library(spdep)
data = read.csv("data.csv",colClasses=c(id="factor"))
map = st_read("nxparroquias.shp")
colnames(map)[1] = "id"

balanced = data %>% 
  group_by(id) %>%
  #drop_na() %>% 
  filter(all(c(2013:2018) %in% year)) %>% 
  ungroup() %>% 
  filter(id %in% unique(map$id))

map = map %>% 
  filter(id %in% unique(balanced$id))
pt = spdep::poly2nb(map)
ptw = spdep::nb2listw(pt,zero.policy = TRUE)

describe(balanced$id)
#balanced$id 
#n  missing distinct 
#5832        0      972 

describe(map$id)
#map$id 
#n  missing distinct 
#972        0      972 

#checks if the data are balanced
plm::is.pbalanced(balanced$id,balanced$year)
#[1] TRUE

p_balanced = pdata.frame(balanced,index = c("id","year"))  #same issues

池化

md1 = splm::spml(data = balanced,y ~ x1+x2+x3,index =  c("id","year"),zero.policy = TRUE,model = "pooling",listw = ptw)
summary(md1)

#ML panel with,spatial error correlation 
#
#Call:
#  spreml(formula = formula,data = data,index = index,w = listw2mat(listw),#         w2 = listw2mat(listw2),lag = lag,errors = errors,cl = cl,#         zero.policy = TRUE)
#
#Residuals:
#  Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#-14.860  -3.213   0.539   0.003   3.194  13.181 
#
#Error variance parameters:
#  Estimate Std. Error t-value Pr(>|t|)    
#rho 0.087841   0.019622  4.4767 7.58e-06 ***
#  
#  Coefficients:
#  Estimate Std. Error t-value  Pr(>|t|)    
#(Intercept)  5.1373431  0.0972298 52.8371 < 2.2e-16 ***
#  x1           0.0423977  0.0098276  4.3141 1.602e-05 ***
#  x2           0.1109780  0.0083800 13.2432 < 2.2e-16 ***
#  x3          -0.0444174  0.0096522 -4.6018 4.189e-06 ***
#  ---
#  Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

FE

md2 = splm::spml(data = balanced,model = "within",listw = ptw)

具有可重现的示例固定效果

lag.listw(listw,u,zero.policy = zero.policy)中的错误: 对象长度不同

使用我的原始数据

spfeml中的错误(公式=公式,数据=数据,索引=索引,listw = listw ,: 不平衡面板无法使用的估算方法

RE

具有随机效果

.C64(“ aplsb1”,SIGNATURE = c(SS $ signature,SS $ signature,“ double”,: 参数7中的NA和“ NAOK = FALSE”(dotCall64)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...