*! version 1.0.0 // A METTRE
help xtfixedcoeftvcu

Title

Performs Estimations of Panel Data Models with Coefficients that Vary over Time and Cross-sectional Units

Syntax

xtfixedcoeftvcu
depvar
indepvars
[if] [in]
[, options]

forcereg this option explicitly balances the panel data before the estimation

maxnbiter(#) perform maximum of # iterations; default is maxnbiter(500000)

ptoler(#) tolerance for the coefficient vector; default is ptoler(1e-5)

vtoler(#) tolerance for the Residual Sum of Squares; default is vtoler(1e-5)

nrtoler(#) tolerance for the scaled gradient; default is nrtoler(1e-5)

ignrtoler ignore the nrtoler() option

[no]displogs display an iteration log of the Residual Sum of Squares; typically, the default

difficult use a different stepping algorithm in nonconcave regions

technique(algorithm_spec) maximization technique

vce(robust) Huber/White/sandwich estimator

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

You must tsset your data before using xtfixedcoeftvcu; see tsset.

indepvars may contain time-series operators; see tsvarlist.

by is allowed with xtfixedcoeftvcu; see [D] by for more details on by.

Description

xtfixedcoeftvcu performs estimations of panel data models with coefficients that vary over time and
cross-sectional units. This command allows estimation of: firstly coefficients that are common to all
cross-sectional units and time, secondly parameters that vary over cross-sectional units, and thirdly
coefficients that change over time. All three parameter groups previously cited are considered
fixed, hence the command xtfixedcoeftvcu estimates a fixed-effects model. It is specifically
called the Fixed-Coefficient Model or Fixed-Effects ANOVA Model. The theory behind the
command xtfixedcoeftvcu is provided by Hsiao (2014).

Econometric Model

The estimated econometric model can be written as:

y_it = sum_^(betabar_k + alpha_ki + lambda_kt) * x_kit + u_it (6.3.1)

where

i = 1,...,N and t = 1,...,T;

betabar_k specifies the coefficients that are constant;

alpha_ki indicates the coefficients that vary over cross-sectional units;

lambda_kt designates the coefficients that vary over Time;

y_it is the dependent variable;

x_kit are the regressors;

u_it is the error term;

the number (6.3.1) is the equation number in Hsiao (2014) for ease of reference, page 181;

Equation (6.3.1) can be written in matrix form as:

y = X * betabar + XTILDE * alpha + XINF * lambda + u (6.3.2)

where

betabar specifies the vector of coefficients that are constant. In the regression table, the vector betabar is named ConstantCoefs;

alpha indicates the vector of coefficients that vary over cross-sectional units. In the regression table, the vector alpha is named GroupSpecCoefs;

lambda designates the vector of coefficients that vary over Time. In the regression table, the vector lambda is named TimeSpecCoefs;

the number (6.3.2) is the equation number in Hsiao (2014) for ease of reference, page 181;

As mentioned previously, when betabar, alpha_k and lambda_k are treated as fixed, the model is a fixed-effects model. The model can then be seen
as a fixed-effects ANOVA model. Nevertheless, as mentioned by Hsiao (2014) (page 182), the matrix of regressors is of
dimension NT * (T + N + 1) K, but its rank is only (T + N - 1) K. Thus we need to impose 2K independent linear restrictions on the
coefficients alpha_k and lambda_k in order to estimate our model (see Hsiao (2014), page 182 for more details). The
command xtfixedcoeftvcu automatically includes these restrictions internally. You do not have to specify them.

Options

forcereg explicitly balances the panel data before the estimation. The command xtfixedcoeftvcu works
only on strongly balanced panel data. Hence if your data are not balanced, you should find a way to obtain a
balanced panel by choosing an appropriate econometric method or any technique that you find convenient
before employing the command; or else use this option to explicitly do it for you.

maxnbiter(#) specifies the maximum number of iterations. When the number of iterations equals
maxnbiter(), the optimizer stops and presents the current results. If convergence is declared
before this threshold is reached, it will stop when convergence is declared. Specifying maxnbiter(0)
is useful for viewing results evaluated at the initial value of the coefficient vector. The default value
of maxnbiter(#) is maxnbiter(500000).

ptoler(#) specifies the tolerance for the coefficient vector. When the relative change in the coefficient
vector from one iteration to the next is less than or equal to ptoler(), the ptoler() convergence
criterion is satisfied. ptoler(1e-5) is the default.

vtoler(#) specifies the tolerance for the Residual Sum of Squares (Residual SS). When the relative change
in the Residual SS from one iteration to the next is less than or equal to vtoler(), the vtoler()
convergence is satisfied. vtoler(1e-5) is the default.

nrtoler(#) specifies the tolerance for the scaled gradient. Convergence is declared
when g * invsym(-H) * g' < nrtoler(). The default is nrtoler(1e-5).

ignrtoler specifies that the default nrtoler() criterion be turned off.

displogs and nodisplogs specify whether an iteration log showing the progress of the Residual
Sum of Squares is to be displayed. The log is displayed by default, and nodisplogs suppresses it.

difficult specifies that the Residual Sum of Squares function is likely to be difficult to minimize because
of nonconcave regions. When the message "not concave" appears repeatedly, xtfixedcoeftvcu's standard
stepping algorithm may not be working well. difficult specifies that a different stepping algorithm be
used in nonconcave regions. There is no guarantee that difficult will work better than the default; sometimes
it is better and sometimes it is worse. You should use the difficult option only when the default stepper
declares convergence and the last iteration is "not concave" or when the default stepper is repeatedly
issuing "not concave" messages and producing only tiny improvements in the Residual Sum of Squares. Since we
are dealing with a minimization problem, think of the preceding discussion in terms of maximization of -f(p).

technique(algorithm_spec) specifies how the Residual Sum of Squares function is to be minimized. The following algorithms are allowed.
For details, see
Gould, Pitblado, and Poi (2010).

technique(nr) specifies Stata's modified Newton-Raphson (NR)
algorithm.

technique(bhhh) specifies the Berndt-Hall-Hall-Hausman (BHHH)
algorithm.

technique(dfp) specifies the Davidon-Fletcher-Powell (DFP)
algorithm.

technique(bfgs) specifies the Broyden-Fletcher-Goldfarb-Shanno
(BFGS) algorithm.

The default is technique(nr).

You can switch between algorithms by specifying more than one in the technique() option. By default, an
algorithm is used for five iterations before switching to the next algorithm. To specify a different number of
iterations, include the number after the technique in the option. For example, specifying technique(bhhh 10 nr 1000)
requests that xtfixedcoeftvcu perform 10 iterations with the BHHH algorithm followed by 1000 iterations with the
NR algorithm, and then switch back to BHHH for 10 iterations, and so on. The process continues until convergence or
until the maximum number of iterations is reached.

vce(robust) uses the robust or sandwich estimator of variance. This estimator is robust to some types of misspecification
so long as the observations are independent; see .

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

Syntax for predict

The syntax for predict after the command xtfixedcoeftvcu is:

predict [type] newvar [if] [in] [, Options_for_predict]

Options for predict

xball, the default, calculates the linear prediction from all the equations taken together. It
computes: X * betabar_hat + XTILDE * alpha_hat + XINF * lambda_hat.

xbeta, calculates the linear prediction from the ConstantCoefs equation only. It computes: X * betabar_hat.

xalpha, calculates the linear prediction from the GroupSpecCoefs equation only. It computes: XTILDE * alpha_hat.

xlambda, calculates the linear prediction from the TimeSpecCoefs equation only. It computes: XINF * lambda_hat.

fcresids, calculates the residuals from all the equations taken together. It
computes: u_hat = y - (X * betabar_hat + XTILDE * alpha_hat + XINF * lambda_hat).

Return values

The command xtfixedcoeftvcu stores the following in e():

Scalars

e(rank) Rank of e(V)

e(ic) Number of iterations

e(k) Number of parameters

e(k_eq) Number of equations in e(b)

e(k_dv) Number of dependent variables

e(converged) 1 if converged, 0 otherwise

e(rc) Return code

e(chi2) Chi-squared

e(chi2_p) P-value of the chi-squared statistic

e(N) Number of observations

e(T) Time used

e(N_g) Number of included individuals

e(g_avg) Average number of observations per included individual

e(g_min) Lowest number of observations in an included individual

e(g_max) Highest number of observations in an included individual

e(r2) R-squared

Macros

e(cmdline) Command as typed

e(cmd) Name of command

e(predict) Program used to implement predict

e(tvar) Name of time variable

e(ivar) Name of panel variable

e(effectvar) Effective times used for the calculation and the display of the coefficients

e(effecpvar) Effective panels used for the calculation and the display of the coefficients

e(xvars) Names of the regressors

e(depvar) Name of the dependent variable

e(opt) Type of optimization

e(vce) vcetype specified in vce()

e(user) Name of the evaluator program

e(ml_method) Type of moptimize() method

e(technique) From technique() option

e(which) max or min; whether optimizer is to perform maximization or minimization; minimization in our case

e(properties) Estimator properties

e(singularHmethod) m-marquardt or hybrid; method used when Hessian is singular; sometimes stored

Matrices

e(b) Coefficient vector

e(V) Variance-covariance matrix of the estimators

e(Cns) Constraints matrix

e(ilog) Iteration log (up to 20 iterations)

e(gradient) Gradient vector

Functions

e(sample) Marks estimation sample

Examples

Before beginning the estimations, we use the set more off instruction to tell
Stata not to pause when displaying the output.

set more off

We illustrate the use of the command xtfixedcoeftvcu with the Stata manual dataset invest2.

webuse invest2, clear

We regress the dependent variable (invest) on the regressors (market stock).

xtfixedcoeftvcu invest market stock

Next we display the Return Values of the previous regression. This will helps us in understanding the results.

ereturn list

As we explained in the section Return values, the macro e(effecpvar) contains the effective panels used for the
calculation and the display of the coefficients and the macro e(effectvar) contains the effective times used for the
calculation and the display of the coefficients. Next we display the content of both of these macros.

display e(effecpvar)

display e(effectvar)

Having done that, let us now turn to the explanation of the output of the previous estimation. The table of results is divided
into three parts: the first part shows the word ConstantCoefs which specifies the coefficients that are constant. It is
the betabar in equation (6.3.2). Since we have two regressors (market stock), we get three coefficients in this part of
the table if we take the constant term into account. The second part displays the word GroupSpecCoefs which indicates the
coefficients that vary over cross-sectional units. It is the alpha in equation (6.3.2). Since we have two
regressors (market stock), and 5 panels (cross-sectional units) as illustrated by the content of the macro e(effecpvar), the
coefficients of our regressors (market stock) are displayed for each panel we have. This is why the words (market and stock) are
repeated in the part containing the Group Specific Coefficients. They correspond to each and every cross-sectional units actually
used internally in our estimation. The third part exhibits the word TimeSpecCoefs which designates the coefficients that
vary over time. It is the lambda in equation (6.3.2). Since we have two regressors (market stock), and 20 time periods (time)
as demonstrated by the content of the macro e(effectvar), the coefficients of our regressors (market stock) are displayed for
each time we have. This is why the words (market and stock) are repeated in the part containing the Time Specific Coefficients. They
correspond to each and every time period actually used internally in our estimation. I suggest you to use the contents of the
macros e(effecpvar) and e(effectvar) to see which cross-sectional units and time period are included in your regression
and the display of the output. Last but not least, a Legend after the table of results also helps you in the interpretation
of the output.

In the next regression, we demonstrate how to compute the robust or sandwich estimator of variance.

xtfixedcoeftvcu invest market stock, vce(robust)

We illustrate the use of the technique() option by putting inside the brackets the name bfgs, which stands
for the Broyden-Fletcher-Goldfarb-Shanno algorithm.

xtfixedcoeftvcu invest market stock, technique(bfgs)

Now we specify technique(dfp 10 bfgs 50) which requests that xtfixedcoeftvcu perform 10 iterations with
the dfp (Davidon-Fletcher-Powell) algorithm followed by 50 iterations with the bfgs (Broyden-Fletcher-Goldfarb-Shanno)
algorithm, and then switch back to dfp for 10 iterations, and so on. The process continues until convergence or until
the maximum number of iterations is reached.

xtfixedcoeftvcu invest market stock, technique(dfp 10 bfgs 50)

The maximum number of iterations is controlled by the maxnbiter(#) option. You can increase or decrease
the maximum number of iterations according to the model you are estimating. Next we choose to decrease it to 1000 iterations.

xtfixedcoeftvcu invest market stock, maxnbiter(1000)

We augment the tolerance for the coefficient vector ptoler(#), the tolerance for the Residual Sum of
Squares vtoler(#) and the tolerance for the scaled gradient nrtoler(#) to 10^(-6).

xtfixedcoeftvcu invest market stock, ptoler(1e-6) vtoler(1e-6) nrtoler(1e-6)

Here we reduce the previous tolerances to 10^(-4).

xtfixedcoeftvcu invest market stock, ptoler(1e-4) vtoler(1e-4) nrtoler(1e-4)

If we do not want to display an iteration log of the Residual Sum of Squares, we type:

xtfixedcoeftvcu invest market stock, nodisplogs

If we want to specify the difficult option, we write:

xtfixedcoeftvcu invest market stock, difficult

Now, we change the confidence intervals level to 90% by typing:

xtfixedcoeftvcu invest market stock, level(90)

Next, we illustrate how to use time-series operators with the command xtfixedcoeftvcu. First, we
restore the original ordering of the dataset by writing:

tsset

Second, we perform the estimation by including the lagged value of the variable market.

xtfixedcoeftvcu invest market L.market stock, technique(dfp)

Let us demonstrate how to employ the forcereg option. Initially, we replace the second and third
observations of the variable invest with missing values.

replace invest = . in 2/3

Then, we run the following regression

xtfixedcoeftvcu invest market stock

Finally, we obtained an error message telling us that the command xtfixedcoeftvcu requires strongly balanced
data. At this point we could either find a way to get a balanced panel data on our own or use the option forcereg
to explicitly do it for us. Here we choose to employ the option forcereg.

xtfixedcoeftvcu invest market stock, forcereg technique(dfp)

To finish this Examples section, we now illustrate how to use the command xtfixedcoeftvcu
with predict. We start by reloading the original balanced panel data.

webuse invest2, clear

We run the following regression.

xtfixedcoeftvcu invest market stock

We calculate the linear prediction from all the equations taken together.

predict predofxboverall, xball

We calculate the linear prediction from the ConstantCoefs equation only.

predict predofxbeta, xbeta

We calculate the linear prediction from the GroupSpecCoefs equation only.

predict predofxalpha, xalpha

We calculate the linear prediction from the TimeSpecCoefs equation only.

predict predofxlambda, xlambda

We calculate the residuals from all the equations taken together.

predict predoffcresids, fcresids

We describe all the previously created variables to see their labels.

describe predofxboverall predofxbeta predofxalpha predofxlambda predoffcresids

Finally, we summarize these variables.

summarize predofxboverall predofxbeta predofxalpha predofxlambda predoffcresids

References

Hsiao, Cheng: 2014, Analysis of Panel Data, Third Edition, Cambridge University Press.

Author

Diallo Ibrahima Amadou

CERDI, University of Auvergne

65 bd Francois Mitterrand

63000 Clermont-Ferrand

France

E-Mail: zavren@gmail.com

Also see

Online: help for xtrc, xtreg, maximize