[R-sig-Geo] Spatio-temporal regression in spdep

Roger Bivand Roger.Bivand at nhh.no
Mon Jan 24 09:28:12 CET 2011

On Sun, 23 Jan 2011, Ebrahim Jahanshiri wrote:

> Dear list
> I want to extend the spatial regression functions in spdep to do
> spatiotemporal regression. That is, instead of lambaW (lambda is
> autocorrelation parameter, W is the weighting matrix) I partition W to
> spatial(S), temporal(T) and spatial temporal (ST and TS) weight matrices
> (phi1S+phi2T+phi3ST+phi4TS) I am working to implement this inside the code
> for the ?spautolm?, It uses optimize method to get a value for lambda that
> maximizes the logliklihood fuction for the family chosen however I am
> puzzled as how to make the code ?optimize? for 4 parameters instead of one
> (also the meaning of ?.opt.fit? in the optimize formula), also how to make
> the logLik work for this type of the algorithm. I would appreciate even the
> smallest of clues.

?optimize (it does line search, so your surprise is unwarranted). If you 
really want to do this, please find a good, existing, open-source 
implementation to compare with, and re-implement from the ground up. Using 
spautolm(), which is only for a single spatial coefficient, will confuse 
you more than help you. In particular, you need to be very careful with 
the numerical optimization, as very often a naive implementation of a 
log-likelihood function is affected by scaling issues. I'm pretty certain 
that your ST and TS will mimic each other, and the optimizer will find it 
very hard to grasp your intentions (two local optima). You need to spend a 
lot of time with well-studied examples (and I don't think there are any or 
many such).

Have you looked at the work already done in the splm package on R-Forge?

Try to set this up in a Bayesian context in parallel, to get a sanity 
check on any results you think you have achieved.

Hope this helps,


> Ebrahim Jahanshiri
> Spatial and Numerical lab.
> 	[[alternative HTML version deleted]]

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