Generating a lagged time series cross sectional variable in R
问题 I am a new R user. I have a time series cross sectional dataset and, although I have found ways to lag time series data in R, I have not found a way to create lagged time-series cross sectional variables so that I can use them in my analysis. 回答1: Here's how you could use the lag() function with zoo (and panel series data): > library(plm) > library(zoo) > data("Produc") > dnow <- pdata.frame(Produc) > x.Date <- as.Date(paste(rownames(t(as.matrix(dnow$pcap))), "-01-01", sep="")) > x <- zoo(t