I am looking to replicate the following Stata command in R:
xtpcse y x1 x2 x3 x4 i.xfe, corr(ar1) pairwise
where i.xfe is a fixed-effects factor.
I have typically used plm
with the coeftest
function (with vcovBK
) for running regressions with panel-corrected standard errors. But it does not appear, unless I am mistaken, that an AR1 correlation structure can be incorporated into a plm
regression.
I believe I can use the gls
function in the nlme
package to incorporate an AR1 structure:
gls(y ~ x1 + x2 + x3 + x4 + factor(xfe),
data = data,
correlation = corAR1(form=~1),
na.action = na.omit)
but I have not been able to find a way of then calculating PCSEs. vcovBK
does not appear to accept gls
-type objects.
How can both PCSEs and an AR1 correction be incorporated into a model in R? Any help would be appreciated.
The method you want to use is the Praise-Winsten regression for panel data.
The panelAR package in R can be used to do this. I have given an example of stata code and its equivalent for R. Stata code:
xtpcse depvar indepvar, correlation(psar1)
Rcode:
require(panelAR)
panelAR(formula = formula ,data = data, panelVar = 'N', timeVar = 'T',
panelCorrMethod = "pcse", autoCorr = "psar1", complete.case = T)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.