[R-sig-Geo] spatial durbin model with large dataset
Roger Bivand
Roger.Bivand at nhh.no
Mon Jun 21 11:13:49 CEST 2010
On Sun, 20 Jun 2010, Mi Diao wrote:
> Dear all,
>
> I am trying to calibrate a Spatial Durbin Model for a dataset with
> 52000 observations. Geoda can handle a dataset of this size, but it
> can only estimate spatial lag and spatial error model. Can the spdep
> package of R handle my dataset?
Yes. At a recent demo, I ran the 25k ?house example on a small memory
older laptop without trouble (http://spatial.nhh.no/R/sea10.zip). With 50k
and many RHS variables, you may find a busy Windows 1Gb machine gasps a
bit - if so, shut down other programs (IE etc.) before starting R. Look at
?lagsarlm, then ?impacts. Typically, you'll need something like:
# lw is your weights object, probably from nb2listw()
# df is the data.frame with your data
# first generate sparse matrix product traces
W <- as(as_dgRMatrix_lw(lw), "CsparseMatrix")
trMat <- trW(W, type="MC")
SD_fit <- lagsarlm(y ~ x, data=df, listw=lw, type="mixed",
method="Matrix", tr=trMat, control=list(compiled_sse=TRUE))
# type="mixed" fits a Spatial Durbin model;
# method could also be "Chebyshev" or "MC" for approximations,
# "Matrix" uses updating sparse Cholesky Jacobians, see ?do_ldet
# for details. "Matrix" needs symmetric neighbours, some other methods
# may not. Beware of k-nearest neighbour schemes, for the same reasons
# as in GeoDa
summary(SD_fit)
# now generate samples from the fitted model to assess the
# significance of the impacts
imp_SD_fit <- impacts(SD_fit, tr=trMat, R=2000)
summary(imp_SD_fit)
plot(imp_SD_fit)
summary(imp_SD_fit, zstats=TRUE, short=TRUE)
Hope this helps,
Roger
>
> Thanks a lot for your kind help!
>
> Mi
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list