| Encoding: | UTF-8 | 
| Type: | Package | 
| Title: | Prais-Winsten Estimator for AR(1) Serial Correlation | 
| Version: | 1.1.4 | 
| Description: | The Prais-Winsten estimator (Prais & Winsten, 1954) 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 attained. | 
| License: | GPL-2 | 
| Depends: | R (≥ 3.2.0), sandwich, pcse | 
| Imports: | stats | 
| RoxygenNote: | 7.3.2 | 
| URL: | https://github.com/franzmohr/prais | 
| BugReports: | https://github.com/franzmohr/prais/issues | 
| Collate: | 'data.R' 'prais-package.R' 'prais_winsten.R' 'predict.prais.R' 'print.prais.R' 'summary.prais.R' 'print.summary.prais.R' 'pw_transform.R' 'vcovHC.R' 'vcovPC.R' | 
| LazyData: | true | 
| NeedsCompilation: | no | 
| Packaged: | 2025-06-25 20:34:01 UTC; fxm-acer | 
| Author: | Franz X. Mohr | 
| Maintainer: | Franz X. Mohr <franz.x.mohr@outlook.com> | 
| Repository: | CRAN | 
| Date/Publication: | 2025-06-25 20:50:02 UTC | 
prais: Prais-Winsten Estimator for AR(1) Serial Correlation
Description
The Prais-Winsten estimator (Prais & Winsten, 1954) 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 attained.
Author(s)
Maintainer: Franz X. Mohr franz.x.mohr@outlook.com (ORCID)
See Also
Useful links:
Barium
Description
Monthly microeconomic data from the U.S. chemical industry from February 1978 to December 1988 as used in Krupp and Pollard (1996) and subsequently re-used by Wooldridge (2000) as a textbook dataset. Raw data was obtained from http://fmwww.bc.edu/ec-p/data/wooldridge/barium.dta.
Usage
data("barium")
Format
A data frame with 131 rows and 31 variables:
- chnimp
- Chinese imports, bar. chl. 
- bchlimp
- Total imports, bar. chl. 
- befile6
- Dummy varialbe, which is 1 for all six months before filing. 
- affile6
- Dummy varialbe, which is 1 for all six months after filing. 
- afdec6
- Dummy varialbe, which is 1 for all six months after decision 
- befile12
- Dummy varialbe, which is 1 for all twelve months before filing. 
- affile12
- Dummy varialbe, which is 1 for all twelve months after filing. 
- afdec12
- Dummy varialbe, which is 1 for all twelve months after decision. 
- chempi
- Chemical production index. 
- gas
- Gasoline production. 
- rtwex
- Exchange rate index. 
- spr
- Dummy varialbe, which is 1 for spring months. 
- sum
- Dummy varialbe, which is 1 for summer months. 
- fall
- Dummy varialbe, which is 1 for fall months. 
- lchnimp
- Log of chnimp. 
- lgas
- Log of gas. 
- lrtwex
- Log of rtwex. 
- lchempi
- Log of chempi. 
- t
- Time trend. 
- feb
- Dummy varialbe for February. 
- mar
- Dummy varialbe for March. 
- apr
- Dummy varialbe for April. 
- may
- Dummy varialbe for May. 
- jun
- Dummy varialbe for June. 
- jul
- Dummy varialbe for July. 
- aug
- Dummy varialbe for August. 
- sep
- Dummy varialbe for September. 
- oct
- Dummy varialbe for October. 
- nov
- Dummy varialbe for November. 
- dec
- Dummy varialbe for December. 
- percchn
- Percent of imports from China. 
References
Krupp, C.M., & Pollard, P.S., (1996). Market responses to antidumpting laws: Some evidence from the U.S. chemical industry. Canadian Journal of Economics 29(1), 199–227. doi:10.2307/136159
Wooldridge, J., (2000). Instructional Stata datasets for econometrics. [barium]. Boston College Department of Economics.
Prais-Winsten Estimator for AR(1) Serial Correlation
Description
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.
Predicted values based on Prais-Winsten object.
Usage
prais_winsten(
  formula,
  data,
  index,
  max_iter = 50L,
  tol = 1e-06,
  twostep = FALSE,
  panelwise = FALSE,
  rhoweight = c("none", "T", "T1"),
  ...
)
## S3 method for class 'prais'
predict(object, ..., newdata = NULL)
## S3 method for class 'prais'
print(x, digits = max(3L, getOption("digits") - 3L), ...)
Arguments
| formula | an object of class  | 
| data | a data frame containing the variables in the model. If panel data is used, it must also contain the ID and time variables. | 
| index | 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. | 
| max_iter | integer specifying the maximum number of allowed iterations. Default is 50. | 
| tol | numeric specifying the maximum absolute difference between the estimator of  | 
| twostep | logical. If  | 
| panelwise | logical. If  | 
| rhoweight | character specifying how  | 
| ... | further arguments passed to or from other methods. | 
| object | an object of class  | 
| newdata | an optional data frame in which to look for variables with with to predict. If omitted, fitted values are used. | 
| x | an object of class "prais", usually, a result of a call to  | 
| digits | the number of significant digits to use when printing. | 
Details
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.
Value
A list of class "prais" containing the following components:
| coefficients | a named vector of coefficients. | 
| rho | the values of the AR(1) coefficient  | 
| residuals | the residuals, that is the response minus the fitted values. | 
| fitted.values | the fitted mean values. | 
| rank | the numeric rank of the fitted linear model. | 
| df.residual | the residual degrees of freedom. | 
| call | the matched call. | 
| terms | the terms object used. | 
| model | the original model frame, i.e., before the Prais-Winsten transformation. | 
| index | a character specifying the ID and time variables. | 
A vector of or predictions.
References
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.
Prais, S. J. and Winsten, C. B. (1954): Trend Estimators and Serial Correlation. Cowles Commission Discussion Paper, 383 (Chicago).
Examples
# 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)
# 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)
Summarising the Prais-Winsten Estimator
Description
Summary method for class "prais".
Usage
## S3 method for class 'prais'
summary(object, ...)
## S3 method for class 'summary.prais'
print(
  x,
  digits = max(3L, getOption("digits") - 3L),
  signif.stars = getOption("show.signif.stars"),
  ...
)
Arguments
| object | an object of class  | 
| ... | further arguments passed to or from other methods. | 
| x | an object of class  | 
| digits | the number of significant digits to use when printing. | 
| signif.stars | logical. If  | 
Value
summary.prais returns a list of class "summary.prais",
which contains the following components:
| call | the matched call. | 
| residuals | the residuals, that is the response minus the fitted values. | 
| coefficients | a named vector of coefficients. | 
| rho | the values of the AR(1) coefficient  | 
| sigma | the square root of the estimated variance of the random error. | 
| df | degrees of freedom, a 3-vector (p, n-p, p*), the first being the number of non-aliased coefficients, the last being the total number of coefficients. | 
| r.squared | R^2, the 'fraction of variance explained by the model', 
 where  | 
