空间面板数据Spatial Durbin Model运行报错求助
空间面板数据SDM模型回归报错求助
我正尝试为空间面板数据运行Spatial Durbin Model(SDM),计划将因变量y对自变量x1、x2进行回归,但多次尝试均出现报错。以下是我尝试的前两种方案及操作步骤:
library("sf") library("dplyr") library("spdep") library("spatialreg") library("spmodel") library(plm) library(GWPR.light) library(sp) library(GWmodel) library(spgwr) library(SDPDmod) # 删除回归变量y、x1、x2中含缺失值的观测: test <- DataTest_shp %>% dplyr::filter(across(c(y , x1,x2),~ !is.na(.))) # 构建权重矩阵: shapefile_centroid <- sf::st_centroid(test) coordsW <- test %>% st_centroid()%>% st_geometry() nb.d125<- dnearneigh(coordsW,0,125000,row.names=coordsW$ID) mat.d125 <-nb2mat(nb.d125,glist=NULL,style="W",zero.policy=TRUE) listd125 = mat2listw(mat.d125, style="W") # 设定回归公式: formula.GWPR <- y ~ x1+x2
方案1:调用blmpSDPD函数
res3<-blmpSDPD(formula.GWPR, data = test, W = mat.d125, index = c("ID","year"), model = list("sdm"), effect = "twoways", prior = "beta")
报错信息:
Error in blmpSDPD(formula.GWPR, data = test, W = mat.d125, index = c("ID", : Non conformable spatial weights
方案2:调用SDPDm函数
mod5<-SDPDm(formula.GWPR, data = test, W = mat.d125, index = c("ID","year"), model = "sdm", effect = "twoways", LYtrans = T, dynamic = T, tlaginfo = list(ind = NULL, tl = T, stl = T))
报错信息:
Error in xtfrm.data.frame(x) : cannot xtfrm data frames
内容的提问来源于stack exchange,提问作者Adriana Castillo Castillo
相关产品推荐
相关产品推荐

