*! version 1.0.0 // A METTRE
help xtnptimevar

Title

Performs Estimations of Non-Parametric Time-Varying Coefficients Panel Data Models with Fixed Effects

Syntax

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

Main
stub(string) designates a string name from which new objects' names (variables, graphs, standard errors, …) will be created

bwidth(#) uses # for the bandwidth; default employs a data driven rule of thumb bandwidth

forcereg this option explicitly balances the panel data before the estimation

alle this option allows using the averaged local linear estimator; the default employs the local linear dummy variable estimator

nographs removes the display of graphs after the estimations are performed

saving(string) allows to save the graphs and other objects that the command creates

title(string) this option allows the user to specify his own title for the graphs generated by the estimation

bootstrap triggers the computation of the pointwise standard errors and confidence intervals via bootstrap; by default they are not calculated

bootoptions(string) in this option, you specify a list of nearly all the options allowed by the bootstrap command

matsize(#) sets the maximum number of variables through the command matsize when the bootstrap option is specified

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

indepvars may contain time-series operators; see tsvarlist.

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

Description

xtnptimevar performs estimations of non-parametric time-varying coefficients panel data models with fixed effects.
Often researchers desire to estimate the effects of some regressors on the dependent variable in a nonlinear fashion in the
context of panel data without imposing a specific functional form. In other words they want the data to reveal this functional
form by letting them speak for themselves. The command xtnptimevar exactly does that. It offers two estimators:
the local linear dummy variable estimator (the default) and the averaged local linear estimator. Both of these two
techniques allow estimating coefficients that vary over time for panel data models. These two estimators were invented
by Li, Chen and Gao (2011). The theory behind the command xtnptimevar is provided in their paper.

Options

Main

stub(string) designates a string name from which new objects' names (variables, graphs, standard errors, …) will be
created. To form this option, you put inside the brackets a string name (without the double quotes). Then new objects' names
will be created from this string. You must specify this option in order to get a result. Hence this option is required.

bwidth(#) uses # to specify the value of the bandwidth. The default employs a data driven rule of thumb bandwidth
that corresponds to the Epanechnikov Kernel (Quadratic kernel) internally used by the command, and that also satisfies
assumption 2.4 of Li, Chen and Gao (2011) paper. You can override this default value by putting a positive real number
inside the brackets. The greater the bwidth(), the greater the smoothing.

forcereg explicitly balances the panel data before the estimation. The command xtnptimevar 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.

alle allows using the averaged local linear estimator. The default employs the local linear dummy variable
estimator which has a quicker asymptotic rate of convergence than the averaged local linear estimator as suggested
by Li, Chen and Gao (2011). But the averaged local linear estimator is faster to compute in practice than the local
linear dummy variable estimator. Hence if you are concerned about efficiency, use the local linear dummy variable
estimator (the default); and if you are worried about speed of calculation employ the averaged local linear estimator.

nographs suppresses the display of graphs after the estimations are performed. This option is used when we do not
want to display the graphs after the estimations are done.

saving(string) in this option, you specify the complete file path where you want to save the graphs produced by
the command. You must enclose de path in double quotes. If you do not specify this option, the graphs will be displayed,
if you do not choose the nographs option, but they will not be saved. This saving(string) option is optional
when you do not specify the bootstrap option, meaning that you can omit it, if you want, in this case. But this
option is required when you choose the bootstrap option. In this situation, the option saving(string) is
mandatory and allows saving new objects (variables, graphs, standard errors, databases, …) that the bootstrap
option creates.

title(string) this option allows the user to give his title for the graphs generated by the estimation. You specify
this option when you want to override the default graph names provided by the command. In this case, put a string
corresponding to the name you want for the graphs inside the option title(string) without the double quotes.

bootstrap triggers the computation of the pointwise standard errors and confidence intervals via bootstrap. By default
the command xtnptimevar only computes the coefficient-vectors in function of time. If you want to calculate the pointwise
standard errors and confidence intervals for the coefficient-vectors, specify the bootstrap option.

bootoptions(string)
in this option, you specify a list of nearly all the options allowed by the bootstrap command. Except the following
options: cluster(varlist), idcluster(newvar), saving(filename, ...)
which are already used internally by the command xtnptimevar, nearly all the other options of the bootstrap command
can be included in the option bootoptions(string). To form them, enter inside the brackets the options of
the bootstrap command separated by blank spaces as you would do with the bootstrap command. Some of these options
are: level(#), seed(#), nodots, etc. The bootoptions(string) option is for use
in conjunction with the bootstrap option.

matsize(#)
sets the maximum number of variables through the command matsize when the bootstrap option is specified.
We have 10 < # < 11000 for Stata/MP and Stata/SE and 10 < # <
800 for Stata/IC. By default # = 800 in the command xtnptimevar. The matsize option
is for use in conjunction with the bootstrap option.

Return values

xtnptimevar saves the following results in e() when the bootstrap option is not specified:

Scalars
e(N) Number of observations used
e(T) Time used
e(bwidth) The computed or specified bandwidth
e(k) Number of regressors used
e(NT) Total number of observations used
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

Macros
e(cmdline) Command as typed by the user
e(cmd) "xtnptimevar", command name
e(seq_stub_efftv) Effective time variable used for the calculation
and the plotting of the coefficient-vectors
e(seq_stub_b_i) The sequence of coefficient-vectors. If you have
k regressors, you will obtain i = 1...k+1
sequences of coefficient-vectors
e(ivar) Individual (panel) variable
e(depvar) Dependent variable

Functions
e(sample) Marks estimation sample

xtnptimevar saves the following results in e() when the bootstrap option is specified:

Scalars
e(N) Number of observations used
e(T) Time used
e(bwidth) The computed or specified bandwidth
e(k) Number of regressors used
e(NT) Total number of observations used
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

Macros
e(cmdline) Command as typed by the user
e(cmd) "xtnptimevar", command name
e(seq_stub_efftv) Effective time variable used for the calculation
and the plotting of the coefficient-vectors
e(seq_stub_ciul_i) The sequence of upper limits confidence intervals
of the coefficient-vectors.
If you have k regressors, you will obtain i = 1...k+1
sequences of upper limits confidence
intervals; they are Normal-based only
e(seq_stub_cill_i) The sequence of lower limits confidence intervals
of the coefficient-vectors.
If you have k regressors, you will obtain i = 1...k+1
sequences of lower limits confidence
intervals; they are Normal-based only
e(seq_stub_se_i) The sequence of bootstrapped standard errors of the
coefficient-vectors. If you have k regressors, you
will obtain i = 1...k+1 sequences of standard errors
e(seq_stub_b_i) The sequence of coefficient-vectors. If you have
k regressors, you will obtain i = 1...k+1
sequences of coefficient-vectors
e(vcetype) Title used to label standard errors
e(cluster) Cluster variables
e(seed) Initial random-number seed
e(clustvar) Cluster variables
e(stubloc) A string indicating the content of the stub() option
e(nombreco) Total number of coefficient-vectors estimated (k+1)
e(ivar) Individual (panel) variable
e(depvar) Dependent variable

Functions
e(sample) Marks estimation sample

Warning

The command xtnptimevar, like many non-parametric estimation techniques, is highly
computationally intensive and may for that reason take a very long time to run on a
sluggish machine.

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 xtnptimevar with the dataset xtnptimevardata.dta.
This dataset contains panel data of 51 countries from 1980 to 2012.

use http://fmwww.bc.edu/repec/bocode/x/xtnptimevardata.dta, clear

Next we describe the dataset to see the definition of each variable. The dependent
variable is Total factor productivity growth calculated as a Solow residual. The regressors are
Openness, Financial development, Government consumption expenditures, Gross inflation and Investment.
All these regressors are logged and quadratically filtered to satisfy the stationarity assumption of
the independent variables in the Li, Chen and Gao (2011) paper. We also have the variable Income level
indicating whether the country belongs to the high income category or not.

describe

It is important to remind the reader that the command
xtnptimevar, particularly with the bootstrap option, is highly computationally intensive and
may take a very long time to run. For instance to execute all instructions (all the lines) included in this
Examples section, in my machine, it took 104274.5760 seconds. This is not a performance issue of the
command but it is due to the nature of the estimation technique (non-parametric estimation). To even speed
the computation process, many parts of the package are written in Mata.

Now let's turn to the estimations. We regress the dependent
variable (tfpg) on the variable of interest (openness) and the control variables (govcons inflation invest).
We also specify the option stub() in which we put the string "coefsa" without the double quotes. This
option is required.

xtnptimevar tfpg openness govcons inflation invest, stub(coefsa)

The previous estimation gives 5 graphs. The first correspond to the trend function
(Coefficient-Vector 1) and the others to the coefficient functions (Coefficient-Vector 2 to
Coefficient-Vector 5). In the estimators provided by Li, Chen and Gao (2011), the coefficients are
smooth functions of time, they are called in the command xtnptimevar Coefficient-Vectors to
differentiate them with the scalar values that someone would obtain in a traditional fixed effects
panel data model. Thus in the previous regression, the trend function is named Coefficient-Vector 1,
the coefficient of openness is named Coefficient-Vector 2, the coefficient of govcons is named
Coefficient-Vector 3, the coefficient of inflation is named Coefficient-Vector 4 and the coefficient
of invest is named Coefficient-Vector 5. We observe that openness has a negative effect on total
factor productivity growth from the mid-1980s to the mid-1990s and roughly a positive impact from the
mid-1990s to the year 2010.

The previous estimation also generates variables containing the Coefficient-Vectors and the
Effective time variable used for the calculation and the plotting of the Coefficient-Vectors. To see
these variables, we type:

describe coefsa_*

The next regression shows how to use the alle option. This option allows using the averaged
local linear estimator instead of the local linear dummy variable estimator (the default).

xtnptimevar tfpg openness govcons inflation invest, stub(coefsb) alle

Now we increase the number of control variables by introducing financial development.

xtnptimevar tfpg openness finddev govcons inflation invest, stub(coefsc)

We obtained an error message telling us that the command xtnptimevar 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.

xtnptimevar tfpg openness finddev govcons inflation invest, stub(coefsd) forcereg

We illustrate how to use the bwidth(#) option. Instead of the default which employs a data
driven rule of thumb bandwidth, we choose to provide our own bandwidth. We pick it here to be 0.15. Remember
that the greater the bwidth(), the greater the smoothing.

xtnptimevar tfpg openness govcons inflation invest, stub(coefse) bwidth(0.15)

If we do not want to display the graphs, we type:

xtnptimevar tfpg openness govcons inflation invest, stub(coefsf) alle nographs

In the following, we demonstrate how to use the saving(string) option. Assume that you have Windows as
your Operating System and you want to save the graphs produced by the command xtnptimevar in a folder named "mystatagraphs"
located in the "C:\" drive. So the full path name is "C:\mystatagraphs". Note that, you must physically create this folder;
otherwise the next instruction will not work at all. Also if you have an Operating System other than Windows, you must supply
the correct file path according to your Platform. To save the graphs in the "mystatagraphs" folder, just type
(without forgetting the double quotes):

\mystatagraphs")"'

If you open the folder "mystatagraphs", you will find that it contains 6 graphs. If you want to save another set of graphs in
the same folder, just change the name that you put in the stub() option. For instance, change it to "newg" and you will have 6 more
graphs in the folder "mystatagraphs".

In the next line we override the default graph names provided by the command by putting a string corresponding to the name
we want for the graphs inside the option title() without the double quotes.

xtnptimevar tfpg openness finddev govcons inflation invest, stub(coefsh) alle forcereg title(The Graph of the Nonlinear Coefficient)

Now we illustrate how to use the bootstrap option. This option triggers the computation of the pointwise standard
errors and confidence intervals by using the bootstrap technique. Often when you set the bootstrap option, you will also
need to specify the matsize(#) option to indicate the maximum number of variables through the command matsize. When
your dataset is big, you will need to increase the number inside the matsize() option. Additionally when you choose
the bootstrap option, you must specify the saving(string) option which indicate the complete file path where to
save the new objects that the bootstrap option creates. Hence when the bootstrap option is chosen, the
saving(string) option becomes required.

\mystatagraphs")"'

The previous estimation provides 5 graphs. The first correspond to the trend function and is named "Graph of Coefficient-Vector 1".
Coefficient-Vector 1 is the red line in the figure. We observe that, contrarily to the previous graphs, there is a gray band around the curve
of Coefficient-Vector 1. This is the 95% confidence interval. This confidence interval is normal based only, hence the "NB"
abbreviation on the figure. The remaining 4 graphs represent the graphs of the coefficients of the regressors
(openness, govcons, inflation, invest) with their respective confidence intervals. They are named graph of
(Coefficient-Vector 2, …, Coefficient-Vector 5) respectively. The estimation also gives 5 regression tables.
Each represents the bootstrapped regression table of a Coefficient-Vector. For instance the estimation of the trend
function (Coefficient-Vector 1) is given in the first table. Unlike traditional fixed effects panel regressions, we see
that, in the first column of the first table of results, instead of the variables' names, there are as a substitute years.
This is because Coefficient-Vector 1 depends on years (the coefficients of the estimation are smooth functions of time).
The second column of the estimation results of Coefficient-Vector 1 represents the observed values of Coefficient-Vector 1,
the others are respectively, the Bootstrap Std. Err., the Z-statistics, the P-values and the Normal-based 95% Conf. Interval
for every year used in the regression. The remaining 4 tables of results correspond to the bootstrapped tables of the
coefficients of the regressors (openness, govcons, inflation, invest), that is Coefficient-Vector 2 to Coefficient-Vector 5
respectively.

The previous estimation also generates variables containing the Coefficient-Vectors, the Effective time variable
used for the calculation and the plotting of the Coefficient-Vectors, the Sequence of upper and lower limits confidence
intervals of the Coefficient-Vectors, and their Sequence of bootstrapped standard errors. To see all these variables, we type:

describe coefsi_*

Next we demonstrate how to employ the bootoptions(string) option. As stated previously, in this
option, you specify a list of nearly all the options allowed by the bootstrap command. To form them, we enter inside the
brackets the options of the bootstrap command separated by blank spaces as we would do with the bootstrap command.
For instance, here we choose to increase the number of bootstrap replications to 70 and suppress the replication dots.

\mystatagraphs")"'

In the following line we set the random-number seed to "375235" and the confidence level to 99.

\mystatagraphs")"'

To close this Examples section, we show how to use the command xtnptimevar with the if qualifier.
First we tabulate the variable inlevel. We see that this variable is a dummy variable indicating whether a country is
developed or not.

tabulate inlevel

We run a regression on the subsample of developed countries.

xtnptimevar tfpg openness govcons inflation invest if inlevel==1, stub(coefsl) alle

We do the same thing on the subsample of developing countries.

xtnptimevar tfpg openness govcons inflation invest if inlevel==0, stub(coefsm) alle

We perform an estimation for all years greater than 1984.

xtnptimevar tfpg openness govcons inflation invest if year>1984, stub(coefsn) alle

Next we run a regression on the subsample of developed countries and for the years between 1990 and 2010.

\mystatagraphs")"'

We do the same thing as above on the subsample of developing countries.

\mystatagraphs")"'

References

Degui Li, Jia Chen and Jiti Gao: 2011, "Non-parametric Time-Varying Coefficient Panel Data Models with Fixed Effects", The Econometrics Journal 14, 387-408.

Acknowledgements

The main program of this command is a Stata adaptation of Li, Chen and Gao (2011) Matlab corresponding original program. I would like to
thank Professors Degui Li (Department of Mathematics, University of York), Jia Chen (Department of Economics, University of York)
and Jiti Gao (Department of Econometrics and Business Statistics, Monash University) for allowing me to use their Matlab program,
and particularly Professor Degui Li for the many fruitful exchanges we had during the building process of the package. I would like
also to thank Rasmane Ouedraogo (CERDI, Univeristy of Auvergne) for using and testing previous versions of the command. The usual
disclaimers apply: all errors and imperfections in this package are mine and all comments are very welcome.

Author

Ibrahima Amadou Diallo

CERDI, University of Auvergne

65 bd Francois Mitterrand

63000 Clermont-Ferrand

France

E-Mail: zavren@gmail.com

Also see

Online: help for kdensity, lowess, lpoly, mlowess (if installed), locpr (if installed), kdens (if installed)