简体   繁体   中英

small Time Series Analysis

I need to make a prediction for the next 2 years. However, I have a very small amount of Data. Data:

   structure(list(BelegDat = structure(c(16801, 16832, 16861, 16892, 
    16922, 16953, 16983, 17014, 17045, 17075, 17106, 17136, 17167, 
    17198, 17226, 17257, 17287, 17318, 17348, 17379, 17410, 17440, 
    17471, 17501, 17532, 17563, 17591, 17622, 17652, 17683, 17713, 
    17744, 17775, 17805, 17836, 17866, 17897, 17928, 17956, 17987, 
    18017, 18048, 18078, 18109, 18140, 18170, 18201, 18231), class = "Date"), 
        Value = c(37, 28, 37, 47, 37, 28, 37, 37, 19, 37, 37, 28, 
        40, 30, 40, 50, 40, 30, 40, 40, 20, 40, 40, 30, 30, 40, 30, 
        30, 40, 30, 30, 50, 30, 50, 20, 20, 60, 20, 60, 40, 20, 10, 
        40, 20, 20, 10, 44, 33)), row.names = c(NA, -48L), class = "data.frame")

I am using ARIMA:

myts <- ts(df_ready[,2], start=c(2016,01), end=c(2019,12), frequency = 12)

fit <- auto.arima(myts)

pred <- forecast(fit, 24) # next 2 years (24 Months)
plot(pred)

My output: Output

Could you, please, show me my mistake / suggest some other way how this prediction can be done?

Thank you in advance!

There is an argument in auto.arima called D . We need to set it to 1 in order to force arima to use a seasonal model. In this case,

m1 <- ts(df$Value, start = min(df$BelegDat), frequency = 12)
autoplot(forecast(auto.arima(m1, D = 1), 24)) 

which gives,

在此处输入图片说明

Your data do not support any evidence of seasonality; your data are consistent with white noise shifted by an offset.

Forcing a specific SARIMA structure and then using that to forecast based on your white noise data is very dangerous.

To demonstrate, let's turn things around and generate white noise data that are shifted by the same offset and that have the same variance as your sample data. Keep in mind that this is white noise by design .

library(forecast)
library(ggplot2)
set.seed(2018)
ts <- ts(
    rnorm(48, mean = 33.8750, sd = 11.15796),
    start = c(2016, 1), frequency = 12)
autoplot(ts) + theme_minimal()

在此处输入图片说明

We now fit a SARIMA(0, 0, 0)(0, 1, 0) 12 model to the data.

fit <- arima(ts, order = c(0, 0 , 0), seasonal = list(order = c(0, 1, 0), period = 12))
fit
#
#Call:
#arima(x = ts, order = c(0, 0, 0), seasonal = list(order = c(0, 1, 0), period = 12))
#
#
#sigma^2 estimated as 283:  log likelihood = -152.7,  aic = 307.39

Again, keep in mind that data was generated from ARIMA(0,0,0) = SARIMA(0,0,0)(0,0,0), ie a white-noise model.

We now use fit to forecast

autoplot(forecast(ts, h = 24, model = fit)) + theme_minimal()

So what we've done here is to forecast based on white noise data assuming a non-existent seasonality effect.

在此处输入图片说明

Yes, you can do that without raising any warnings/flags within forecast . And no, these forecasts will not be meaningful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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