简体   繁体   English

为什么ACF不绘制滞后

[英]Why ACF not plotting lags

Hi does anyone know why my ACF is not plotting my lag max when for my time series? 嗨,有人知道为什么我的ACF在我的时间序列中没有绘制最大滞后时间吗? You can use the airpassenger data in R for this question. 您可以在R中使用航空旅客数据。

My code is: 我的代码是:

acf(z.t, lag.max = 40, main = expression(paste("acf of Z"[t])))

and I'm getting 而我得到

这个

but want have 1-40 on the x-axis. 但想在x轴上设置1-40。

The data is a time series by month. 数据是按月的时间序列。 Forty lags spans a range of 40 months, or 3.33 years. 40个滞后跨度为40个月,即3.33年。 The time unit on the x-axis is denominated in years and you're seeing lags of 0 to 40 months in the graph. x轴上的时间单位以年为单位,您将在图表中看到0到40个月的滞后。

As another example, if you run acf(AirPassengers, lag.max=12) you can see that the x-axis has lags from 0 to 12 months and the axis is labeled from zero to 1 year. 再举一个例子,如果运行acf(AirPassengers, lag.max=12)您会看到x轴的滞后时间为0到12个月,并且该轴的标签为从零到1年。

在此处输入图片说明

You can relabel the axis if you wish. 您可以根据需要重新标记轴。 For example: 例如:

mx=40
acf(AirPassengers, lag.max=mx, xaxt="n", xlab="Lag (months)")
axis(1, at=0:mx/12, labels=0:mx)

在此处输入图片说明

That's because the units of the axis are in seasonal units (periods), not time units. 这是因为轴的单位是季节性单位(时段),而不是时间单位。

frequency(AirPassengers) gives 12, so monthly. frequency(AirPassengers)为12,所以每月一次。 The axis in your plot goes to ~3.33, which is precisely 40 / 12. 您绘图中的轴为〜3.33,正好是40/12。

You can get the values to generate your own plot from acf with x = acf(AirPassengers, lag.max = 40) and getting x$acf and x$lag . 您可以使用x = acf(AirPassengers, lag.max = 40)acf获取值以生成自己的图,并获取x$acfx$lag

You can also do: 您也可以:

library(forecast)
Acf(AirPassengers, lag.max = 40)

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

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