| adj.r.squared | the above R^2 statistic 'adjusted', penalising for higher p. | 
| fstatistic | (for models including non-intercept terms) a 3-vector with the value of the F-statistic with its numerator and denominator degrees of freedom. | 
| cov.unscaled | a  | 
| dw | a named 2-vector with the Durbin-Watson statistic of the original linear model and the Prais-Winsten estimator. | 
| index | a character specifying the ID and time variables. | 
Semirobust Covariance Matrix Estimators
Description
Semirobust covariance matrix estimators for models of class "prais".
Usage
## S3 method for class 'prais'
vcovHC(x, type = c("const", "HC1", "HC0"), ...)
Arguments
| x | an object of class  | 
| type | a character string specifying the estimation type. | 
| ... | not used. | 
Details
vcovHC is a function for estimating a robust covariance matrix of parameters for
the Prais-Winsten estimator. The weighting schemes specified by type are analogous to those in
vcovHC in package sandwich
with the caveat that only "const", "HC0" and "HC1" are available.
Value
An object of class "matrix" containing the estimate of the asymptotic covariance matrix of coefficients.
See Also
Extract Panel-Corrected Variance Covariance Matrix
Description
Panel-corrected covariance matrix estimators for models of class "prais".
Usage
## S3 method for class 'prais'
vcovPC(x, pairwise = FALSE, ...)
Arguments
| x | an object of class  | 
| pairwise | logical. If  | 
| ... | not used. | 
Details
vcovPC is a function for estimating a panel-corrected covariance matrix of parameters for
the Prais-Winsten estimator.
Value
An object of class "matrix".
References
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.