Professional Documents
Culture Documents
Panel Data Models
Panel Data Models
Andualem G. (Ph.D)
andulaser@gmail.com
1
What is panel data?
A data set containing observations on multiple phenomena
observed at a single point in time is called cross-sectional data
A data set containing observations on a single phenomenon
observed over multiple time periods is called time series data
Observations on multiple phenomena over multiple time
periods are panel data
Cross sectional and time series data are one- dimensional, panel
data are two-dimensional
Panel data can be used to answer both longitudinal and cross-
sectional questions!
2
Example of a panel data
Organization Time Profit Location Tax
MUGER CEMENT 2013 500,000 1 2%
MUGER CEMENT 2014 600,000 1 3%
MUGER CEMENT 2015 700,000 1 4%
MESSEBO CEMENT FACTORY 2013 400,000 2 2%
MESSEBO CEMENT FACTORY 2014 300,000 2 3%
MESSEBO CEMENT FACTORY 2015 200,000 2 4%
DERBA MIDROC CEMENT 2013 100,000 3 2%
DERBA MIDROC CEMENT 2014 300,000 3 3%
DERBA MIDROC CEMENT 2015 500,000 3 4%
Xit Xi Xt
3
Long versus Short Panel Data
4
Balanced versus Unbalanced Panel
Data
In a balanced panel, all entities have measurements in all time
periods. In a contingency table (or cross-table) of cross-
sectional and time-series variables, each cell should have only
one frequency. Therefore, the total number of observations is
nT.
When each entity in a data set has different numbers of
observations, the panel data are not balanced. Some cells in
the contingency table have zero frequency. Accordingly, the
total number of observations is not nT in an unbalanced
panel. Unbalanced panel data entail some computation and
estimation issues although most software packages are able
to handle both balanced and unbalanced data.
5
Fixed versus Rotating Panel Data
6
Recap : Example of a panel data
Organization Time Profit Location Tax
MUGER CEMENT 2013 500,000 1 2%
MUGER CEMENT 2014 600,000 1 3%
MUGER CEMENT 2015 700,000 1 4%
MESSEBO CEMENT FACTORY 2013 400,000 2 2%
MESSEBO CEMENT FACTORY 2014 300,000 2 3%
MESSEBO CEMENT FACTORY 2015 200,000 2 4%
DERBA MIDROC CEMENT 2013 100,000 3 2%
DERBA MIDROC CEMENT 2014 300,000 3 3%
DERBA MIDROC CEMENT 2015 500,000 3 4%
Xit Xi Xt
7
With panel data we can control for factors that:
8
Panel Data (cont.)
Potential unobserved heterogeneity is a form
of omitted variables bias.
Unobserved heterogeneity refers to omitted
variables that are fixed for an individual (at
least over a long period of time).
A persons upbringing, family characteristics,
innate ability, and demographics (except age)
do not change.
9
Panel Data (cont.)
With cross-sectional data, there is no
particular reason to differentiate between
omitted variables that are fixed over time and
omitted variables that are changing.
However, when an omitted variable is fixed
over time, panel data offers another tool for
eliminating the bias.
10
Panel Data (cont.)
Panel Data is data in which we observe repeated
cross-sections of the same individuals.
Examples:
Annual unemployment rates of each country over several
years
Quarterly sales of individual stores over several quarters
Wages for the same worker, working at several different
jobs
11
Panel Data (cont.)
By far the leading type of panel data is
repeated cross-sections over time.
The key feature of panel data is that we
observe the same individual in more than one
condition.
Omitted variables that are fixed will take on
the same values each time we observe the
same individual.
12
Panel Data (cont.)
Some of the most valuable data sets in
economics and finance are panel data sets.
13
Panel Data (cont.)
For example, the National Longitudinal Survey
of Youth (NLSY) tracks labor market outcomes
for thousands of individuals, beginning in their
teenage years.
The Panel Survey of Income Dynamics
provides high-quality income data.
The panel Survey of Stock Price provides a
high quality asset return data
14
Example:
Cross-Industry Wage Disparities
A great puzzle in labor market is the presence of cross-
industry wage disparities.
Workers of seemingly equivalent ability, in seemingly
equivalent occupations, receive different wages in
different industries.
e.g. A person with MSc in accounting working at ECA paid
30,000 birr. Another person with MSc in accounting
working at Addis Ababa University paid 5000 birr.
Do high-wage industries actually pay higher wages, or
do they attract workers of unobservably higher quality?
15
Gibbons and Katz findings
Gibbons and Katz (Review of Economic Studies
1992) exploited panel data to explore these
differentials.
They observed workers in 1984 and 1986.
They focused on workers who lost their
1984 jobs because of plant closings (on the
grounds that plant closings are unlikely to be
correlated with an individual workers
abilities). They looked only at workers who
were re-employed by 1986.
16
Gibbons and Katz findings
Gibbons and Katz estimated wages as
.. m DitIndustry _ m it
where Xkit are demographic variables, and
Dit are a set of dummy variables for being
employed in different industries
17
Gibbons and Katz findings
18
Gibbons and Katz findings
Gibbons and Katz speculated that any
unmeasured ability is fixed over time and equally
rewarded in all industries.
.. m D Industry _ m
it vi it
19
Gibbons and Katz findings
20
Gibbons and Katz findings
The estimated industry coefficients from
the differenced equation are about 80% of
the estimated industry coefficients from the
levels equation.
21
A Panel Data DGP
22
Panel Data DGPs (cont.)
Notice that when we have panel data, we
index observations with both i and t.
Pay close attention to the subscripts on
variables.
Some variables vary only across time or across
individual.
23
Recap : Example of a panel data
Organization Time Profit Location Tax
MUGER CEMENT 2013 500,000 1 2%
MUGER CEMENT 2014 600,000 1 3%
MUGER CEMENT 2015 700,000 1 4%
MESSEBO CEMENT FACTORY 2013 400,000 2 2%
MESSEBO CEMENT FACTORY 2014 300,000 2 3%
MESSEBO CEMENT FACTORY 2015 200,000 2 4%
DERBA MIDROC CEMENT 2013 100,000 3 2%
DERBA MIDROC CEMENT 2014 300,000 3 3%
DERBA MIDROC CEMENT 2015 500,000 3 4%
Xit Xi Xt
24
Panel Data DGPs (cont.)
25
Panel Data DGPs (cont.)
26
Panel Data DGPs (cont.)
In this DGP, the b0i are fixed across samples.
The unmeasured heterogeneity is the same in
every sample.
This DGP is called the Distinct Intercepts
DGP.
It is suitable for panels of states or countries,
where the same individuals would be selected
in each sample.
27
Panel Data DGPs (cont.)
With longitudinal data on individual workers
or consumers, we draw a different set of
individuals from the population each time we
collect a sample.
Each individual has his/her own set of fixed
omitted variables.
We cannot fix each individual intercept.
28
Another Panel Data DGP
29
Panel Data DGPs
In this DGP, we return to a model with a single
intercept for all data points, b0
However, we break the error term into two
components: v
it i it
When we draw an individual i, we draw one vi
that is fixed for that individual in all time
periods.
vi includes all fixed omitted variables.
30
Panel Data DGPs
In the Distinct Intercepts DGP, the unobserved
heterogeneity is absorbed into the individual-
specific intercept b0i
In the second DGP, the unobserved
heterogeneity is absorbed into the individual
fixed component of the error term, vi
This DGP is an Error Components Model.
31
Panel Data DGPs
The Error Components DGP comes in two
flavors, depending on E ( X jit vi ) .
If E ( X jit vi ) 0, then the unobserved
heterogeneity is uncorrelated with the
explanators.
OLS is unbiased and consistent.
32
Panel Data DGPs
If E ( X jit vi ) 0 , then the unobserved
heterogeneity IS correlated with
the explanators.
33
Panel Data DGPs
Panel data is most useful in the second Error
Components case.
When E ( X jit vi ) 0 , OLS is inconsistent.
Using panel data, we can create a consistent
estimator: Fixed Effects.
34
Recall
OLS estimator beta and alpha are BLUE (best
linear unbiased estimator)
Best: variance of OLS estimator is minimal,
smaller than the variance of any other estimator
Linear: if the relationship is not linear- OLS is not
applicable
Unbiased: the expected values of the estimated
beta and alpha equal the true values describing
the relationship between X and Y
35
Recall :How to choose between
estimator: Bias vs consistency
Efficiency is a relative measure between two estimator. An
estimator is efficient when it is smaller variance than
another estimator
Consistency: how far is the estimator likely to be from the
true parameter as we let the sample size increase
indefinitely. If N approaches to infinity the estimated beta
equals the true beta.
Unlike unbiasedness, consistency involves that the variance
of the estimator collapses around the true value as N
approaches infinity. Thus unbiased estimator are not
necessarily consistent, but those whose variance shrink to
zero as the sample size grows are consistent
36
Fixed Effects
The Fixed Effects Estimator
Used with EITHER the distinct intercepts DGP
OR the error components DGP
with E ( X v ) 0
ijt i
37
Fixed Effects
The simplest way to estimate separate
intercepts for each individual is to use dummy
variables.
This method is called the least squares
dummy variable estimator.
38
Fixed Effects
We have already seen that we can use dummy
variables to estimate separate intercepts for
different groups.
With panel data, we have multiple
observations for each individual. We can
group these observations.
39
Fixed Effects
Least Squares Dummy Variable Estimator:
1. Create a set of n dummy variables,
D j, such that D j = 1 if i = j.
2. Regress Yit against all the dummies,
Xt , and Xit variables (you must omit Xi
variables and the constant).
40
Fixed Effects
The LSDV estimator is conceptually quite
simple.
In practice, the tricky parts are:
1. Creating the dummy variables
2. Entering the regression into the computer
3. Reporting results
41
Fixed Effects
Suppose we have a longitudinal dataset with
300 workers over 10 years.
n = 300
We must create 300 dummy variables and
then specify a regression with
300+ explanators.
How do we do this in our software package?
42
Fixed Effects
Our regression output includes 300 intercepts.
Usually, we are not interested in the intercepts
themselves.
We include the dummy variables to control for
heterogeneity.
43
Fixed Effects
In reporting your regression output,
it is preferable to note that you have included
individual fixed effects.
44
Fixed Effects
At some point, n becomes too large for the
computer to handle easily.
Modern computers can implement LSDV for
ever larger data sets, but eventually LSDV
becomes computationally intractable.
45
Fixed Effects
A computationally convenient alternative is
called the Fixed Effects Estimator.
Technically, only this strategy is
Fixed Effects; using dummy variables is
LSDV.
In practice, econometricians tend to refer to
either method as Fixed Effects.
46
Fixed Effects
The initial insight for the Fixed Effects
estimator: if we DIFFERENCE observations for
the same individual, the vi cancels out.
47
Fixed Effects
48
Fixed Effects
When we difference, the heterogeneity term
vi drops out.
(In the distinct intercepts model, the b0i would
drop out).
By assumption, the it are uncorrelated with
the Xit
OLS would be a consistent estimator of b1
49
Fixed Effects
If T = 2, then we have only 2 observations for
each individual
(as in the Gibbons and Katz example).
Differencing the 2 observations is efficient.
If T > 2, then differencing any 2 observations
ignores valuable information in the other
observations for each individual.
50
Fixed Effects
We can use all the observations for each
individual if we subtract the individual-specific
mean from each observation.
51
Fixed Effects
52
Fixed Effects
53
Fixed Effects
The Fixed Effects and DVLS estimators
provide exactly identical estimates.
The n-T-k term of the Fixed Effects e.s.e.s
must be adjusted to account for the extra n
degrees of freedom that have been used.
The computer can make this adjustment
54
Fixed Effects
Demeaning each observation by the
individual-specific mean eliminates the need
to create n dummy variables.
55
Fixed Effects
Fixed Effects (however estimated) discards all
variation between individuals.
Fixed Effects uses only variation over time
within an individual.
FE is sometimes called the within estimator.
56
Fixed Effects
Fixed Effects discards a great deal of variation
in the explanators (all variation between
individuals).
Fixed Effects uses n degrees of freedom.
Fixed Effects is not efficient if
E ( X it vi ) 0
Could we use OLS?
57
Checking Understanding (cont.)
58
Checking Understanding (cont.)
Because X is uncorrelated with either
v or , OLS is consistent in the uncorrelated
version of the error components DGP.
59
Checking Understanding (cont.)
However, the covariance between
disturbances for a given individual is
60
Checking Understanding (cont.)
In the presence of serial correlation, OLS is
inefficient.
61
Random Effects
When unobserved heterogeneity is
uncorrelated with explanators, panel data
techniques are not needed to produce a
consistent estimator.
62
Random Effects
When E ( X it vi ) 0, panel data provides
a valuable tool for eliminating omitted
variables bias. We use Fixed Effects to gain the
benefits of panel data.
When E ( X it vi ) 0 , panel data does not offer
special benefits. We use Random Effects to
overcome the serial correlation of panel data.
63
Random Effects
The key idea of random effects:
Estimate v2 and 2
Use these estimates to construct efficient weights
of panel data observations
64
Random Effects
65
Random Effects
Once we have estimates of v2 and
2, we can re-weight the observations
optimally.
66
Example: Production Functions
We have data from 625 French firms from
16 countries for 8 years.
We wish to estimate a CobbDouglas production
function: b1 b 2
Qi b 0 Li Ki i
Taking logs:
ln(Qi ) ln( b0 ) b1 ln( Li ) b 2 ln( Ki ) ln( i )
We estimate using random effects.
67
Random Effects Estimation
of a CobbDouglas Production Function
for a Sample of Manufacturing Firms
68
Example: Production Functions
The estimated coefficients of 0.30 for capital
and 0.69 for labor are similar to estimates
using US data.
69
Fixed Effects Estimation of a CobbDouglas
Production Function for a Sample of
Manufacturing Firms
70
Example: Production Functions
We arrive at similar estimates using either
random effects or fixed effects.
Because only fixed effects controls
for unobserved heterogeneity that is
correlated with the explanators, the similarity
between the two estimates suggests that
unobserved heterogeneity is not creating a
large bias in
this sample.
71
Example: Production Functions
The fixed effects estimator discards all
variation between firms, and must use
624 more degrees of freedom than
random effects.
Moving from RE to FE increases the e.s.e.
on capital from 0.0116 to 0.0145
The e.s.e. on labor moves from 0.0118
to 0.0132
72
Example: Production Functions
The RE estimator provides more
precise estimates
We would prefer to use RE instead of FE.
However, RE might be inconsistent if
E ( X it vi ) 0
74
The Hausman Test
If E ( X it vi ) 0 , then the unobserved
heterogeneity is uncorrelated with X
and does not create a bias.
RE and FE are both consistent.
For two consistent estimators to provide
significantly different estimates would be
surprising.
75
The Hausman Test
We know the FE estimator is consistent even
when E ( X it vi ) 0
The problem with FE is its inefficiency.
FE is not as precise as RE.
Although FE is imprecise, it may provide a
good enough estimate to detect a large bias in
RE.
76
The Hausman Test
If FE is very imprecise, then the Hausman test
has very weak power and cannot rule out
even large biases.
If FE is very precise, then the Hausman test
has very good power, but we gain little benefit
from switching to the more efficient RE.
77
The Hausman Test
If FE is somewhat precise, then the Hausman
test can warn us away from using RE in the
presence of a large bias, but there is still room
for substantial efficiency gains in switching to
RE.
79
The Hausman Test
Warning: fixed effects exacerbates
measurement error bias.
There is likely to be less variation
in X within the experience of a single
individual than across several individuals.
Small measurement errors can become large
relative to the within-variation in X.
80
The Hausman Test
The Hausman Test warns us that RE and
FE provide significantly different estimates.
This difference could arise because of
omitted variables bias in RE, caused by
E( X it vi ) 0
This difference could ALSO arise because
of measurement error biases in FE.
81
Review
Potential unobserved heterogeneity is a form
of omitted variables bias.
Unobserved heterogeneity refers to omitted
variables that are fixed for an individual
(at least over a long period of time).
A persons upbringing, family characteristics,
innate ability, and demographics (except age)
do not change.
82
Review
Panel Data is data in which we
observe repeated cross-sections of the same
individuals.
83
Review
The key feature of panel data is that we
observe the same individual in more than one
condition.
Omitted variables that are fixed will take on
the same values each time we observe the
same individual.
84
Review
We learned 3 different DGPs for
panel data.
In the distinct intercept DGP, across samples
we would observe the same individuals with
the same unobserved heterogeneity.
Each i has its own intercept, b0i, that is fixed
across samples.
85
A Panel Data DGP
86
Review
Error components DGPs are suitable when we
would draw different individuals across
samples.
When each i is drawn, its unobserved
heterogeneity is captured in a vi term.
We learned two error components
DGP, depending on whether the vi is
correlated with the Xkit s.
87
Another Panel Data DGP
88
Review
If E( X it vi ) 0, OLS would be inconsistent
By estimating a separate intercept for each
individual, we can control for the vi
We learned two equivalent strategies: DVLS
and FE.
89
Review
The simplest way to estimate separate
intercepts for each individual is to use dummy
variables.
90
Review
Least Squares Dummy Variable Estimator:
1. Create a set of n dummy variables,
D j , such that D j = 1 if i = j
2. Regress Yit against all the dummies,
Xt , and Xit variables (you must omit Xi
variables and the constant)
91
Review
92
Review
Demeaning each observation by the
individual-specific mean eliminates the need
to create n dummy variables.
93
Review
Fixed Effects (however estimated) discards all
variation between individuals.
Fixed Effects uses only variation over time
within an individual.
FE is sometimes called the within estimator.
94
Review
Because X is uncorrelated with either
v or , OLS is consistent in the uncorrelated
version of the error components DGP.
Var(it ) Var(vi it )
2
v
2
95
Review
However, the covariance between
disturbances for a given individual is
E (v )
2
i
2
v
Cov( it , it ' ) v2
Corr ( it , it ' ) 2
Var ( it ) v 2
96
Review
When unobserved heterogeneity is
uncorrelated with explanators, panel data
techniques are not needed to produce a
consistent estimator.
97
Review
When E (,X it vi ) 0panel data provides
a valuable tool for eliminating omitted
variables bias. We use Fixed Effects to gain the
benefits of panel data.
98
Review
When E( X it vi ) 0 , panel data is less
convenient than an equal-sized
cross-sectional data set. We use Random
Effects to overcome the serial correlation of
panel data.
99
Review
The key idea of random effects:
Estimate v2 and 2
Use these estimates to construct efficient weights
of panel data observations
100
Random vs. Fixed Effects
Random Effects
Small number of parameters
Efficient estimation
If you believe that differences across entities have some influence on your dependent variable then
use Random effect model.
It also accommodate time invariant variables
Pr ofitit b1 b 2 Saleit b3adv cos tit it it , where Profit i is the profit of i firm
in time t
Fixed Effects
Robust generally consistent
Large number of parameters
More reasonable assumption
Precludes time invariant regressors
Use fixed effect whenever you are interested in analyzing the impact of variables that vary over time
assumption of the correlation between entitys error term and predictor variables
FE remove the effect of those time-invariant characteristics
designed to study the causes of changes within a country
Pr ofitit b1 b 2 Saleit b3adv cos tit i it , where Profit i is the profit of i firm
in time t 101
Random vs. Fixed Effects
102
Using panel data in Stata
103
Commands
xtset company time
xtdes
Xtsum
Interpretation for sum:
**/ For time-invariant variable ed the within variation is
zero.
For individual-invariant variable t the between variation is
zero.
For lwage the within variation < between variation/*****
xtdata
xtline revenue
xtline revenue, overlay
104
Commands: Tabulation
**/Panel tabulation for a variable. If south is a
dummy /**
xttab south
Interpretation for tab:
For overall percent: 29.03% on average were in
the south.
For between percent: 20.59% were ever in the
south.
For within percent: 94.9% of those ever in the
south were always in the south.
105
Commands: Transition and correlation
**/Transition probabilities for a variable///
xttrans south, freq
Interpretation: For the 28.99% of the sample
ever in the south, 99.23% remained in the south
the next period.
correlate lwage L.lwage L2.lwage L3.lwage
L4.lwage L5.lwage L6.lwage
106
Regression
1. reg revenue numberofbranchadvcost
2. ****Pooled OLS with cluster-robust standard errors*/**
regress lwage exp exp2 wks ed, noheader vce(cluster id)
3. xi: regress revenue numberofbranchadvcosti.company
4. Pooled GLS estimator: xtgee. Pooled FGLS estimator with
AR(2) error & cluster-robust ses
xtgee lwage exp exp2 wks ed, corr(ar 2) vce(robust)
5. Between GLS estimator: xtreg, be
xtreg lwage exp exp2 wks ed, be
6. First difference estimator with cluster-robust ses
regress D.(lwage $xlist), vce(cluster id)
107
Random and fixed effect
7. xtreg revenue numberofbranch , fe **** fixed effect
**Coefficients of the regressors indicate how much Y
changes when X increases by one unit**********
8. * Random effects estimator with cluster-robust ses
xtreg lwage exp exp2 wks ed, re vce(robust) theta
xtreg revenue numberofbranch, re **** random effect
**** represents the average effect of X over Y when X
changes across time and between countries by one
unit**
108
Hausman test
Hausman test (If this is < 0.05 mean P value (i.e. significant) use fixed effects): to
run it
xtreg revenue numberofbranch , fe
estimates store fixed
xtreg revenue numberofbranch , re
estimates store randome
Hausmanfixeddrandomm
109
Compare different estimation
110
cross-sectional dependence
cross-sectional dependence is a problem in macro panels with long
time series (over 20 30 years). This is not much of a problem in
micro panels (few years and large number of cases). The null
hypothesis in the B-P/LM test of independence is that residuals
across entities are not correlated.
xtreg revenue numberofbranch , fe
xttest2
if P value is higher than 0.05 then No cross-sectional dependence
alternatively we can use Pasaran CD (cross-sectional dependence):
used to test whether the residuals are correlated across entities
xtreg revenue numberofbranch , fe
xtcsd, pesaran abs
if P value is higher than 0.05 then No cross-sectional dependence
111
A test for heteroskedasticiy and Serial
correlation tests
1. A test for heteroskedasticiy
The null is homoskedasticity (or constant variance)
This is a user-written program, to install it type:
ssc install xtest3
xttest3
2. Serial correlation tests apply: is a problem of long time 20- 30
A Lagram-Multiplier test for serial correlation is available using the
command
xtserial.
This is a user-written program, to install it typessc install xtserial
xtserial revenue numberofbranch
112