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]]

