Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why ACF not plotting lags

Tags:

r

time-series

Hi does anyone know why my ACF is not plotting my lag max when for my time series? You can use the airpassenger data in R for this question.

My code is:

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

and I'm getting

this

but want have 1-40 on the x-axis.

like image 535
Ryan Z Johnson Avatar asked Jan 17 '26 19:01

Ryan Z Johnson


1 Answers

The data is a time series by month. Forty lags spans a range of 40 months, or 3.33 years. The time unit on the x-axis is denominated in years and you're seeing lags of 0 to 40 months in the graph.

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.

enter image description here

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)

enter image description here

like image 108
eipi10 Avatar answered Jan 19 '26 18:01

eipi10