Skip to content

Commit 96c0568

Browse files
authored
Merge pull request #1180 from m-muecke/fix/meanf-bootstrap-single-level
fix(meanf): handle single confidence level with bootstrap
2 parents fc8e015 + 792a53b commit 96c0568

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* `bld.mbb.bootstrap()` no longer errors when `num = 1` and now validates that `num` is a positive integer.
77
* `forecast.Arima()` now correctly passes `xreg` when `bootstrap = TRUE` (#1115).
88
* `forecast.ets()` now gives the intended error message when forecasting fails for a multiplicative trend model.
9+
* `meanf()` no longer errors with `bootstrap = TRUE` when a single confidence level is supplied.
910
* `nsdiffs()` now ignores extra arguments passed via `...` with `test = "seas"` instead of silently returning 0.
1011
* `print()` for `Arima()` models now displays the stored AICc and BIC values instead of recomputing them, which gave slightly different results for series with interior missing values.
1112
* `theta_model()` and `thetaf()` gained a `type` argument to select additive or multiplicative seasonal decomposition.

R/mean.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ forecast.mean_model <- function(
119119
nrow = h
120120
)
121121
sim <- sweep(sim, 1, f, "+")
122-
lower <- t(apply(sim, 1, quantile, prob = .5 - level / 200))
123-
upper <- t(apply(sim, 1, quantile, prob = .5 + level / 200))
122+
lower <- apply(sim, 1, quantile, prob = .5 - level / 200)
123+
upper <- apply(sim, 1, quantile, prob = .5 + level / 200)
124+
if (nconf > 1L) {
125+
lower <- t(lower)
126+
upper <- t(upper)
127+
} else {
128+
lower <- matrix(lower, ncol = 1)
129+
upper <- matrix(upper, ncol = 1)
130+
}
124131
} else {
125132
lower <- upper <- matrix(NA_real_, nrow = h, ncol = nconf)
126133
for (i in seq_len(nconf)) {

0 commit comments

Comments
 (0)