I have a problem regarding to the execution time of a SAR model with the 'spdep' package.
I pass two different dataset of the same dimension to the same function, it takes very different times (a few seconds vs hours).
I write to you my code, if you have any idea please let me know.
Thanks Chiara
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"))
I got:
It seems that time of
lagsarlm
is dependent of t`s Number of nonzero links..