Reputation: 1
I want to replicate a Stata do.file (panel model) in R, but unfortunately I'm ending up with the wrong standard error estimates. The data is proprietary, so I can't post it here. The Stata code used looks like:
xtreg Y X, vce(cluster countrycodeid) fe nonest dfadj
With fe
for fixed effects, nonest
indicating that the panels are not nested within the clusters, and dfadj
for the fact that some sort of DF-adjustment takes place - not possible to find out which sort as of now.
My R-Code looks like this and makes me end up with the right coefficient values:
model <- plm(Y~X+as.factor(year),data=panel,model="within",index=c("codeid","year"))
Now comes the difficult part, which I haven't found a solution for so far, even after trying out numerous sorts of standard error robust estimation methods, for example making extensive use of lmtest
and various degrees of freedom transformation methods. The standard errors are supposed to follow a country-year pair pattern (captured by the variable countrycodeid
in the Stata code, which takes the form codeid-year, as there appears to be missing data for some variables which are not available on a monthly basis.
Does anyone know if there are special tricks to keep in mind when working with unbalanced panels and the plm()
package, which sort of DF-adjustment can be used, and if there is a possibility to group data in the coeftest()
function on a country-year basis?
Upvotes: 0
Views: 1822
Reputation: 9460
This is not a complete answer.
Stata uses a finite sample correction described in this post. I think that may get your standard errors a tad closer.
Moreover, you can learn more about the nonest/dfadj by issuing the help whatsnew9
. Stata used to adjust the VCE for the within transformation when the cluster()
option was specified. The cluster-robust VCE no longer adjusts unless the dfadj
is specified. You may need to use the version control to replicate old estimates.
Upvotes: 1