[R-sig-Geo] Fw: "Spdep" linear regression code

Roger Bivand Roger.Bivand at nhh.no
Wed Oct 26 16:00:47 CEST 2011


On Wed, 26 Oct 2011, Mariana Benitez rojas wrote:

>
>
> Thank you very much Roger and Dennis,
>
> I need to do spatial regression for my project on "house prices values" 
> so I will definitely need to use the wonderful "spdep" package (of 
> course the latest version 0.5-40).
>
> Along with reading more about R, I am curious to see how the statistics 
> like the "p-value" and "z-value" of auto-correlation parameters are 
> estimated. Also how "rho.se" or "lambda.se" and their covariances with 
> other coefficients are calculated in the coefficient covariance matrix 
> code so then I can understand and interpret it for myself.


The most up-to-date reference is given on the relevant help pages:

LeSage J and RK Pace (2009) Introduction to Spatial Econometrics. CRC 
Press, Boca Raton.

and the methods used for computing the standard errors vary depending on 
the method= and trs= arguments to lagsarlm() and errorsarlm() - trs= is 
not (yet) used in sacsarlm.

Roger


>
>
> Thanks for you helps,?
>
> ?
> Mariana Benitez Rojas
>
>
> Centro Federal de Educa??o Tecnol?gico (CEFET-PA)
>
>
>
> ________________________________
> From: Roger Bivand <Roger.Bivand at nhh.no>
>
> Cc: "r-sig-geo at r-project.org" <r-sig-geo at r-project.org>
> Sent: Wednesday, October 26, 2011 1:36 AM
> Subject: Re: [R-sig-Geo] "Spdep" linear regression code
>
> On Tue, 25 Oct 2011, Mariana Benitez rojas wrote:
>
>> Dear list,
>>
>> I am trying to study the code for spatial econometrics models in the "spdep" package. The code is understandable but I have some parts that I don't? understand for example why we need to do lm(y ~ x - 1) instead of just lm(y ~ x) since in other regression models in R we supposedly are doing this way instead of reducing the x by one.
>
> You are looking at the implementation code, but do not say what version. The code is not written to be understandable, but to work - most code tries to handle corner cases. Here, the lm() function is being used on the matrix of right-hand side variables, including the intercept, to see whether the user has included aliased (very collinear) variables. Consequently, -1 is added to the formula to tell lm() not to include an intercept. If covariates are aliased, they are omitted in ML fitting.
>
>>
>> Also for "lagsarlm"
> we use three types of regression lm.base(), lm.lag() and the simple (y~1) model so I am not sure which model is being used to compare against the lm.lag() or how we get the LR statistics.
>
> The intercept-only model is used to prepare a part of the Nagelkerke pseudo-R2.
>
>> Fore "errorsarlm" and "sacsarlm" we have the same situation but using lm.target() instead of lm.lag().
>>
>
> You probably need to know more R to read the code - these sub-objects and steps are not of great interest, and do not give you the log likelihood, which is shown in the summary(), and (surprisingly) logLik() methods for sarlm objects. For LR statistics, use the LR.sarlm() function.
>
>>
>> I would be so thankful if anybody could give the answer or show me the material that I can use for my study.
>
> You have not explained what the point of your study is, as far as I can see. The functions are fitting by maximum likelihood, and doing lots
> of extra things to accommodate for example alternative methods for computing the Jacobian, and for estimating the coefficient covariance matrix. So the lines you have chosen to report are not very odd, just auxiliary regressions used in getting to the user's chosen model fit.
>
> Hope this clarifies,
>
> Roger
>
>>
>>
>>
>> ?
>> Mariana Benitez Rojas
>>
>>
>> Centro Federal de Educa??o Tecnol?gico (CEFET-PA)
>>
>> ??? [[alternative HTML version deleted]]
>>
>>
>
> -- 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
> 	[[alternative HTML version deleted]]
>
>

-- 
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