amela
amela

Reputation: 3

Using acf function in r for time series data

I am new to time-series analysis and have a data set with a daily time step at 5 factor levels. My goal is to use the acf function in R to determine whether there is significant autocorrelation across the response variable of interest so that I can justify whether or not a time-series model is necessary.

I have sorted the dataset by Day, and am using the following code:

acf(DE_vec, lag.max=7)

The dataset has not been converted to a time-series object…it is a vector sorted by Day.

My first question is whether the dataframe should be converted to a time-series object, or if it is also correct to sort the vector by Day?

Second, if I have a variable repeated over the 5 levels for each Day, then should I construct 5 different acf plots for each level, or would it be ok to pool over stations as was done with the code above?

Thanks in advance,

Upvotes: 0

Views: 1721

Answers (1)

Mark S
Mark S

Reputation: 613

Yes, acf() will work on a data.frame class, and yes, you should compute the ACF for each of the 5 levels separately. If you pass the entire df to acf(), it will return the ACF for each of the levels.

If you are curious about the relationship across levels, then you need to use ccf() or some mutual information metric like those in the entropy or infotheo pkgs.

Upvotes: 2

Related Questions