I trying out the plm package for some first difference estimation in R. As stated in the title I wonder how I can turn my POSIX dates like "2002-10-01" into values that are understood by plm's time index. I guess this means using integer values?
Here's what I tried so far:
panel.fd <- plm(y~X,index=c("datefield","id"),model="fd",data=z)
# returns
Error in pdim.default(index[[1]], index[[2]]) :
# when I convert my datefield to a factor, I get the same error...
z$t_idx <-as.factor(z$datefield)
You can turn it into an integer value with
unclass
.If you divide that number by 86400 you would get the number of days since 1970-1-1.
The plm package does not use the time variable for much else than indexing purposes, so you are right in only needing an integer value here.
EDIT:
How about formating it and then converting: