tidyverts / tidyverts/fable

[1] subscript out of bounds - What's the problem?

Open
#385 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 trying to calculate the accuracy of a single point forecast for 2013. Model is trained on 2010-2012 data. It produces expected result, but also throws error: [1] subscript out of bounds. How would I fix the error?

MRE:

df <- as_tsibble(data.frame(x = seq(2010:2013), y = sample(1:10, 4)), index = x)

df[1:3, ] %>%
  model(RW(y ~ drift())) %>%
  forecast(h = 1) %>%
  accuracy(df)

Result:

# A tibble: 1 × 10
  .model          .type    ME  RMSE   MAE   MPE  MAPE   MASE  RMSSE  ACF1
  <chr>           <chr> <dbl> <dbl> <dbl> <dbl> <dbl>  <dbl>  <dbl> <dbl>
1 RW(y ~ drift()) Test   -0.5   0.5   0.5   -10    10 0.0769 0.0750    NA
Warning message:
1 error encountered
[1] subscript out of bounds

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 running the supplied R MRE and inspect the accuracy(df) call after forecast(h = 1), focusing on the [1] subscript out of bounds warning. Done means the example returns its accuracy row without the warning, while preserving the reported metrics.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.