1

我正在尝试在不对矩阵进行行归一化的情况下估计 SAR 空间模型。出于某种原因,当我不进行行标准化时,该命令不会返回正确的估计值。我在命令选项上遗漏了什么吗?

这是我的意思的一个例子。

如果我运行以下代码,使用行归一化矩阵模拟数据,lagsarlm 会返回正确的估计值:

set.seed(20100817)

rho <- .5
B <- c(2, 5)
e <- as.matrix(rnorm(100, sd=2))
X0 <- matrix(1, ncol=1, nrow=100) # create Intercept
X1 <- matrix(runif(100, min = -10, max = 10), nrow=100) # generate covariate
Xbe <- X0*B[1]+X1*B[2]+e
I <- diag(100)

W <- rgraph(100, m=1, tprob=0.1, mode="graph", diag=FALSE) #assume I need to start with a matrix of relationships
spatialList <- mat2listw(W)
nb7rt <- spatialList$neighbours
listw <- nb2listw(nb7rt)
W <- nb2mat(nb7rt)

y <- solve(I - rho*W) %*% Xbe

model <- lagsarlm(y ~ X1, listw=listw) 
summary(model) 

但是,如果我尝试完全相同但没有行规范化,则结果不正确:

set.seed(20100817)

rho <- .5
B <- c(2, 5)
e <- as.matrix(rnorm(100, sd=2))
X0 <- matrix(1, ncol=1, nrow=100) # create Intercept
X1 <- matrix(runif(100, min = -10, max = 10), nrow=100) # generate covariate
Xbe <- X0*B[1]+X1*B[2]+e
I <- diag(100)

W <- rgraph(100, m=1, tprob=0.1, mode="graph", diag=FALSE) #assume I need to start with a matrix of relationships
spatialList <- mat2listw(W, style ="B")
nb7rt <- spatialList$neighbours
listw <- nb2listw(nb7rt, style="B")
W <- nb2mat(nb7rt, style="B")

y <- solve(I - rho*W) %*% Xbe

model <- lagsarlm(y ~ X1, listw=listw) 
summary(model) 

可以在此处找到此代码的基础https://stat.ethz.ch/pipermail/r-sig-geo/2010-August/009023.html

4

0 回答 0