Implements a probabilistic ensemble time-series forecaster that combines an auto-encoder with a neural decision forest whose split variables are learned through a differentiable feature-mask layer. Functions are written with 'torch' tensors and provide continuous ranked probability score training, empirical or mixture forecast distributions, and optional forecast calibration.
temper fits a probabilistic time-series forecasting model using a temporal
encoder and a masked neural decision forest trained with the continuous ranked
probability score. It returns forecast distribution functions and plots.
Install the released package from CRAN with install.packages("temper").
The development source in this folder can be installed from RStudio using
Build > Install and Restart, or built with R CMD build . and installed from
the resulting source archive. The torch package also requires its LibTorch
and LibLantern libraries; see the torch installation guide.
library(temper)
set.seed(2025)
x <- 100 + cumsum(rnorm(250))
fit <- temper(x, future = 3, epochs = 2, verbose = FALSE)
fit$pred_funs$t3$qfun(c(0.1, 0.5, 0.9))
paths <- fit$path_prediction(100) # 100 complete paths, one per row
plot(fit$plot)
The default fit uses 60 epochs; this short example uses two for speed. Version
2.0 changes several model defaults and forecasting behavior compared with the
CRAN 1.1.1 release. See NEWS.md and ?temper for details.
Paths are sampled with replacement from the finite forest ensemble. If the
optional mixture distribution is selected, path samples remain empirical and
do not have the smoothed marginal distributions returned by pred_funs.