简体   繁体   English

在R中使用ACF函数获取时间序列数据

[英]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. 我是time-series analysis新手,并且有一个数据集,其每日时间步长为5个因子水平。 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. 我的目标是在R中使用acf函数来确定感兴趣的响应变量之间是否存在显着的自相关,以便我可以证明是否需要时序模型。

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. 数据集尚未转换为时间序列对象……它是按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? 我的第一个问题是,是否应将数据框转换为时间序列对象,或者按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? 其次,如果我有一个变量在每天的5个级别上重复,那么我应该为每个级别构造5个不同的acf图,还是可以像上面的代码那样在站上合并?

Thanks in advance, 提前致谢,

Yes, acf() will work on a data.frame class, and yes, you should compute the ACF for each of the 5 levels separately. 是的, acf()将在data.frame类上工作,是的,您应该分别计算5个级别的ACF。 If you pass the entire df to acf() , it will return the ACF for each of the levels. 如果将整个df传递给acf() ,它将返回每个级别的ACF。

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. 如果您对跨级别的关系感到好奇,则需要使用ccf()或某些互信息度量标准,例如entropyinfotheo pkgs中的度量标准。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM