Forecasting - is my model performing well?

I'm new to forecasting and playing with some forecasting techniques. I used the ets function from te forecast package to automatically select the model. I want to do a check to see if the model has adequately captured the information in the data.

I used the checkresiduals() function and the Ljung-Box test with Box.test() as described in https://otexts.com/fpp2/residuals.html.

checkresiduals gives me a p-value lower than 0.05 where the Ljung-Box test gives me a p-value greater than 0.05.

I was suspecting a p-value greater than 0.05 by both methods. I'm really confused now.

Question

Is my model correct? Or is it incorrect and can it be optimized with for example ARIMA?

Data

    month_year  n
1	2017-12-01	75
2	2018-01-01	253
3	2018-02-01	99
4	2018-03-01	155
5	2018-04-01	186
6	2018-05-01	290
7	2018-06-01	400
8	2018-07-01	248
9	2018-08-01	148
10	2018-09-01	167
11	2018-10-01	181
12	2018-11-01	136
13	2018-12-01	94
14	2019-01-01	135
15	2019-02-01	134
16	2019-03-01	168
17	2019-04-01	172
18	2019-05-01	206
19	2019-06-01	896
20	2019-07-01	270
21	2019-08-01	183
22	2019-09-01	174
23	2019-10-01	164
24	2019-11-01	100
25	2019-12-01	123
26	2020-01-01	182
27	2020-02-01	155
28	2020-03-01	178

Code

# define time serie #
timeserie.ts <- ts(data$n, start=c(2017, 12), end=c(2020, 03), freq=12)
time <- time(timeserie.ts)

# split data in train & test #
n.valid <- 2
n.train <- length(tijdserie.ts) - n.valid
train.ts <- window(tijdserie.ts, start=time[1], end=time[n.train])
valid.ts <- window(tijdserie.ts, start=time[n.train+1], end=time[n.train+n.valid])

# use ETS to find the 'best' model #
modelfit <- ets(train.ts, model = "ZZZ")

# write away residuals #
res <- residuals(modelfit)

# ACF plot #
acf(res)

acf plot

#checkresiduals test#
checkresiduals(modelfit)

data:  Residuals from ETS(M,N,M)
Q* = 19.517, df = 3, p-value = 0.0002137

Residuals plot

# Ljung-Box test #
Box.test(res, type = "Ljung-Box")

data:  res
X-squared = 3.1101, df = 1, p-value = 0.07781
# forecast 6 months #
plot(forecast(modelfit, 6))

enter image description here

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.