[R] detecting autocorrelation structure in panel data

Matteo Richiardi matteo.richiardi at gmail.com
Mon Nov 28 03:54:06 CET 2011


Hello,
I'm a newby in R. I have created a data.frame holding panel data, with
the following columns: "id","time","y", say:

periods = 100
numcases = 100
df = data.frame(
 id = rep(1:numcases,periods),
 time = rep(1:periods, each = numcases)
)
df = transform(df,y=c(rnorm(numcases*periods)+id)

I want to check whether "y" is autocorrelated. I came across the acf()
function, but I cannot understand how to specify that my time variable
is "time" and that individuals are identified by their "id". I have
also tried to convert my data.frame in a ts or a xts object, but got
really lost there. I'd really apreciate help...

Thank you,
Matteo



More information about the R-help mailing list