*! version 1.0.0 05Jun2026

Title

xtpraisk -- Prais-Winsten regression with AR(k) errors and
panel-corrected standard errors

Syntax

xtpraisk
depvar
[indepvars]
[if] [in]
, lag(#) [options]

Model
* lag(#) set AR lag order

noconstant suppress constant term

np1 weight panel autocorrelations by T_i instead of T_i-1

SE
nmk normalize standard errors by N-k instead of N

Reporting
level(#) set confidence level; default is level(95)

coeflegend display legend instead of statistics

nolog suppress the iteration log

Convergence
tolerance(#) convergence tolerance; default is
tolerance(1e-6)

iterate(#) maximum iterations; default is
iterate(250)

* lag() is required.

A panel variable and a time variable must be specified; use
xtset; see [XT] xtset.

indepvars may contain factor variables; see fvvarlist.

depvar and indepvars may contain time-series operators; see
tsvarlist.

Postestimation syntax

The following predict options are available after xtpraisk:

predict newvar [if] [in] [, statistic]

statistic

xb linear prediction; the default

residuals OLS residuals

ue AR(k) innovation residuals

stdp standard error of the linear prediction

xb and stdp are available both in and out of sample.
residuals and ue are calculated only where the dependent variable
is non-missing. The ue option requires panel data declared with
xtset and sets predictions to missing for the first k
observations of each panel.

Description

xtpraisk calculates Prais-Winsten regression with AR(k) errors and panel-corrected standard errors, thereby extending
Stata's xtpcse command to higher-order autoregressive errors. As with xtpcse, xtpraisk
assumes that the disturbances are, by default, heteroskedastic and contemporaneously correlated across panels.

Typing xtpraisk without arguments replays the last estimation results.

Options

Model

lag(#) specifies the order of the autoregressive process for the
errors; lag() is required and must be >= 1.

noconstant suppresses the constant term from the model.

np1 specifies that panel-specific autocorrelations be weighted by T_i
rather than the default T_i - 1 when estimating the common rho. This option
has an effect only when panels are unbalanced; see xtpcse.

SE

nmk specifies that standard errors be normalized by N-k rather than
the default N. Different authors use one or the other normalization;
see xtpcse.

Note: xtpraisk always reports panel-corrected standard errors (PCSEs).
PCSEs jointly account for panel heteroscedasticity and contemporaneous
cross-panel correlation (Beck and Katz 1995), subsuming the corrections
provided by vce(robust) or vce(cluster).

Reporting

level(#) specifies the confidence level as a percentage for confidence
intervals. The default is level(95) or as set by set level.

coeflegend; see [R] Estimation options.

nolog suppresses the iteration log that reports the value of rho (for
AR(1)) or the maximum modulus of the companion matrix eigenvalues (for
AR(k > 1)) at each iteration.

Convergence

tolerance(#) specifies the convergence criterion. Iteration stops when
the maximum absolute change in any AR parameter across successive iterations
is less than #. The default is tolerance(1e-6).

iterate(#) specifies the maximum number of iterations allowed before
an error is returned. The default is iterate(250).

Examples

1) AR(1) estimation matching xtpcse

Setup

. webuse grunfeld

. xtset company year, yearly

Estimate with common AR(1) errors and PCSEs

. xtpraisk invest mvalue kstock, lag(1)

Compare with xtpcse

. xtpcse invest mvalue kstock, correlation(ar1)

Replay results with 99% confidence intervals

. xtpraisk, level(99)

2) Higher-order AR errors

Setup

. webuse grunfeld

. xtset company year, yearly

Estimate with AR(2) errors

. xtpraisk invest mvalue kstock, lag(2)

Estimate with AR(3) errors

. xtpraisk invest mvalue kstock, lag(3)

3) Post-estimation diagnostics

Setup

. webuse grunfeld

. xtset company year, yearly

. xtpraisk invest mvalue kstock, lag(2)

Obtain fitted values and residuals

. predict yhat, xb

. predict uhat, residuals

Obtain AR innovation residuals and inspect for a single panel

. predict ue, ue

. ac ue if company == 1

Note: ac and wntestq do not support multiple panels.
Inspect the autocorrelation function for individual panels or rely on the
autocorrelation table displayed by xtpraisk.

4) Unbalanced panels and the np1 option

. xtpraisk invest mvalue kstock, lag(1) np1

With balanced panels np1 has no effect; with unbalanced panels
it weights panel-specific rho estimates by T_i rather than T_i - 1,
matching xtpcse's np1 option.

Stored results

xtpraisk stores the following in e():

Scalars

e(N) number of observations

e(rank) rank of variance-covariance matrix

e(df_m) model degrees of freedom

e(chi2) Wald chi2 statistic

e(p) p-value for Wald test

e(r2) R-squared (computed on GLS-transformed data)

e(r2_a) adjusted R-squared

e(rmse) root mean squared error

e(mss) model sum of squares (transformed)

e(rss) residual sum of squares (transformed)

e(ll) exact log likelihood

e(level) confidence level

e(iterations) number of iterations to convergence

e(tolerance) convergence tolerance used

e(ngaps) number of gaps (panel changes + time gaps)

e(N_g) number of panels

e(g_min) smallest group size

e(g_avg) average group size

e(g_max) largest group size

e(p_lag) AR lag order

e(ac_ols1), e(ac_ols2), ... autocorrelation of OLS residuals at lag k

e(ac_ue1), e(ac_ue2), ... autocorrelation of AR innovation residuals at lag k

Macros

e(cmd) xtpraisk

e(cmdline) command as typed

e(title) title in estimation output

e(depvar) name of dependent variable

e(ivar) name of panel variable

e(tvar) name of time variable

e(panelvar) name of panel variable

e(timevar) name of time variable

e(balance) balanced or unbalanced

e(vcetype) Panel-corrected

e(noconstant) noconstant, if specified

e(predict) program used to implement predict

Matrices

e(b) coefficient vector

e(V) variance-covariance matrix of the estimator

e(rho) AR parameter estimates (1 x k)

e(serho) standard errors of AR parameter estimates (1 x k)

Functions

e(sample) marks estimation sample

In addition, r(table) is stored in r() and contains the
coefficient matrix with standard errors, test statistics, p-values, and
confidence intervals. Results stored in r() are updated when the
command is replayed and will be replaced when any r-class command is run
after the estimation command.

References

Beck, N. L., and J. N. Katz. 1995. What to do (and not to do) with
time-series cross-section data. American Political Science Review
89: 634-647.

Galbraith, R. F., and J. I. Galbraith. 1974. On the inverses of some
patterned matrices arising in the theory of stationary time series.
Journal of Applied Probability 11(1): 63-71.

Hamilton, J. D. 1994. Time Series Analysis. Princeton University Press.

Linden, A. 2026. Adjustment for autocorrelation in multiple-group
(controlled) interrupted time series analysis and its effect on power:
A simulation study of the Newey-West and Prais-Winsten methods.
https://doi.org/10.21203/rs.3.rs-8865851/v1

Linden, A. 2026. Multiple-group (controlled) interrupted time series
analysis with higher-order autoregressive errors: A simulation study
comparing Newey-West and Prais-Winsten methods.
https://arxiv.org/abs/2603.24814

Linden, A. 2026. Extending Prais–Winsten regression to panel data
with higher-order autoregressive errors: A simulation study.
https://arxiv.org/html/2606.12596v1

Vougas, D. V. 2021. Prais-Winsten algorithm for regression with second
or higher order autoregressive errors. Econometrics 9(3): 32.

Citation of xtpraisk

xtpraisk is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Linden A. 2026. XTPRAISK: Stata module for computing Prais-Winsten regression with AR(k) errors and
panel-corrected standard errors.
Statistical Software Components S459735, Boston College Department of Economics.

Author

Ariel Linden

Linden Consulting Group, LLC

alinden@lindenconsulting.org

Acknowledgements

I am grateful to Dimitrios V. Vougas for graciously providing the MATLAB
code that served as the basis for the praisk command, on which
xtpraisk is built.

Also see

Manual: [TS] prais, [XT] xtpcse

Online: xtpcse, prais, regress, newey, ac,
praisk (if installed)