RandomWalkWithDrift
chronax.models.RandomWalkWithDrift ยท inherits BaseForecaster
The RandomWalkWithDrift class implements statsforecast's random walk with drift forecasting model. A variation of the naive method that allows forecasts to change over time by extrapolating a linear trend between the first and last observations. This JAX implementation provides complete compatibility with statsforecast's RandomWalkWithDrift class.
__init__(self, alias: str = 'RWD', conformal_params: ConformalIntervals | None = None)
Initializes the RandomWalkWithDrift model.
| Parameter | Type | Default | Description |
|---|---|---|---|
alias |
str |
"RWD" |
(undocumented) |
conformal_params |
ConformalIntervals | None |
None |
(undocumented) |
fit(self, y: jnp.ndarray, X: jnp.ndarray | None = None) -> Self
Fit the RandomWalkWithDrift model.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | Clean time series of shape (t,) |
X |
jnp.ndarray | None |
None |
Optional exogenous variables (not used, for API compatibility) |
Returns: Self (the fitted forecaster; sets self.model_).
predict(self, h: int, level: list[int] | None = None) -> dict
Predict with fitted RandomWalkWithDrift.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | Forecast horizon |
level |
list[int] | None |
None |
Confidence levels (0-100) for prediction intervals |
Returns: dict (Dictionary with entries mean for point predictions and level_* for probabilistic predictions).
Keys include {"mean": jnp.ndarray}. If level is provided, keys also include lo-L and hi-L for each level L.
predict_in_sample(self, level: list[int] | None = None) -> dict
Access fitted RandomWalkWithDrift insample predictions.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
level |
list[int] | None |
None |
Confidence levels (0-100) for prediction intervals |
Returns: dict (Dictionary with entries fitted for point predictions).
Keys include {"fitted": jnp.ndarray}. If level is provided, keys also include fitted-lo-L and fitted-hi-L for each level L.
forecast(self, h: int, y: jnp.ndarray, X: jnp.ndarray | None = None, X_future: jnp.ndarray | None = None, level: list[int] | None = None, fitted: bool = False) -> dict
Memory Efficient RandomWalkWithDrift predictions.
This method avoids memory burden due from object storage. It is analogous to fit_predict without storing information. It assumes you know the forecast horizon in advance.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | Forecast horizon |
y |
jnp.ndarray |
- | Clean time series of shape (n,) |
X |
jnp.ndarray | None |
None |
Optional insample exogenous of shape (t, n_x) (not used, for API compatibility) |
X_future |
jnp.ndarray | None |
None |
Optional exogenous of shape (h, n_x) (not used, for API compatibility) |
level |
list[int] | None |
None |
Confidence levels (0-100) for prediction intervals |
fitted |
bool |
False |
Whether or not to return insample predictions |
Returns: dict (Dictionary with entries mean for point predictions and level_* for probabilistic predictions).
Keys include {"mean": jnp.ndarray}. If fitted=True, includes "fitted". If level is provided, includes interval keys (lo-L, hi-L, and optionally fitted-lo-L, fitted-hi-L).