Open jkhanson1970 opened 2 years ago
Yes, you are right. This is (poorly) document in the NEWS for version 1.7-0 when the lag
, lead
, and diff
functions for panel data were enhanced (and defaulted) to allow time-wise shifting:
Note that, however, the diff-ing performed in first-difference model estimation by plm(..., model = "fd") is based on row-wise differences of the model matrix per individual.
Up until now, no one got around to implement this for plm's FD estimation. A workaround is to diff the data yourself before estimation. This seems like what you want to suggest with your examples, but note that you put model = "random"
where you want model = "pooling"
, i.e., set mod.alt <- plm(d.emp ~ d.wage + d.capital, data = Em, model = "pooling")
.
Thank you for the quick reply. I appreciate the clarification, as well as the correction to use "pooling" for the alternative model.
I am not sure, but I think that the row-wise differencing in the FD routine has downstream effects. For example, pwfdtest
also gives me different estimation sample sizes than the counterpart in Stata when using the same data. That's what first alerted me to the situation.
Yes, this is correct as well (as these tests internally use plm(., model = "fd")
).
Steps to get there:
pdiff
(in base R) for time-wise shifting pdiff
(fast collapse version) for time-wise shifting make.fdindex
as a helper function)
model.matrix.pdata.frame
and ptransform
)
Greetings,
It appears that method "fd" will calculate a first difference even when data points for previous time periods are missing. I noticed this when trying to get R and Stata to produce the same results for a model with first differences, in which plm with the fd method reported having more cases in the estimation.
Specifically, if data points in the middle of a panel series are missing, method fd will still construct a first difference by going back to the most recent period in which there is data, rather than drop the case.
I illustrate in the attached code using the EmplUK dataset. I set specific data points to missing. I then construct the first differences manually. Then, I compare fd using the source data in levels to method random using the first differenced data.
Kind regards,
Jon Hanson