Title

tvpreg —— Parameter path estimation in unstable environments

Syntax

tvpreg varlist_dep varlist1
(varlist2 =
varlist_iv)
[if] [in] [, options]

varlist_dep denotes the list of dependent variables.

varlist1 denotes the list of exogenous variables.

varlist2 denotes the list of endogenous variables.

varlist_iv denotes the list of exogenous variables used with varlist1 as instruments for varlist2.

Estimator
ols ordinary least squares (OLS); the default when no insturment is specified.

newey applies Newey-West HAC estimation to the long-run variance of scores.

2sls two-stage least squares (2SLS); the default when instruments are specified.

gmm generalized method of moments (GMM).

weakiv indicates the weak-instrument environment and use OLS for the reduced-from regression.

var indicates the vector autoregressive (VAR) environment.

Model
cmatrix(matname) specifies the C grid for c(i).
This option controls the magnitude of time variation allowed in the parameters: larger c(i) values allow for larger magnitude of time variation.
The default is a scalar c(i) with the C grid 0:5:50.
We allow c(i) to be either a scalar or a vector: a vector c(i) allows different magnitudes of time-variation in different subsets of the parameters.
When c(i) is a scalar, C is a row vector;
when c(i) is a vector, C is a matrix whose number of rows should equal the number of
parameters, q.
Note that an excessively large value of c(i) may cause the calculation to exceed the maximum representable value in precision, in which case the intermediate step of weight computation returns Inf, which ultimately leads to a quasi-posterior value of NaN.

nhorizon(numlist) specifies the number list of horizons in the local projection or the vector autoregressive model.
The default is nhorizon(0).

lplagged specifies that in the TVP-LP or TVP-LP-IV models, the endogenous variables are lagged and held at their current-period value across horizons, while the dependent variable is the h-step-ahead future value.
This option only applies when the estimator option is 2sls, gmm, or weakiv.

cumulative indicates that the dependent variables and endogenous variables are cumulated over horizons.
If the lplagged option is specified, then the endogenous variables are not cumulated.

slope imposes that only the slope parameters are time-varying.

cholesky indicates that the logarithm of the standard deviation is considered in the parameter path for univariate regressions,
or that the triangular reduction of the covariance matrix is implemented for multivariate regressions.

