View source: R/diagnostics_sim.R
| durbin_watson | R Documentation |
Tests first-order autocorrelation in temporally-ordered residuals.
durbin_watson(
object,
alternative = c("two.sided", "greater", "less"),
time = NULL,
resid_type = "pearson"
)
object |
A fitted model, or a numeric vector of temporally-ordered
residuals. A fit's residuals are in its data's row order, so pass |
alternative |
|
time |
Optional time index, one per residual; the residuals are put in
increasing |
resid_type |
Residual type if extracting from a model (default
|
An htest object with DW statistic, lag-1 r, and p-value
set.seed(1)
e <- as.numeric(arima.sim(list(ar = 0.6), n = 100))
durbin_watson(e)
# Residuals recorded out of time order:
tt <- sample(100)
durbin_watson(e[tt], time = tt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.