首页 > 解决方案 > ACF 月度数据

问题描述

我有 275 行销售数据。我想从这个时间序列数据中创建 ACF。ACF 应该是从 1 到大约 69(书籍中的 275/4)

par(mfrow=c(2,1), mar=c(3,3,1,0)+.5, mgp=c(1.6,.6,0)) ts.plot(sales_ts_ohne_na,col="blue") acf(sales_ts_ohne_na)

在此处输入图像描述

标签: rtime-series

解决方案


您需要记住时间序列的采样频率。我假设它是 12,因为您有每月数据。

acf()中,如果您设置lag.max=69,您将获得高达 69 的延迟的 acf。但由于持续时间以周期计算,它将扩展到 5.75,即 69/12。如果您希望 x 轴对样本进行计数,则只需将采样频率设置为 1。

set.seed(1)
x <- sin(seq(0, pi*2*25, by=pi/(12/2)))
x.ts <- ts(x + rnorm(length(x)), f=12)

par(mfrow=c(3, 1))
acf(x.ts)
acf(x.ts, lag.max=69)
acf(ts(x.ts, f=1), lag.max=69)

在此处输入图像描述


推荐阅读