Problem with lagsarlm (spdep) with SparseM method

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Problem with lagsarlm (spdep) with SparseM method

Gilles Spielvogel
Regarding what I asked earlier: no error occurs if there are two exogenous
variables, and it does run incredibly faster (a few seconds instead of 15
minutes or so with the eigen method).
As far as I can understand, the problem I encountered comes from a sequence
in the sub-program dosparse, which says (in a loop over the columns of x):
        lm.null<, y)
If x has only two columns (which is the case if there is only one variable
on the right hand side), thisx has only one column at each step of the loop
and is not seen as a matrix by the function, which returns an error.

My questions are now:
- is my interpretation right ?
- is this a bug, or is this a desired feature ?
- if this a bug, is there a way to correct it and be able to run a lagsarlm
with one exogenous variable and the SparseM method ?

Thanks in advance.


-----Original Message-----
From: r-sig-geo-bounces at
[mailto:r-sig-geo-bounces at]On Behalf Of Gilles
Sent: vendredi 28 janvier 2005 18:14
To: r-sig-geo at
Subject: [R-sig-Geo] Problem with lagsarlm (spdep) with SparseM method


when running the command:

lagsarc2<-lagsarlm(vary ~ varx , mydata, c2.listw,,
type="lag", method="SparseM", quiet=FALSE, zero.policy=TRUE)

R returns the following error:

Spatial lag model
Jacobian calculated using sparse matrix techniques using SparseM
Error in, y) : `x' must be a matrix

The listw object I use comes originally from a queen contiguity GAL object
made with GeoDA. The command works perfectly if I use the option "eigen"
instead of "SparseM", but it takes a lot of time.

Does anyone have any idea about this problem ?

Thanks in advance for your help.


R-sig-Geo mailing list
R-sig-Geo at