I'm doing a replication of an estimation done with Stata's xtregar
command, but I'm using R instead.
The xtregar
command implements the method from Baltagi and Wu (1999) "Unequally spaced panel data regressions with AR(1) disturbances" paper. As Stata describes it:
xtregar fits cross-sectional time-series regression models when the disturbance term is first-order autoregressive. xtregar offers a within estimator for fixed-effects models and a GLS estimator for random-effects models. xtregar can accommodate unbalanced panels whose observations are unequally spaced over time.
So far, for the fixed-effects model, I used the plm
package for R. The attempt looks like this:
plm(data=A, y ~ x1 + x2, effect = "twoways", model = "within")
Nevertheless is not complete (comparing to xtregar
description) and the results are not quite like the ones Stata provides. Furthermore, Stata's command needs to set a panel variable and a time variable, feature that's (as far as I can tell) absent in the plm
environment.
Should I settle with plm
or is there another way of doing this?
PS: I searched thoroughly different websites but failed to find a equivalent to Stata's xtregar
.
Update
After reading Croissant and Millo (2008) "Panel Data Econometrics in R: The plm
Package", specifically seccion 7.4 "Some useful 'econometric' models in nlme
" I used something like this for the Random Effects part of the estimation:
gls(data=A, y ~ x1 + x2, correlation = corAR1(0, form = ~ year | pays), na.action = na.exclude)
Nevertheless the following has results closer to those of Stata
lme(data=A, y ~ x1 + x2, random = ~ 1 | pays, correlation = corAR1(0, form = ~ year | pays), na.action = na.exclude)
index
argument! It is in the example section of?plm
. – Kota Mori