The Prais-Winsten estimator takes into account AR(1) serial correlation of the errors in a linear regression model. The procedure recursively estimates the coefficients and the error autocorrelation of the specified model until sufficient convergence of the AR(1) coefficient is reached. All estimates are obtained by OLS.
prais_winsten(
formula,
data,
index,
max_iter = 50L,
tol = 1e-06,
twostep = FALSE,
panelwise = FALSE,
rhoweight = c("none", "T", "T1"),
...
)# S3 method for prais
print(x, digits = max(3L, getOption("digits") - 3L), ...)
A list of class "prais"
containing the following components:
a named vector of coefficients.
the values of the AR(1) coefficient \(\rho\) from all iterations.
the residuals, that is the response minus the fitted values.
the fitted mean values.
the numeric rank of the fitted linear model.
the residual degrees of freedom.
the matched call.
the terms object used.
the original model frame, i.e., before the Prais-Winsten transformation.
a character specifying the ID and time variables.
an object of class "formula"
(or one that can be coerced to that class):
a symbolic description of the model to be fitted.
a data frame containing the variables in the model. If panel data is used, it must also contain the ID and time variables.
a character vector specifying the ID and time variables. If only one variable is provided, it is assumed to be the time variable and the data will be reordered accordingly.
integer specifying the maximum number of allowed iterations. Default is 50.
numeric specifying the maximum absolute difference between the estimator of \(rho\) in the current and the previous iteration that has to be attained to reach convergence. Default is 1e-6.
logical. If TRUE
, the estimation will stop after the first iteration.
logical. If TRUE
, \(\rho\) will be calculated for each panel separately.
Default is FALSE
. Only used for panel data. See 'Details'.
character specifying how \(\rho\) should be calculated if panelwise = TRUE
.
See 'Details'.
arguments passed to lm
.
an object of class "prais", usually, a result of a call to prais_winsten
.
the number of significant digits to use when printing.
If \(\rho\) takes a value above 1 during the estimation process, the Prais-Winsten transformation cannot be applied to the first observations, because \((1 - \rho^2)^{(1 / 2)}\) is not real. These observations are dropped during the respective iteration and the estimator effectively becomes the Cochrane-Orcutt estimator.
If panelwise = TRUE
, twostep = FALSE
and rhoweight = "none"
,
each individual estimate of \(rho\) is re-estimated until convergence is achieved for all coefficients.
If panelwise = TRUE
, the calculation of \(\rho\) can be further specified in argument
rhoweight
. If rhoweight = "none"
, \(\rho\) is assumed to be panel-specific. If
rhoweight = "T"
, \(\rho\) is calculated as a weighted mean of panel-specific estimates, where
the number of available observations per panel, i.e. \(T_i\), is used as weight. If rhoweight = "T1"
,
\(\rho\) is calculated as a weighted mean of panel-specific estimates, where the number of available
observations per panel minus one, i.e. \(T_i - 1\), is used as weight.
Beck, N. L. and Katz, J. N. (1995): What to do (and not to do) with time-series cross-section data. American Political Science Review 89, 634-647.
Prais, S. J. and Winsten, C. B. (1954): Trend Estimators and Serial Correlation. Cowles Commission Discussion Paper, 383 (Chicago).
Wooldridge, J. M. (2013): Introductory Econometrics. A Modern Approach. 5th ed. Mason, OH: South-Western Cengage Learning Cengage.
# 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")
summary(pw)
Run the code above in your browser using DataLab