James Ryans
2011-Nov-22 04:50 UTC
[R] Unexpected result with lag() et diff() in plm package.
I didn't see you got an answer posted to this question: You can't modify a pdata.frame object. Your transforms turn it back to a normal data frame and diff and lag won't work as expected. Try: Grunfeld.p <- pdata.frame(Grunfeld,c("firm","year")) tmp <- transform(Grunfeld.p, d.value = diff(Grunfeld.p$value,1)) tmp <- cbind(tmp, l.value = lag(Grunfeld.p$value,1)) ... When everything is in shape, convert it back to a pdata.frame for further analysis: Grunfeld.p <- pdata.frame(tmp,c("firm","year")) [[alternative HTML version deleted]]
Possibly Parallel Threads
- Unexpected result with lag() et diff() in plm package.
- Problems when using lag() in plm package
- Manual two-way demeaning of unbalanced panel data (Wansbeek/Kapteyn transformation)
- plm "within" models: is the correct F-statistic reported?
- singular matrices in plm::pgmm()