RandomWalkWithDrift
chronax.models.randomWalkWithDrift.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.
Attributes
| Name | Type | Description |
|---|---|---|
alias |
str |
Alias for the model, defaults to "RWD". |
conformal_params |
ConformalIntervals \| None |
Parameters for conformal prediction, if used. |
model_ |
dict |
Dict containing fitted parameters (slope, last_y, sigma, fitted values, n). |
__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.
| 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.
| 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).
predict_in_sample(self, level: list[int] | None = None) -> dict
Access fitted RandomWalkWithDrift insample predictions.
| 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).
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.
| 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).