tidyverts / tidyverts/fable

Forecasting with NNETAR fit leads to "! I can't use NNETAR to forecast..."

Open
#422 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
588
Forks
71
Avg merge
1h 58m
Merged PRs (30d)
1

Description

I am getting this error that is identical to the error in this issue:
https://github.com/tidyverts/fable/issues/326

I am able to fit this model as follows:

fit <- train |>
model(NNETAR(var1 ~ lag(var2, n = 1L) + lag(var3, n = 1L)))

However, use of that fit in fc and in a plot with this code will result in the error:

fit |>
forecast(new_data = test) |>
autoplot(train) +
autolayer(test3, close, colour = "orange")

A paste of what appears to be the critical part of the backtrace:

  1. │ └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
  2. │ └─mask$eval_all_mutate(quo)
  3. │ └─dplyr (local) eval()
  4. ├─fable (local) sim_nnetar(.innov)
  5. │ └─rlang::abort("I can't use NNETAR to forecast with missing values near the end of the series.")
  6. │ └─rlang:::signal_abort(cnd, .file)
  7. │ └─base::signalCondition(cnd)
  8. └─dplyr (local) <fn>(<rlng_rrr>)

Finally, if TSLM() is used to fit that same model and with the same data, all works fine. And there is no missing values anywhere. 'Test' is 90 rows long.

Also, I am not sure if using lag() as above is best way to have NNETAR employ the variables from previous day.

Thanks in advance for assisting with this!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the NNETAR fit and forecast pipeline shown in the issue with the referenced fable issue 326, then inspect the reported sim_nnetar backtrace. Reproduce the failure with the lagged var2 and var3 inputs and test whether forecasting the 90-row test data succeeds without the missing-values error; compare the result with TSLM().

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.