View source: R/predict.prais.R
| predict.prais | R Documentation |
Predicted values based on Prais-Winsten object.
## S3 method for class 'prais'
predict(object, newdata = NULL, ...)
object |
an object of class |
newdata |
an optional data frame in which to look for variables with which to
predict. It must contain the variables that appear in |
... |
further arguments passed to or from other methods. |
The predictions are the conditional mean of the model, i.e. the product of the regressors and the coefficients. The AR(1) structure of the errors is not used, so the result does not contain the forecast of the serially correlated part of the error term.
A vector of predictions.
Prais, S. J. and Winsten, C. B. (1954): Trend Estimators and Serial Correlation. Cowles Commission Discussion Paper, 383 (Chicago).
# Generate an artificial sample
set.seed(1234567)
n <- 100
x <- sample(20:40, n, replace = TRUE)
rho <- .5
# AR(1) errors
u <- rnorm(n, 0, 5)
for (i in 2:n) {
u[i] <- u[i] + rho * u[i - 1]
}
pw_sample <- data.frame("x" = x, "y" = 10 + 1.5 * x + u, "time" = 1:n)
# Estimate
pw <- prais_winsten(y ~ x, data = pw_sample, index = "time")
# Predict
fcst <- predict(pw)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.