[R-sig-Geo] Calculating impact measures for spatial panel models and trouble specifying SDEM model using spml

Roger Bivand Roger@B|v@nd @end|ng |rom nhh@no
Wed Jul 24 15:50:13 CEST 2019


On Wed, 24 Jul 2019, Letisha Sarah Fong Rui Zhen wrote:

> Dear all,

Please do not post HTML-formated messages.

>
> I???m working with panel data of 9 countries and 18 years and I???m 
> running fixed effects SDEM, SLX and SEM with the splm package.
>
> I have three questions:
>
> 1. I can???t seem to get the SDEM model to run. My code for each of the
>    3 models is:
>
> model.SDEM <- spml(ln(Y) ~ ln(GDP) + (ln(GDP))^2 + EI + RE + 
> slag(ln(GDP), listw = my.listw) + slag((ln(GDP))^2, listw = my.listw), 
> data = my.data, listw = my.listw, model = ???within???, effect = 
> ???individual???, lag = F, spatial.error = ???b???)
>
> model.SLX <- plm(ln(Y) ~ ln(GDP) + (ln(GDP))^2 + EI + RE + slag(ln(GDP), 
> listw = my.listw) + slag((ln(GDP))^2, listw = my.listw), data = my.data, 
> model = ???within???, effect = ???individual???)
>
> model.SEM <- spml(ln(Y) ~ ln(GDP) + (ln(GDP))^2 + EI + RE, data = 
> my.data, listw = my.listw, model = ???within???, effect = 
> ???individual???, lag = F, spatial.error = ???b???)
>
> I am able to run both SLX and SEM models without problem, but when I try 
> to run the SDEM model, the error message is:
>
> Error in UseMethod("slag") :
>  no applicable method for 'slag' applied to an object of class
>  "c('double', 'numeric')"
>
> I don???t understand what is wrong here, as I have no problems with the 
> slag() function in the SLX model. My data is a pdataframe and each 
> variable is a numeric pseries.

My guess would be that you should protect your square with I() in general, 
but have no idea - this is not a reproducible example.

>
>
> 2. How can I calculate impact measures (direct, indirect and total) for
>    spatial panel models?
>
> The impacts() function in spdep doesn???t work anymore and the impacts() 
> function from the spatialreg package seems to work only for 
> cross-sectional data and not panel data.
>
> For example, I ran:
>
> spatialreg::impacts(model.SLX)
>
> And the error message is:
>
> Error in UseMethod("impacts", obj) :
>  no applicable method for 'impacts' applied to an object of class
>  "c('plm', 'panelmodel')"
>
> I have tried methods(impacts) but none of the functions seem to work for 
> my SLX model created with the splm package.

But your SLX model is created with the plm package, isn't it? The only use 
of splm is for the manual lags with slag()?

>
> I also looked at some previous examples in the splm documentation and 
> more specifically the spml() function and the example provided 
> (specifically the impact measures) doesn???t work anymore:
>
> data(Produc, package = "plm")
> data(usaww)
> fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
> ## random effects panel with spatial lag
> respatlag <- spml(fm, data = Produc, listw = mat2listw(usaww),
>                  model="random", spatial.error="none", lag=TRUE) 
> summary(respatlag) ## calculate impact measures impac1 <- 
> impacts(respatlag, listw = mat2listw(usaww, style = "W"), time = 17) 
> summary(impac1, zstats=TRUE, short=TRUE)
>

The implemented impacts methods in splm apply to the case where the lagged 
response is included. For SDEM and SLX, you can get the impacts by 
addition for the total impactss, and by linear combination for their 
standard errors. This is not implemented in a method. Further, slag() does 
not give any impacts method any information on which variables have been 
lagged - in your illustration above EI and RE are not lagged.

> The error message when I run the impacts() function is:
>
> Error in UseMethod("impacts", obj) :
>  no applicable method for 'impacts' applied to an object of class "splm"
>
> My question is therefore, how do I go about calculating direct, indirect 
> and total impact measures for spatial panel data?
>
>
> 3. How can I test if the SDEM model can be simplified to the SLX model
>    (since I estimate the SDEM by maximum likelihood (spml function) and
>    the SLX by ordinary linear regression (plm function))? From my
>    understanding the plm() function does not compute a loglikelihood or
>    AIC so I probably can???t do a likelihood ratio test to choose
>    between models (I haven???t tried this out because I???m stuck at
>    running the SDEM model).

Do you know definitely that plm does not provide a log likelihood? I 
realise that it isn't OLS unless pooled. Have you reviewed the JSS plm and 
splm articles?

Roger

>
> Any help or advice would be greatly appreciated. Thank you.
>
> Best wishes,
> Sarah
>
>
>
> ________________________________
>
> Important: This email is confidential and may be privileged. If you are 
> not the intended recipient, please delete it and notify us immediately; 
> you should not copy or use it for any purpose, nor disclose its contents 
> to any other person. Thank you.
>
> 	[[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