【发布时间】:2018-03-13 12:26:03
【问题描述】:
我正在尝试使用 splm 包在 R 中运行空间面板回归。所以我有多边形随着时间的推移汇总数据,我想看看因变量如何受到其他变量的影响,这些变量也随着时间而变化。
我有 546 个区域,其中包含许多变量,但为了测试它的工作原理,我使用了 3 个多边形的数据子集,包括用于计算权重的 shapefile 和数据。
https://drive.google.com/file/d/0B4SK0f2zZUKxZ0dDU2lnclB2M3c/view?usp=sharing
#load data
file="sector_panel_data_test.csv"
sector_data=read.table(file,sep=",", header=T, quote="")
sector_data[is.na(sector_data)] <- 0
names(sector_data)
attach(sector_data)
#load shape
require (rgdal)
sectors <-readOGR(dsn=".",layer="sectors_test_sample_year1")
nb <- poly2nb(sectors)
#distance based neighbors
coords <- coordinates(sectors)
nb.d125<- dnearneigh(coords,0,125000,row.names=sectors$Code)
#create weights matrix
mat.d125 <-nb2mat(nb.d125,glist=NULL,style="W",zero.policy=TRUE)
#and then a weights list object
listd125 = mat2listw(mat.d125, style="W")
#design model and run, just picked one variable here
fm <- prop_fdeg ~ mean_pop
randommodel <-spml(fm,
data=sector_data,index=NULL,listw=listFQQ,model="random", lag=FALSE)
我收到以下错误:
spreml 中的错误(公式 = 公式,数据 = 数据,索引 = 索引,w = listw2mat(listw),:不符合的空间权重
有人知道这是什么意思吗?我到处搜索,只发现有同样问题的人在寻找解决方案。
【问题讨论】:
标签: r regression panel spatial