r - 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)
解决方案
您需要记住时间序列的采样频率。我假设它是 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)
推荐阅读
- c# - 找不到提供程序“System.Data.SQLite”的 MigrationSqlGenerator
- android - 将事件信息从自定义视图传递到 ViewModel
- java - 如何使用 Spring Boot 监听动态目的地?
- regex - 用于匹配 MAC 地址或“N A”的正则表达式
- android - 有没有人知道我的按钮不能在 android studio 的下一页继续
- javascript - Puppeteer 的 page.click() 正在处理一些链接,但不是其他链接
- python - 为什么我不能在 Python 中的流控制条件中使用 return()?
- c# - 实现组合框(下拉)作为新数据库记录的一部分
- php - 我可以对不在课堂上的函数使用 phpunit 测试吗?
- angular-hybrid - 如何在使用混合路由时以角度使用 ActivatedRoute?