smooth.SMA.residuals

property SMA.residuals: ndarray[tuple[Any, ...], dtype[_ScalarT]]

Return model residuals (errors from fitting).

For additive error models, residuals are y_t - fitted_t. For multiplicative error models, residuals are y_t / fitted_t - 1. For combined models, returns residuals computed from the IC-weighted combined fitted values: y_t - combined_fitted_t.

The log-domain and multiplicative-domain distributions are the exception: dlnorm, dllaplace, dls, dlgnorm, dgamma and dinvgauss return the ratio y_t / fitted_t rather than an error, because that is the quantity their densities are written in. Mirrors R’s residuals.adam (R/adam.R:5383-5403): abs(1 + e/f) for an additive error and 1 + e for a multiplicative one.

Returns:

Array of residuals from the fitted model.

Return type:

NDArray

Raises:

ValueError – If the model has not been fitted yet.

Examples

>>> model = ADAM(model="AAN")
>>> model.fit(y)
>>> errors = model.residuals
>>> rmse = np.sqrt(np.mean(errors**2))