| rw_model | R Documentation |
Fit a generalized random walk with Gaussian errors (and optional drift) to a univariate time series.
rw_model(y, lag = 1, drift = FALSE, lambda = NULL, biasadj = FALSE)
y |
a numeric vector or univariate time series of class |
lag |
Lag parameter. |
drift |
Logical flag. If |
lambda |
Box-Cox transformation parameter. If |
biasadj |
Use adjusted back-transformed mean for Box-Cox
transformations. If transformed data is used to produce forecasts and fitted
values, a regular back transformation will result in median forecasts. If
biasadj is |
The model assumes that
Y_t = Y_{t-p} + c + \varepsilon_{t}
where p is the lag parameter,
c is the drift parameter, and
\varepsilon_t\sim N(0,\sigma^2) are iid.
The model without drift has c=0.
In the model with drift, c is estimated
by the sample mean of the differences Y_t - Y_{t-p}.
If p=1, this is equivalent to an ARIMA(0,1,0) model with
an optional drift coefficient. For p>1, it is equivalent to an
ARIMA(0,0,0)(0,1,0)p model.
The forecasts are given by
Y_{T+h|T}= Y_{T+h-p(k+1)} + ch
where k is the integer part of (h-1)/p.
For a regular random walk, p=1 and c=0, so all forecasts are equal to the last observation.
Forecast standard errors allow for uncertainty in estimating the drift parameter
(unlike the corresponding forecasts obtained by fitting an ARIMA model
directly).
The generic accessor functions stats::fitted() and stats::residuals()
extract useful features of the object returned.
An object of class rw_model.
forecast.rw_model(), rwf(), naive(), snaive()
model <- rw_model(gold)
forecast(model, h = 50) |> autoplot()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.