[R-sig-Geo] Common Factors test in R

Roger Bivand Roger@B|v@nd @end|ng |rom nhh@no
Fri Apr 5 21:35:26 CEST 2019


On Fri, 5 Apr 2019, Hulényi Martin wrote:

> Hello,
> I would like to perform a common factor test, conducted using likelihood 
> ratio test on spatial error model and spatial durbin model (both in 
> panel format).
> I have not found a command in R, that would help me to conduct the test. 
> Hence, I am trying to perform the test manuallly using the splm package 
> and data available in the splm and plm packages.

> Here is my code:
> library(splm)
> library(plm)
>
> data(Produc, package="plm")
> data(usaww)
>
> Produc <- pdata.frame(Produc, index = c("state", "year"))
>
> usaww<- mat2listw(usaww, style="W")
>
> Produc$slagUnemp <- slag(Produc$unemp, listw = usaww)
>
> durbin <- spml(gsp~unemp + slagUnemp,
>                data=Produc, listw=usaww,  effect = "twoways",
>                 model="within", lag=TRUE, spatial.error = "none",
>                  quiet = FALSE)
> spem  <- spml(gsp ~ unemp,
>                data=Produc, listw=usaww,  effect = "twoways",
>                model="within", lag=FALSE, spatial.error = "b",
>                quiet = FALSE)
> Is it correct to take the last value of the function from the console 
> output to compute the likelihood ratio?

Without checking whether the likelihoods are compatible (here probably 
are), you will not see whether the fitting functions concentrate them, 
possibly differently. Here both are lag=TRUE but one has 
spatial.error="none", the other "b", so without reading the code, you 
can't tell. It would be a good idea if these models had logLik() methods, 
because then lmtest::lrtest() should work. It then handles the degrees of 
freedom accounting between the models.

Hope this helps,

Roger

> Meaning, in this example, to calculate 2*(function(non-nested) - 
> function(nested)) = 2*(10261.79 - 10255.74) = 12.1?
> If it is correct, how can I compute the significance values?
> If it is not correct, is there a better way to compute this?
>
> Autorom tejto spr???vy elektronickej po???ty je Martin Hul???nyi. T???to spr???va je ur???en??? v???lu???ne jej adres???tovi. Inform???cie a ???daje, ktor??? s??? v nej uveden???, alebo ktor??? s??? obsiahnut??? v jej prilo???en???ch s???boroch, m???u by??? inform???ciami alebo ???dajmi chr???nen???mi pod???a platn???ch pr???vnych predpisov v Slovenskej republike. V pr???pade, ak nie ste ur???en??? ako prij???mate??? tejto spr???vy alebo jeho opr???vnen??? z???stupca, upozor???ujeme V???s, ???e inform???cie a ???daje v nej uveden??? nie ste opr???vnen??? sprac???va???, ani ich spr???stupni??? alebo poskytn?????? tretej osobe alebo ich zverejni???. Ak ste nedopatren???m prijali alebo zachytili tuto spr???vu elektronickej po???ty, dovo???ujeme si V???s po???iada???, aby ste ju zaslali sp??? na elektronick??? adresu jej odosielate???a, a aby ste ju n???sledne zmazali zo svojho po??????ta???a a z Va???ej schr???nky elektronickej po???ty. Odosielate??? tejto spr???vy nenesie zodpovednos??? za ???kody sp???soben??? nespr???vnym pou???it???m tejto spr???vy elektronickej po???ty a jej pr???loh.
>
> The author of this e-mail message is Martin Hul???nyi. This message is intended solely for the recipient. The information and data contained therein or contained in its enclosed files may be information or data protected under applicable laws in the Slovak Republic. If you are not designated as the recipient of this message or its authorized representative, we would like to inform you that the information and data contained therein are not authorized to process or make them available to third parties or to disclose them. If you have received or downloaded this e-mail message accidentally, we ask you to send it back to the e-mail address of the sender and then delete it from your computer and from your e-mail. The sender of this message is not responsible for damages caused by incorrect use of this e-mail message and its attachments.
> [eco.jpg]       Pred vytla???en???m tohto mailu zv???te pros???m vplyv na ???ivotn??? prostredie. ???akujeme.
> Please consider the environment before printing this e-mail. Thanks
>
> 	[[alternative HTML version deleted]]
>
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand using nhh.no
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en


More information about the R-sig-Geo mailing list