nwlag(#) specifies the number of lags to calculate the long run variance Vhat of the scores.
The default is nwlag(0) for estimator option being ols or var,
and nwlag(T^(1/3)) for other estimator options,
where T is the total sample size.
For instance, if no estimator option is set and nwlag(8) is specified, ols will be used to obtain the constant parameter estimate for evaluating scores and Hessians, with 8 lags applied to calculate the long-run variance of the scores.

noconstant suppresses the constant term.

ny(#) specifies the number of dependent variables.
The default is ny(1).
This option does not apply when the estimator option is var

varlag(numlist) specifies the number of lags in the vector autoregressive model.
The default is varlag(1).
This option only applies when the estimator option is var.

ndraw(#) specifies the number of draws used to simulate the confidence band in the precense of weak instruments
or for the impulse responses computed by iterating the VAR.
The default is ndraw(1000).
This option only applies when the estimator option is weakiv or var.
To fix the estimation results, use set seed. For example, set seed 1234.

Reporting
getband generates the confidence bands.

level(clevel) sets the confidence level.
The default is level(95).

nodisplay suppresses the text output.

Plotting
plotcoef(namelist) specifies the parameter name (list) to be plotted.
The parameter name is stored in e(coefname).
To plot the slope parameters, namelist is specified by "yvar1:xvar1 yvar2:xvar2 ..." and locates the parameter to be plotted.
These parameters correspond to the coefficients of the variables xvar# in the equations for yvar#.
To plot the covariance matrix parameters when cholesky is specified,
namelist is
specified by "aij ... li ...",
where aij denotes the i-th row and j-th column element in A(t),
li denotes the i-th element in lnσ(t);
A(t)Σ(e,t)A(t)' = Σ(ε,t)Σ(ε,t)'; σ(t)=diag(Σ(ε,t));
A(t) is a lower-triangular matrix with ones on the main diagonal;
Σ(e,t) is the covariance matrix; and i > j.
To plot the convariance matrix parameters when cholesky is not specified,
namelist is specified by "vij ...",
where vij denotes the i-th row and j-th column element in the covariance matrix Σ(e,t),
and i ≥ j.

plotvarirf(namelist) specifies the parameter name (list) of the time-varying parameter vector autoregression impulse responses to be plotted.
The parameter name is stored in e(varirfname).
namelist is specified as "var1:shock1 var2:shock2 ..." and locates the impulse response to be plotted,
where var (shock) is the variable (shock) of interest.
This option only applies when the estimator option is var.
plotcoef(namelist) and plotvarirf(namelist) cannot be specified together.

plotnhorizon(numlist) specifies the number (list) of horizons to be plotted.
This list must be a subset of the number list in nhorizon(numlist).
The command plots the parameter path over time (horizons)
when plotnhorizon(numlist) specifies a single number (or a list of numbers).
The default is the list specified by nhorizon(numlist).

plotconst includes the constant parameter estimate (a line in the graph).
This option does not apply when the estimator option is weakiv.

period(varname) specifies the dummy variable indicating the time points to be highlighted in the plots.
when plotnhorizon(numlist) specifies a list of numbers, this option indicates the specific time points to be plotted in the parameter paths across horizons.
When plotnhorizon(numlist) specifies a single number, this option adds a background shade in the graph at the selected time points of the parameter path.

movavg(#) specifies the degree of the moving average when ploting a (smoothed) parameter path.
The default is movavg(1).

noci suppresses the confidence band in the figures.
The confidence band is only computed and stored when getband is specified.

title(tinfo) specifies the graph title.
The default is the parameter name.

ytitle(axis_title) specifies y-axis title.
The default is "Parameter."

xtitle(axis_title) specifies x-axis title
The default is "Time" ("Horizons") for parameter path across time (horizons).

tvplegend(string) specifies the legend for the time-varying-parameter estimate.
The default is "Time-varying parameter."

constlegend(string) specifies the legend for the constant-parameter estimate.
The default is "Constant parameter."
This option may be specified only when plotconst is specified.

bandlegend(string) specifies the legend name for the confidence band.
The default is "95% confidence band."
This option may be specified only when getband is specified and noci is not specified.

shadelegend(string) specifies the legend for the background shade.
The default is the variable name specified by period(varname).
This option may be specified only when period(varname) is specified and a single number is specified by plotnhorizon(numlist).

periodlegend(namelist) specifies the legend for the time-varying estimates in different time periods;
namelist is specified by "periodname1,periodname2,...", where the order of names should match the increasing order of time periods.
If this option is not specified, all the time-varying estimates have the same legend specified by tvplegend(string).
This option may be specified only when a list of numbers is specified by plotnhorizon(numlist).

nolegend suppresses the legend.
The legend is displayed only when more than two of the above elements are plotted in the figure.

scheme(schemename) specifies the overall look of the graph.
The default is controled by set scheme.

tvpcolor(colorstyle) specifies the color of the time-varying-parameter estimate.
The default is tvpcolor(green).

constcolor(colorstyle) specifies the color of the constant-parameter estimate.
The default is constcolor(black).

name(name_option) specifies the graph name.
The default is "tvpreg."

estimator specifies the estimation method for the constant parameter estimate which is used to evaluate the scores and Hessians.
The command allows to specify at most one estimator.

. ols or newey estimates the linear regression or local projection.
The syntax is analogous to Stata command regress and newey:
tvpreg varlist_dep varlist1
[if] [in] [, ols/newey options]

. 2sls, gmm and weakiv are designed for instrument variable estimation.
The syntax is analogous to Stata command ivreg2:
tvpreg varlist_dep [varlist1]
(varlist2 =
varlist_iv)
[if] [in] [, 2sls/gmm/weakiv options]

. var estimates vector autoregregressive models.
The syntax is analogous to Stata command var
tvpreg varlist_dep
[if] [in] [, var options]

Description

tvpreg facilitates practitioners to estimate and visualize the parameter path and impulse response functions in unstable environments.
Estimation results are stored in e() form.
Postestimation commands are provided to store and visualize the estimation results.

Postestimation commands

The following postestimation commands are available after tvpreg.

Command Description

predict obtains fitted values, residuals, time-varying coefficients and impulse responses

tvpplot visualizes the time-varying coefficients and impulse responses

The syntaxes for predict and tvpplot are listed as follows:

predict newvarlist
[, xb residual y(varlist) h(#) coef(namelist) coefub(namelist) coeflb(namelist) varirf(namelist) varirfub(namelist) varirflb(namelist)]

Detailed description of the above options is in predict.

tvpplot [, plotcoef(namelist) plotvarirf(namelist) horizon(numlist) plotconst period(varname) movavg(#)
noci title(tinfo) ytitle(axis_title) xtitle(axis_title) name(name_option)
tvplegend(string) constlegend(string) bandlegend(string) shadelegend(string) periodlegend(namelist) scheme(schemename) tvpcolor(colorstyle) constcolor(colorstyle) nolegend]

The options for tvpplot are the same as tvpreg. plotcoef(namelist) or plotvarirf(namelist) should be specified to locate the parameter.

Examples

Please refer to Inoue et al. (2024) for detailed examples.
Table 1 therein provides a summary of commonly used specifications and their corresponding commands to assist users in selecting the appropriate options.
Table 2 provides a summary of the impelmentation examples, including TVP-VAR, TVP-LP, TVP-LP-IV, and TVP-weak IV.

Stored results

tvpreg stores the following in e():

Scalars

e(T) sample size

e(q) number of time varying parameters

e(level) confidence level

Macros

e(title) Time-Varying-Parameter Estimation

e(cmd) tvpreg

e(cmdline) command as typed

e(model) estimator type

e(coefname) parameter name of the model

e(varirfname) parameter name of the TVP-VAR impulse response functions

e(horizon) number (list) of horizons

e(cumulative) "yes" if the variables are cumulated; "no" otherwise

e(lplagged) "yes" if endogenous variables do not vary across horizons; "no" otherwise

e(timevar) name of time variable

e(depvar) name of dependent variable

e(indepvar) name of independent variables

e(instd) name of instrumented variables

e(insts) name of instruments

e(inexog) name of included instruments

e(exexog) name of excluded instruments

e(varlags) number list of lags in TVP-VAR

e(maxl) maximum lag in TVP-VAR

e(constant) "yes" if constant is included; "no" otherwise

e(band) "yes" if confidence band is obtained; "no" otherwise

e(cholesky) "yes" if triangular reduction of the coveriance matrix is implemented; "no" otherwise

Matrices

e(c) input C grid matrix

e(qLL) qLL test statistic if a default C grid is specified by cmatrix(matname)

e(weight) weights associated with the path for each c(i) in C grid

e(coef_const) constant parameter estimate

e(coef) parameter path

e(coef_lb) lower bound of the parameter path

e(coef_ub) upper bound of the parameter path

e(Omega) covariance matrix of the parameter path

e(varirf_const) constant parameter estimate of VAR impulse response function

e(varirf) TVP-VAR impulse response function path

e(varirf_lb) lower bound of the TVP-VAR impulse response function path

e(varirf_ub) upper bound of the TVP-VAR impulse response function path

e(residual) residuals

Functions

e(sample) marks estimation sample

References

Inoue, A., Rossi, B., Wang, Y., and Zhou, L., 2024. "Parameter path estimation in unstable environments: the tvpreg command." Working Paper.

Compatibility and known issues

Please ensure the following information before running the tvpreg program:

. The programs are written in version 17.0.

. Time-series structure is declared: tsset timevar.

. The time-series should be consecutive with no missing values.

. The tvpreg and tvpplot commands use the bgshade package to add background shading in the parameter path.
It can be found and installed in Stata by typing -ssc install bgshade- in the command window.

Author

Atsushi INOUE

Department of Economics, Vanderbilt University.

Barbara ROSSI

ICREA-Universitat Pompeu Fabra, EUI, Barcelona School of Economics, and CREI.

Yiru WANG

Department of Economics, University of Pittsburgh.

Lingyun ZHOU

PBC School of Finance, Tsinghua University.