我对使用“spdep”包的 SAR 模型的执行时间有疑问。
我将两个相同维度的不同数据集传递给同一个函数,它需要非常不同的时间(几秒与几小时)。
我把我的代码写给你,如果你有任何想法,请告诉我。
谢谢基亚拉
library(spdep)
data(house, package="spData")
hlw<-nb2listw(LO_nb)
system.time( lagsarlm(log(price) ~ age, data=house, listw=hlw, type="lag", method="Matrix", trs=trMat))
#----------------------------------------------
library(spatstat)
d1<-100
d2<-100
n<-25357
coord<- runifpoint(n,win=owin(c(0,d1),c(0,d2)))
mat<-cbind(coord$x,coord$y)
X<-rnorm(n,5,2)
Y<-rnorm(n,5,3)
d<-as.data.frame(cbind(X,Y))
cutoff<- dnearneigh(mat,0,4)
t<-nb2listw(cutoff)
system.time( lagsarlm(Y ~ X, data=d, listw=t, type="lag", method="Matrix"))