R language: ARIMA model

qianke321 注册会员
2023-02-25 11:12

the reference answer GPT ᴼ ᴾ ᴱ ᴺ ᴬ ᴵ < br / > lag for decimal condition may be due to the frequency of the time series data is not accurate. In R, the frequency parameter specifies the number of time units, while the start time of a time series specifies the point in time of the first time unit. In your code, you set the frequency to 12, indicating that there are 12 months in each year, but your data set starts in 2004, so you set start to 2009, which may cause the frequency of the time series to be imprecise, resulting in a lag of decimal values when plotting acf and pacf plots.
To solve this problem, you can set start to 2004 and convert the data to annual data. Doing so ensures that the frequency of the time series is accurate and that there will be no lag values of decimals when plotting acf and pacf plots. Here's some code that might work for you:

rate <- ts(DA$value, frequency = 12, start = c(2004, 1))
rate_yearly <- aggregate(rate, FUN = sum, k = 12) # 将月度数据转换为年度数据
z <- diff(rate_yearly) # 一阶差分

Here, we set start to c(2004, 1), indicating that it begins in January 2004. We then use the aggregate function to convert monthly data to annual data and set the frequency to 12. In this way, we can plot acf and pacf correctly without lag values of decimals.

dengh_dhsea 注册会员
2023-02-25 11:12
< div class = "md_content_show e397 data - v - 3967" = "" >

thank you for your answer. My data goes back to 2009, and that's my typing speed, sorry.
According to your method, it is indeed possible to reduce the lag of acf and pacf graphs without decimals. But if I convert the monthly data to the annual data, the number of data is greatly reduced to 13. As follows:


The subsequent difference of such data is wrong. In addition, I want the acf and pacf diagram of the data after difference to be correct. How should I solve this problem? Thanks!

About the Author

Question Info

Publish Time
2023-02-25 11:12
Update Time
2023-02-25 11:12