-
Notifications
You must be signed in to change notification settings - Fork 22
Coefficients and Parameters
This page documents methods for extracting and analysing model parameters from smooth models.
Extracts the estimated parameters from the model.
model <- adam(AirPassengers, "MMM", lags=12, h=12, holdout=TRUE)
# Extract all coefficients
coef(model)
# Same as
coefficients(model)from smooth import ADAM
model = ADAM(model="MMM", lags=12)
model.fit(y)
# Extract all coefficients
coefficients = model.coef
# Matching parameter names (coef is a bare NDArray)
model.coef_names # e.g. ['alpha', 'beta', 'gamma', 'level', 'trend', 'seasonal_1', ...]R: Returns a named vector containing:
- Smoothing parameters (alpha, beta, gammas, deltas)
- Damping parameter (phi) if applicable
- ARIMA parameters (AR, MA coefficients) if applicable
- Initial states (level, trend, seasonal, ARIMA states)
- Regression coefficients if applicable
Python: Returns an NDArray containing the estimated parameter vector (B). The
matching labels (in the same order) are available via model.coef_names, which
mirror R's naming (alpha, beta, gamma/gamma1, phi, level, trend,
seasonal_1…, ARIMA phi1[1]/theta1[1], regressor names, constant).
model <- adam(AirPassengers, "MAM", lags=12)
coef(model)
# Output:
# alpha beta gamma level trend seasonal1 ...
# 0.3521234 0.0012345 0.0001234 126.3456789 0.9987654 0.8765432 ...Computes confidence intervals for the estimated parameters.
model <- adam(AirPassengers, "MMM", lags=12, h=12, holdout=TRUE)
# 95% confidence intervals (default)
confint(model)
# 99% confidence intervals
confint(model, level=0.99)
# Bootstrap-based confidence intervals
confint(model, bootstrap=TRUE, nsim=1000)from smooth import ADAM
model = ADAM(model="MMM", lags=12)
model.fit(y)
# 95% confidence intervals (default) — returns a pandas DataFrame
model.confint()
# 99% confidence intervals
model.confint(level=0.99)
# Only selected parameters
model.confint(parm=["alpha", "beta"])Note: The Python
confint()reproduces R's interval construction, including the clamping of bounds to the admissible region for ETS smoothing parameters (alpha,beta,gamma,phi) and ARIMA AR/MA coefficients. Bootstrap intervals (bootstrap=TRUE) are R-only.
| Parameter | Type (R) | Type (Python) | Default | Description |
|---|---|---|---|---|
object / model |
adam |
ADAM (self) |
- | Fitted model |
parm |
character |
list / str / None
|
NULL / None
|
Which parameters (NULL/None = all) |
level |
numeric | float |
0.95 | Confidence level |
bootstrap |
logical | (R only) | FALSE | Use bootstrap for intervals (passed to vcov()) |
step_size |
- |
float / None
|
- / None
|
Finite-difference step for the Fisher Information |
... |
- | - | - | Additional parameters passed to vcov() if bootstrap=TRUE (R) |
-
R: a matrix with columns
S.E.(if bootstrap=TRUE), lower bound (e.g.2.5%) and upper bound (e.g.97.5%). -
Python: a
pandas.DataFrameindexed by the parameter names (model.coef_names) with columns["S.E.", "<lo>%", "<hi>%"](e.g.2.5%,97.5%).
Python occurrence models:
confint()is available for bothOMandOMG.OMoverrides the Fisher Information path so the cumulative-logistic (plogis) occurrence distribution is handled correctly;OMGdefines its own. See OM.
Returns the variance-covariance matrix of the estimated parameters. It is obtained by inverting the observed Fisher Information matrix (the negative Hessian of the log-likelihood at the optimum).
model <- adam(AirPassengers, "AAN", h=12, holdout=TRUE)
# Get covariance matrix (Fisher Information based)
V <- vcov(model)
# Bootstrap-based covariance matrix
V <- vcov(model, bootstrap=TRUE, nsim=1000)
# Heuristic estimation (fast approximation)
V <- vcov(model, heuristics=0.1)
# Standard errors
sqrt(diag(V))import numpy as np
from smooth import ADAM
model = ADAM(model="AAN")
model.fit(y)
# Covariance matrix (Fisher Information based) — pandas DataFrame
V = model.vcov()
# Heuristic estimation (fast diagonal approximation)
V = model.vcov(heuristics=0.1)
# Standard errors
np.sqrt(np.diag(V))Note: When the model was fitted with
fi=True, the cached Fisher Information is reused; otherwise it is computed on demand. Bootstrap covariance (bootstrap=True) is supported in both R and Python — Python dispatches to.coefbootstrap(),method="cr"only.
| Parameter | Type (R) | Type (Python) | Default | Description |
|---|---|---|---|---|
object / model |
adam |
ADAM (self) |
- | Fitted model |
bootstrap |
logical | bool |
FALSE / False | Use bootstrap (delegates to coefbootstrap()). Python supports method="cr" only. |
heuristics |
numeric |
float / None
|
NULL / None
|
If set, variance equals abs(coef)*heuristics. Fast approximation |
step_size |
- |
float / None
|
- / None
|
Finite-difference step for the Fisher Information |
... |
- | - | - | Additional parameters passed to coefbootstrap() if bootstrap=TRUE (R) |
Returns a square matrix (R) / pandas.DataFrame (Python) with:
- Rows/columns named by parameters (Python:
model.coef_names) - Diagonal contains variances
- Off-diagonal contains covariances
The analytical FI is computed by central finite differences on the
cost function. R and Python share a single C++ implementation
(src/headers/hessianCore.h) that uses per-parameter relative
steps:
h_i = ε^(1/4) · max(|x_i|, 1)
For parameters with |x_i| ≤ 1 (the smoothing parameters
α, β, γ, the damping φ, ARIMA AR/MA coefficients, OM persistence,
etc.) the step degenerates to the original absolute
h = ε^(1/4) ≈ 1.22e-4 — so the result is bit-equivalent to a pure
absolute scheme. For parameters with |x_i| > 1 (most importantly
the initial level / trend / seasonal states that enter B when
initial="optimal" or "two-stage" is used — these have magnitudes
on the data scale, e.g. level ≈ 280 for AirPassengers) the step
scales up so the relative perturbation h_i / |x_i| stays above the
cost-function precision floor and the Hessian entry is recovered
without catastrophic cancellation.
"two-stage" is handled identically to "optimal" in the FI path:
the two share the same B shape (initials are estimated), the
staged path just hands the optimiser a better starting point. R
aliases initialType="two-stage" to "optimal" inside the FI
refit; Python's FI methods don't branch on initial type so the
relative-step C++ change is sufficient.
A post-hoc retry with h = ε^(1/6) ≈ 7.4e-3 is kept as a safety
net for genuinely ill-conditioned models (all(FI==0) or any isnan(FI) in a row), but fires rarely with the relative-step rule.
When the analytical FI is undeterminable (e.g. a non-PSD Hessian),
vcov(bootstrap=True) provides the alternative — see
coefbootstrap() below.
Generates bootstrap estimates of model coefficients for inference. R's method is defined in greybox and extended for adam / om / omg; the Python port mirrors the same API on the ADAM, ES, MSARIMA, OM, OMG classes (method="cr" only — see Differences below).
model <- adam(AirPassengers, "AAN", h=12, holdout=TRUE)
# Bootstrap with default settings
bootCoef <- coefbootstrap(model)
# Bootstrap with custom settings
bootCoef <- coefbootstrap(model, nsim=500, method="dsr", parallel=TRUE)
# Examine distribution
hist(bootCoef$coefficients[,"alpha"])
# Bootstrap confidence intervals
apply(bootCoef$coefficients, 2, quantile, probs=c(0.025, 0.975))
# Extract the covariance matrix
bootCoef$vcovfrom smooth import ADAM
model = ADAM(model="AAN").fit(y)
# Bootstrap with default settings (nsim=1000)
boot = model.coefbootstrap()
# Reproducible with seed; smaller nsim for a quick sanity check
boot = model.coefbootstrap(nsim=100, seed=42)
# Bootstrap-based covariance and CIs go through the same dispatch
V = model.vcov(bootstrap=True, nsim=100, seed=42)
ci = model.confint(bootstrap=True, nsim=100, seed=42, level=0.95)
# Replicate matrix and empirical covariance
boot.coefficients # pandas.DataFrame, nsim_effective × k
boot.vcov # pandas.DataFrame, k × k| Parameter | Type (R) | Type (Python) | Default | Description |
|---|---|---|---|---|
object |
adam / om / omg | self |
- | Fitted model |
nsim |
integer | int |
1000 | Number of bootstrap samples |
size |
integer |
int / None
|
floor(0.75*nobs(object)) | Size of each bootstrap sample (case resampling) |
replace |
logical | bool |
FALSE | Sample with replacement |
prob |
numeric vector | array-like / None
|
NULL | Probability weights for sampling |
parallel |
logical/integer |
bool / int
|
FALSE | Run replicates in parallel. R uses foreach + doParallel/doMC; Python uses joblib.Parallel (optional dep — pip install "smooth[parallel]"). Pass an integer to set the worker count explicitly. If joblib is missing, Python warns and falls back to serial. |
method |
character | str |
"cr" | Bootstrap method: "cr" (Case Resampling) or "dsr" (Data Shape Replication). Python raises on "dsr" until greybox::dsrboot is ported |
seed |
- |
int / None
|
- / None
|
Python-only — seeds the NumPy Generator for reproducible replicates |
verbose |
- | bool |
- / False
|
Python-only — prints progress every 10% of replicates |
| Method | Description | Python support |
|---|---|---|
"cr" |
Case Resampling — resamples observations with varying sample sizes | ✓ |
"dsr" |
Data Shape Replication — model-free, creates data of similar shape to the original series | ✗ (raises NotImplementedError) |
R returns an object of class "bootstrap"; Python returns a BootstrapResult dataclass with the same fields:
R $ element |
Python attribute | Description |
|---|---|---|
vcov |
.vcov |
Empirical covariance of replicates (R: matrix; Python: pd.DataFrame) |
coefficients |
.coefficients |
Replicate matrix, rows = replicates, columns = parameters |
method |
.method |
"cr" or "dsr"
|
nsim |
.nsim |
Replicates requested |
size |
.size |
Subsample size per replicate |
replace |
.replace |
Sampling with replacement |
prob |
.prob |
Sampling weights |
parallel |
.parallel |
Whether parallel execution actually ran (Python flips this to False if joblib was missing) |
model |
.model |
Model spec (e.g. "AAN", "omg") |
timeElapsed |
.time_elapsed |
Wall-clock seconds |
| - | .nsim_effective |
Python-only — replicates that converged (failures dropped) |
- Python supports
method="cr"only.method="dsr"(Data Shape Replication viagreybox::dsrboot) raisesNotImplementedErroruntil the underlyingdsrboothelper is ported. - Parallel execution uses
joblib.Parallelinstead of R'sforeach/doParallel/doMC.joblibis an optional dependency (pip install "smooth[parallel]"). If it's not importable,parallel=Trueemits a one-lineUserWarningand runs serially, mirroring R's "ifdoParallelis missing, fall back" pattern. - Python adds two convenience kwargs:
seed=(deterministic vianumpy.random.default_rng) andverbose=(progress prints). With a fixedseed=, serial and parallel runs produce bit-identical replicate matrices — indices are pre-generated upstream and the optimiser is deterministic. - Replicates that fail (non-convergence or mismatched parameter count) are silently dropped;
nsim_effectiverecords the surviving count. R does up to 100 retries for an OM replicate before giving up.
- Svetunkov, I. (2023). Forecasting and Analytics with the Augmented Dynamic Adaptive Model (ADAM). Chapman and Hall/CRC. Online: https://openforecast.org/adam/.
- ADAM - Main ADAM function
- Fitted-Values-and-Forecasts - Fitted values, forecasts and simulation
- Refitting-and-Reforecasting - Parameter uncertainty analysis
- Visualisation-and-Output - Plotting forecasts