Skip to contents

Draw innovations by bootstrapping from weighted residual errors

Usage

draw_bootstrap_weighted(n, errors, weight_function, ...)

Arguments

n

The number of innovations to draw

errors

The residual errors that are used to define the distribution from which the innovations are drawn

weight_function

A function that takes errors as sole argument and must return a numeric vector of same length as errors to be used as prob argument by the underlying sample() call

...

Additional arguments passed from predict.threedx(), ignored

Value

A vector of same type as errors and of length n

Examples

model <- learn_weights(
  y = rpois(n = 55, lambda = pmax(0.1, 1 + 10 * sinpi(1:55 / 6))),
  period_length = 12L,
  alphas_grid = list_sampled_alphas(n_target = 25),
  loss_function = loss_mae
)

forecast <- predict(
  object = model,
  horizon = 12L,
  n_samples = 1000L,
  observation_driven = FALSE,
  innovation_function = draw_bootstrap_weighted,
  weight_function = function(x) {
    weights_exponential(alpha = model$alpha, n = length(x))
  }
)