[R-sig-Geo] spatial durbin model with large dataset
Mi Diao
diaomi at gmail.com
Wed Jun 23 21:28:36 CEST 2010
Thanks a lot for your help, Roger!
I ran into another problem when I try to calibrate spatial lag and
spatial durbin model with this dataset using spdep. The error messages
that I got are:
Error in solve.default(-(mat), tol.solve = tol.solve) :
Lapack routine dgesv: system is exactly singular
In addition: There were 38 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: In determinant(x, TRUE) : This version of the Matrix package returns
|determinant(L)| instead of determinant(A), i.e., a
*DIFFERENT* value.
If still necessary, do change your code, following
http://matrix.r-forge.r-project.org
2: In optimize(sar.lag.mixed.f, interval = interval, maximum = TRUE, ... :
NA/Inf replaced by maximum positive value
......
I have been able to calibrate the spatial lag model with the same
dataset using Geoda. Could anyone help me figure this out?
Thanks a lot!
Mi
On Mon, Jun 21, 2010 at 5:13 AM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
> 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
>
>
--
--------------------------------------------------------------
Mi Diao
Ph. D. Candidate
Department of Urban Studies and Planning
Massachusetts Institute of Technology
Cambridge, MA 02139
More information about the R-sig-Geo
mailing list