You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

空间面板数据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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 03:37:56