Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OLS with both panel-corrected standard errors and AR(1) correction in R

Tags:

r

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.

like image 252
GK3 Avatar asked Oct 22 '17 20:10

GK3


1 Answers

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)
like image 189
Vaibhav Avatar answered Nov 13 '22 06:11

Vaibhav