Skip to content

Commit e8e60fc

Browse files
sbfnkclaude
andcommitted
Fix truth vector generation in forecastbaselines vignette
The code was trying to access out-of-bounds indices (trend[51:62] when trend only has 50 elements), which created NA values that became Missing in Julia, causing a type error. Fixed by generating future trend and seasonal values for the forecast horizon instead of trying to index beyond the data length. Error was: "expected Vector{Float64}, got Union{Missing, Float64}" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e5fa78e commit e8e60fc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

vignettes/forecastbaselines.Rmd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ To evaluate forecast accuracy, you need to provide the true values.
218218
```{r scoring}
219219
# Generate some "future" observations
220220
set.seed(456)
221-
truth <- trend[n + 1:12] + seasonal[n + 1:12] + rnorm(12, sd = 2)
221+
future_time <- (n + 1):(n + 12)
222+
future_trend <- 0.5 * future_time
223+
future_seasonal <- 5 * sin(2 * pi * future_time / 12)
224+
truth <- future_trend + future_seasonal + rnorm(12, sd = 2)
222225
223226
# Add truth to forecast
224227
fc_with_truth <- forecast(

0 commit comments

Comments
 (0)