[R-sig-Geo] Common Factors test in R
Hulényi Martin
m@rt|n@hu|eny| @end|ng |rom v|@d@@gov@@k
Mon Apr 8 16:18:22 CEST 2019
Thank you very much.
I tried it with lrtest, but i got the following error:
> lrtest(durbin1, spem)
Error in UseMethod("logLik") :
no applicable method for 'logLik' applied to an object of class "splm"
As you said, it might have been caused by the fact that panel spatial error model does not produce log likelihood.
Would you say that using slmtest to compare the two models is better?
Best regards,
Martin
-----Original Message-----
From: Roger Bivand [mailto:Roger.Bivand using nhh.no]
Sent: Friday, April 5, 2019 9:35 PM
To: Hulényi Martin <martin.hulenyi using vlada.gov.sk>
Cc: r-sig-geo using r-project.org
Subject: Re: [R-sig-Geo] Common Factors test in R
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
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
More information about the R-sig-Geo
mailing list