[R] lagsarlm - using mixed explanatory variables (spdep package)

Roger Bivand Roger.Bivand at nhh.no
Thu Nov 27 18:03:42 CET 2003


On Thu, 27 Nov 2003, Roy Sanderson wrote:

> Hello

Usually it is easier to send package questions directly to the package 
maintainer, because they may not interest the whole list.

> 
> I'm very new to R (which is excellent), so apologies if this has already
> been raised.  In the spdep package, I'm trying to undertake an
> autoregressive mixed model using the lagsarlm function.  This is working
> fine, but there does not appear to be a method of including an explanatory
> variable without it automatically being included as a lagged term.  I'm
> after something along the lines of
> 
> y = rho.W.y + x1 + x2 + lag(x2)
> 
> but am only able to output
> 
> y = rho.W.y + x1 + x2 + lag(x1) + lag(x2)
> 

Using the old Columbus data set in the spdep package:

> data(oldcol)
> lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, nb2listw(COL.nb))
> lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, nb2listw(COL.nb), 
+ type="mixed")

give the standard lag and mixed model types, but you need to use
type="lag" and include the spatially lagged x variable(s) manually:

> WINC <- lag.listw(nb2listw(COL.nb), COL.OLD$INC)
> lagsarlm(CRIME ~ INC + HOVAL + WINC, data = COL.OLD, nb2listw(COL.nb))

Hope this helps,

Roger


> Is there any way around this issue?
> 
> Many thanks
> Roy
> 
> ----------------------------------------------------------------------------
> Roy Sanderson
> Centre for Life Sciences Modelling
> Porter Building
> University of Newcastle
> Newcastle upon Tyne
> NE1 7RU
> United Kingdom
> 
> Tel: +44 191 222 7789
> 
> r.a.sanderson at newcastle.ac.uk
> http://www.ncl.ac.uk/clsm
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list