Question about NNETAR from Section 12.4, Hyndman, 3rd edition


Please help with with the syntax of NNETAR. The example from 12.4 works, but when I try to modify it, I get an error:

fit_seasonal <- sunspots |> model(NNETAR(sqrt(value), formula = AR(p = NULL, P = NULL, period = 11)))
Error in list2(...) : object 'value' not found

I tried to specify p and P explicitly below. It doesn't fail, but the fitted model doesn't correspond to the specification:

fit_seasonal <- sunspots |> model(NNETAR(sqrt(value), p = 1, P = 1, period = 11))
fit_seasonal |> report()

Series: value
Model: NNAR(9,5)

Here I try to specify the period and find p and P automatically:

fit_seasonal <- sunspots |> model(NNETAR(value ~ AR(p = NULL, P = NULL, period = 11)))
Warning message:
1 error encountered for NNETAR(value ~ AR(p = NULL, P = NULL, period = 11))
[1] missing value where TRUE/FALSE needed

Referred here by Forecasting: Principles and Practice, by Rob J Hyndman and George Athanasopoulos

sunspots <- sunspot.year |> as_tsibble()
fit <- sunspots |>
  model(NNETAR(sqrt(value) ~ AR(P = 1, period = 11)))

However, I wouldn't use this model for sunspots. They are not periodic, and forcing a period of 11 doesn't really make sense. They are cyclic, not seasonal.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.