Skip to contents

Fit Model and Forecast

Core functions to fit a model and then forecast a time series.

learn_weights()
Fit a 3DX model to a time series
predict(<threedx>)
Draw forecast sample paths from a fitted 3DX model

Initialize Grid of Parameters

Helper functions to construct a grid of alpha parameters to be evaluated during model fitting, or use your own.

list_sampled_alphas()
Generate a data frame of possible alpha values to evaluate during training
list_edge_alphas()
Generate a data frame of possible alpha values to evaluate during training

Loss Functions

Loss functions to be used during model fitting, or use your own.

loss_mae()
Mean absolute error loss function
loss_mae_ignoring_bias()
Mean absolute error loss function ignoring bias
loss_mae_with_observation_weight()
Observation-weighted mean absolute error loss function
loss_rmse()
Root-mean-square error loss function
loss_rmse_ignoring_bias()
Root-mean-square error loss function ignoring bias

Innovation Methods

Methods of generating innovations to construct sample paths during prediction, or use your own.

draw_bootstrap()
Draw innovations by bootstrapping from unweighted residual errors
draw_bootstrap_weighted()
Draw innovations by bootstrapping from weighted residual errors
draw_bootstrap_zero_mean()
Draw innovations by bootstrapping from unweighted zero-mean residual errors
draw_normal_with_drift()
Draw i.i.d. innovations from a Normal distribution with non-zero mean
draw_normal_with_zero_mean()
Draw i.i.d. innovations from a Normal distribution with zero mean

Plot Model and Forecast

Custom functions to plot the fitted model and the forecast using ggplot2.

autoplot(<threedx>)
Autoplot method for threedx objects
autoplot(<threedx_paths>)
Autoplot method for threedx_paths objects

Generate Weights

Generate the weights that are the fundamental component of threedx models.

weights_exponential()
Derive exponential weights
weights_seasonal()
Derive seasonal exponential weights
weights_seasonal_decay()
Derive weights with seasonal exponential decay
weights_threedx()
Derive three-dimensional exponential (3DX) weights

Sample Path Postprocessing

Functions to postprocess samples during generation of forecast sample paths.

to_moment_matched_nbinom()
Postprocess to samples from a moment-matched negative-binomial distribution
to_non_negative_with_identical_mean()
Turn values non-negative while preserving their sample mean

Helper Functions

k_largest_weights_sum_to_less_than_p_percent()
Do the k largest weights sum up to less than p% of the total weights?
trade_loss_for_simplicity()
Allow for an increase in loss to find a simpler model
fitted(<threedx>)
Extract fitted values from a threedx model
residuals(<threedx>)
Extract residuals from a threedx model