[R-sig-Geo] Spatial Regression Eigenwert-Matrix
Roger Bivand
Roger.Bivand at nhh.no
Mon Nov 25 13:31:02 CET 2013
On Fri, 22 Nov 2013, Jacqueline Schweizer wrote:
>
>
> Hello everybody,
>
> I am trying to test my model (lm) in a spatial regression model. I have
> already done the moran I test and found, that due to the spatial
> correlation it would be wise to try a spatial regression model. When I
> try to do the eigenwert-matrix or the spatial lag model, i get the
> following error:
>
You did not provide the output of sessionInfo(), but I assume that you are
using 32-bit Windows. On 64-bit Linux, the error message is:
> oo <- matrix(0, nrow = n, ncol = n)
Error: cannot allocate vector of size 36.5 Gb
You also omitted to report the output of traceback() run after the error
occurred, so it isn't obvious where this happens
The underlying question is why you want to try to do something that is
hard (handling large dense matrices), when easier alternatives are
provided in the same model-fitting function you are using. If you look at
the help page for lagsarlm(), you'll see that for your intrinsically
asymmetric weights (k-nearest neighbours are almost always asymmetric),
your choices for an exact fit are method="eigen" and method="LU", and
"eigen" presumes moderate n (say < 5000 in most cases).
"LU" provides the same numerical result as "eigen", but is not limited to
moderate n, because it uses a sparse representation of W; for large n it
will take some time. Analytical standard errors are not available for
"LU", with values based on the numerical Hessian returned - you may wish
to pass the traces of the power series of W to lagsarlm() to improve the
numerical Hessian values. See Lesage & Pace (2009) and Bivand, Hauke &
Kossowski (2013) for details.
There are further possibilities for approximations, also described in
?do_ldet.
Note that the output coefficients of lagsarlm() cannot be interpreted, so
you will also need to use impacts() to get to something you can use.
Hope this helps,
Roger
>
> #-------------------------------------------------------------
> Fehler in matrix(0, nrow = n, ncol = n) : zu viele Elemente angegeben
> #-------------------------------------------------------------
> -> English: to many elements specified
>
>
> I have a dataset of about 70'000 points. Is it possible that this is too much for the eigenwert-matrix? I use library (spdep)
>
> Here's my code:
>
> #-------------------------------------------------------------
> # Get coordinates
> d.angeb.efh.sub2$residuals <- reg.lm.bereinigt2$residuals
>
> crds <- as.matrix(d.angeb.efh.sub2[, c("LON1903","LAT1903")])
>
> t.neig <- knn2nb(knearneigh(crds, k=4, longlat=FALSE))
>
>
> # Weights-Matrix (W = row-standardized)
> n.listw.obj <- nb2listw(t.neig, style="W")
>
> # Moran's I Test
> moran.test(reg.lm.bereinigt2$residuals, listw=n.listw.obj, alternative="two.sided", na.action=na.exclude,
> zero.policy=TRUE)
>
> # Spatial Lag Model
> mod.lag.eig <- lagsarlm(log(VPREIS) ~
> as.factor(ALTER.CL2) +
> as.factor(ZIMMERK) +
> log(FLAE) +
> log(FLAE):as.factor(ZIMMERK) ,
> data=d.angeb.efh.sub2,
> n.listw.obj, method="eigen",
> quiet=FALSE)
>
> # Fehler in matrix(0, nrow = n, ncol = n) : zu viele Elemente angegeben
> #-------------------------------------------------------------
>
>
>
> Does anyone have a tip how to handle bigger datasets or am I missing something and focusing on the wrong problem?
>
> Thanks for the help,
> Jacqueline
>
> Disclaimer\ \ Die in dieser E-Mail enthaltenen Informati...{{dropped:27}}
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
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