-
Notifications
You must be signed in to change notification settings - Fork 22
Fitted Values and Forecasts
This page documents methods for extracting fitted values and generating forecasts from smooth models.
Generates point forecasts and optionally prediction intervals for h steps ahead.
In R, the standard method is forecast(), although predict() is also available, but with a limited functionality and focusing on the in-sample prediction.
In Python, use predict() method.
model <- adam(AirPassengers, "MMM", lags=12)
# Out-of-sample prediction
pred <- forecast(model, h=12, interval="prediction")
# In-sample confidence intervals
pred <- predict(model, interval="confidence")from smooth import ADAM
# Fit model
model = ADAM(model="ZZZ", lags=12)
model.fit(y)
# Basic point forecast
forecasts = model.predict(h=12)
# With prediction intervals (parametric)
forecasts = model.predict(
h=12,
calculate_intervals=True,
interval_method='parametric',
level=0.95
)
# Simulation-based intervals
forecasts = model.predict(
h=12,
calculate_intervals=True,
interval_method='simulation',
level=[0.8, 0.95],
nsim=1000
)
# One-sided intervals
forecasts = model.predict(
h=12,
calculate_intervals=True,
interval_method='parametric',
level=0.95,
side='upper'
)
# Access prediction intervals after calling predict()
intervals = model.predict_intervals(h=12, levels=[0.8, 0.95])| Parameter | Type (R) | Type (Python) | Default | Description |
|---|---|---|---|---|
object |
adam | ADAM | - | Fitted model |
h |
integer | int | 10 | Forecast horizon |
newdata |
matrix/data.frame | - | NULL | New explanatory variables for forecasting |
X |
- | NDArray | None | Exogenous variables for forecast period |
occurrence |
numeric vector | - | NULL | Future occurrence probabilities (values in [0,1]) if known |
calculate_intervals |
- | bool | True | Whether to calculate prediction intervals |
interval |
character | - | "none" | Interval type (see table below) |
interval_method |
- | str | "parametric" | Method: "parametric", "simulation", or "bootstrap" |
level |
numeric | float/list | 0.95 | Confidence level(s) |
side |
character | str | "both" | Interval side: "both", "upper", "lower" |
cumulative |
logical | - | FALSE | Produce cumulative forecasts (useful for inventory control) |
nsim |
integer | int | NULL | Number of simulations. |
scenarios |
logical | - | FALSE | Return simulated scenarios (only for interval="simulated") |
... |
- | - | - | Other parameters passed to underlying functions |
| Type | Description | Best For | R | Python |
|---|---|---|---|---|
"none" |
No intervals | Point forecasts only | Yes | Yes |
"prediction" |
Analytical for additive, simulated for others | General use (recommended) | Yes | - |
"parametric" / "approximate"
|
Analytical formulae for conditional variance | Fast, additive models | Yes | Yes |
"semiparametric" |
Based on multi-step forecast errors and assumed distribution | When residuals are not i.i.d. | Yes | - |
"nonparametric" |
Quantile regression (Taylor & Bunn, 1999) | Distribution-free | Yes | - |
"empirical" |
Empirical quantiles of multi-step forecast errors | Distribution and model free | Yes | - |
"simulated" / "simulation"
|
Monte Carlo simulation | Multiplicative models | Yes | Yes |
"bootstrap" |
Bootstrap-based intervals | Parameter uncertainty | - | Yes |
"confidence" |
Confidence intervals for point forecast via reforecast()
|
Uncertainty in the forecast line | Yes | - |
"complete" |
Accounts for parameter uncertainty via reforecast()
|
Full uncertainty quantification | Yes | - |
Note: "semiparametric", "nonparametric" and "empirical" use the
rmultistep()method to extract multistep in-sample forecast errors. See more in Residuals-and-Errors.
R: Returns an object of class "adam.forecast" / "smooth.forecast".
Python: predict() returns a NumPy array of point forecasts. Prediction intervals are stored in model.forecast_results and can be accessed via predict_intervals().
| Element | Description | R | Python |
|---|---|---|---|
model |
The estimated model object | Yes | - |
method |
Name of the model (e.g., "ETS(M,M,M)") | Yes | - |
mean / forecast
|
Point forecasts (conditional mean) | Yes | Yes |
lower |
Lower prediction bounds (matrix with columns per level) | Yes | Yes |
upper |
Upper prediction bounds (matrix with columns per level) | Yes | Yes |
level |
Confidence level(s) used | Yes | Yes |
side |
Which side of intervals was requested | - | Yes |
interval |
Whether intervals were produced (logical) | Yes | - |
scenarios |
Matrix of simulated scenarios (h × nsim) | Yes | - |
Notes:
- In R, access elements via
$(e.g.,fc$mean,fc$lower) - In Python,
predict()returns point forecasts directly; usepredict_intervals()to get a dictionary withforecast,lower,upperkeys - In R,
scenariosis only populated wheninterval="simulated"andscenarios=TRUE
Extracts fitted (in-sample predicted) values from the model.
model <- adam(AirPassengers, "MMM", lags=12)
# Get fitted values
fitted(model)from smooth import ADAM
model = ADAM(model="MMM", lags=12)
model.fit(y)
# Get fitted values
fitted_values = model.fittedR: Returns a time series with fitted values for each in-sample observation.
Python: Returns an NDArray with fitted values for each in-sample observation.
Extracts the actual (observed) values used in model estimation.
model <- adam(AirPassengers, "MMM", lags=12, h=12, holdout=TRUE)
# Get actuals
y <- actuals(model)from smooth import ADAM
model = ADAM(model="MMM", lags=12)
model.fit(y)
# Get actuals (the data used for fitting)
actuals = model.actualsR: Returns a time series with the actual in-sample observations.
Python: Returns an NDArray with the actual in-sample observations.
- ADAM - Main ADAM function
- Coefficients-and-Parameters - Extracting model parameters
- Simulation-Functions - simulate() and sim.* functions
- Refitting-and-Reforecasting - Parameter uncertainty analysis
- Visualisation-and-Output - Plotting forecasts