34
Econometrics of Panel Data 1. Basics and Examples 2. The generalized least squares estimator 3. Fixed effects model 4. Random Effects model 1

Panel Data for Learing

Embed Size (px)

DESCRIPTION

Panel Data for Learing

Citation preview

Page 1: Panel Data for Learing

Econometrics of Panel Data

1. Basics and Examples

2. The generalized least squares estimator

3. Fixed effects model

4. Random Effects model

1

Page 2: Panel Data for Learing

1 Basics and examples

We observes variables for N units, called the cross-sections, for T

consecutive periods:

(Yit, Xit)

⋄ i = 1, . . . , N , with N the cross-sectional dimension.

⋄ t = 1, . . . , T , with T the temporal dimension.

→ panel of size N × T .

2

Page 3: Panel Data for Learing

⋄ Yit is the income of family i during year t, for 1 ≤ i ≤ 1000, and

observed in years 2000, 2001, 2002, so T = 3.

⋄ Yit is the unemployment rate for EU-country i, (1 ≤ i ≤ 15),

observed monthly from 1998:01 up to 2001:12, so T = 48.

Note that:

T large, N small → multiple time series

T small, N large → survey data on individuals/firms for a small

number of waves.

3

Page 4: Panel Data for Learing

Example 1: South American countries

For 8 South-American countries we want to model the Real GDP per

capita in 1985 prices (=Rgdl) in function of the following explicative

variables.

⋄ Population in 1000’s (Pop)

⋄ Real Investment share of GDP, in % (I)

⋄ Real Government share of GDP, in % (G)

⋄ Exchange Rate with U.S. dollar (XR)

⋄ Measure of Openness of the Economy (Open)

You find the data in the file ”penn.wmf”, already in Eviews format.

We are in particular interested in the effect of Openness on economic

growth.

4

Page 5: Panel Data for Learing

1. Create a“pool” object in Eviews (‘/Object/New object’). Give it a name and

define the cross-section identifiers. These identifiers are those parts of the

names of the series identifying the cross-section.

2. Open the XR-variables as a group and make a plot of them. Compute them

in log-difference, using the PoolGenr menu of the pool object and

”logdifXR?=dlog(XR?)”. The ? will be substituted by every cross-section

identifier. Plot the transformed variables.

3. Compute the medians of the variable I? for the different countries (use

View/descriptive statistics within the Pool object.) Compute now the average

value of I? for every year.

4. Estimate the regression model for Brazil, using “/Quick/estimate equation’

and specifying in Eviews the equation

dlog(rgdp bra) c dlog(pop bra) i bra g bra dlog(xr bra) open bra

5. Now we want to pool the data of all countries, to increase the sample size.

Use, within the pooled object, ‘/Estimate’, and specify: dependent

variable=dlog(rgdp?); common coefficients=c dlog(pop?) i? g? dlog(xr?)

open?. This is a pooled regression model.

5

Page 6: Panel Data for Learing

6. Pooling the data ignores the fact that the data originate from different

countries. Dummy variables for the different countries need to be added. This

can be done by specifying the constant term as a “cross section specific

coefficient.” We obtain a fixed effect panel data model. Discuss the

regression output.

7. The fixed effect panel data model assumes that the effect of openness is the

same of all countries. How could you relax this assumption?

8. Test whether all country effects are equal (to know how Eviews labels the

coefficients, use View/Representation), using a Wald test. The country

effects are called the fixed effects, and if there are significantly different then

there is unobserved heterogeneity.

6

Page 7: Panel Data for Learing

2 The Generalized Least Squares

estimator

Standard linear regression model:

Yi = X ′

iβ + εi (i = 1, . . . , n)

with

⋄ Var(εi) = σ2 is constant ⇒ homoscedastic errors

⋄ Cov(εi, εj) = 0 for i 6= j ⇒ uncorrelated errors

7

Page 8: Panel Data for Learing

At the standard model, the Ordinary Least Squares (OLS) estimator

is

⋄ Consistent, meaning that β → β for n tending to infinity.

⋄ Has the smallest variance among all estimators (for normal

errors) and smallest variance among all linear estimators.

One has that

βOLS =

(

n∑

i=1

XiX′

i

)

−1( n∑

i=1

XiYi

)

.

8

Page 9: Panel Data for Learing

What if the the errors are not homoscedastic and uncorrelated?

E.g. for panel data:

⋄ Cross-sectional heteroscedasticity

⋄ Correlation among cross sections

⋄ Serial correlation within and across cross-sections

⋄ ...

The Ordinary Least Squares (OLS) estimator is still consistent, but

not optimal anymore.

9

Page 10: Panel Data for Learing

General linear regression model:

Yi = X ′

iβ + εi (i = 1, . . . , n)

with

⋄ Var(εi) = σ2

i ⇒ heteroscedastic errors

⋄ Cov(εi, εj) = σij for i 6= j ⇒ correlated errors.

One can still use OLS (not even a bad idea), if one uses

⋄ White standard errors (if heteroscedasticity)

⋄ Newey-West standard errors (if correlated errors +

heteroscedasticity)

10

Page 11: Panel Data for Learing

The Generalized Least Squares (GLS) estimator will be consistent

and optimal and is given by

βGLS =

n∑

i=1

n∑

j=1

wijXiX′

j

−1

n∑

i=1

n∑

j=1

wijXiYj

,

where the weights depends on the values of σij.

More precisely: let Σ be the n × n matrix with elements σij, then

wij = (Σ−1)ij .

Unfortunately, the values in Σ are unknown.

11

Page 12: Panel Data for Learing

The Feasible Generalized Least Squares (GLS) proceeds in 2 steps:

1. Compute βOLS and the residuals

rOLSi = Yi − X ′

iβOLS .

2. Use the above residuals to estimate the σij. [This will require

some additional assumptions on the structure of Σ]

Compute then the GLS estimator with estimated weights wij.

The above scheme can be iterated → fully iterated GLS estimator.

12

Page 13: Panel Data for Learing

Theoretical Example

Our sample of size n = 20 consists of two groups of equal size (e.g.

men and women). There is no correlation among the observations,

but we think that the variances of the error terms for men and

women might be of different size.

[The error terms contains the omitted and unobserved variables. We

might indeed think that their size is different for women than for

men, e.g. when regressing salary on individual characteristics]

⋄ σ2

i = σii = σ2

M for i = 1, . . . , 10

⋄ σ2

i = σii = σ2

F for i = 11, . . . , 20

⋄ σij = 0 for i 6= j.

13

Page 14: Panel Data for Learing

Computation of the (Feasible) GLS estimator:

1. Compute the OLS estimator and the residuals rOLSi .

2. Estimate

σ2

M =1

10

10∑

i=1

(rOLSi )2 and σ2

F =1

10

20∑

i=11

(rOLSi )2.

Due to the simple structure of the matrix Σ, we have

wi =1

σ2

M

(i = 1, . . . , 10) and wi =1

σ2

F

(i = 11, . . . , 20)

⇒ βGLS =

(

n∑

i=1

wiXiX′

i

)

−1( n∑

i=1

wiXiYi

)

.

14

Page 15: Panel Data for Learing

Application to panel data regression

Let εit be the error term of a panel data regression model, with

1 ≤ i ≤ n, and 1 ≤ t ≤ T.

Three different specifications are common:

1. V ar(εit) = σ2 and all covariances between error terms are zero.

OLS can be applied (no weighting).

2. V ar(εit) = σ2

i and all covariances between error terms are zero.

We have cross-sectional heteroscedasticity. GLS can be applied

(cross-section weights):

3. V ar(εit) = σ2

i , Cov(εit, εjt) = σij, all other covariances zero. We

allow now for contemporaneous correlation between

cross-sections. GLS can be applied (SUR weights).

15

Page 16: Panel Data for Learing

Example South American (continued)

1. Have a look at the residuals (View/residuals/Graphs) within the

pool object). Compute the covariance and the correlation matrix

of the residuals (i) Is there cross-sectional heteroscedasticity?

(ii) Is there contemporaneous correlation?

2. Estimate now the model with the appropriate GLS estimator.

Are the results depending a lot on the weighting scheme?

3. Is there still serial correlation present in the residuals, i.e.

(cross)-correlation at leads and lags? Hence, is the model

capturing the dynamics in the data?

16

Page 17: Panel Data for Learing

3 The Fixed Effects regression model

Fixed effects Model:

Yit = X ′

itβ + αi + εit

with t = 1, . . . T time periods and i = 1 . . . , N cross-sectional units.

⋄ The αi contain the omitted variables, constant over time, for

every unit i.

⋄ The αi are called the fixed effects, and induce unobserved

heterogeneity in the model.

⋄ The Xit are the observed part of the heterogeneity. The εit

contain the remaining omitted variables.

17

Page 18: Panel Data for Learing

Testing for unobserved heterogeneity:

H0 : α1 = . . . = αN := α

(Test for redundant fixed effects)

In case H0 holds, there is no unobserved heterogeneity, and the model

reduces to the pooled regression model:

Yit = X ′

itβ + α + εit

Ignoring unobserved heterogeneity may lead to severe bias of the

estimated β, see figure:

18

Page 19: Panel Data for Learing

1 2 3 4 5 6 70

5

10

15

x

y

Pooled Regression

Cross Section 1

Cross Section 2

Cross Section 3

19

Page 20: Panel Data for Learing

LSDV estimation

LSDV=Least Squares Dummy Variable estimation

Rewrite the model as

Yit = α1D1

i + . . . + αnDni + X ′

itβ + εit,

with Dji = 1 if i = j and zero if i 6= j.

Estimate model by OLS or GLS (weighting).

If necessary, use White/Newey West type of Standard Errors (also if

GLS is used, see later).

20

Page 21: Panel Data for Learing

Within groups estimator

Compute averages of Xit and Yit within each “group” of

cross-sectional unit → Xi. and Yi.

Yit = X ′

itβ + αi + εit

Yi. = X ′

i.β + αi + εi.

⇒ (Yit − Yi.) = (Xit − Xi.)′β + (εit − εi.)

Regress the centered Yit on the centered Xit by OLS.

By centering, the fixed effects are eliminated !

One can show that the within group estimator is identical to LSDV.

21

Page 22: Panel Data for Learing

Comments

1. If a variable Xit is constant in time for all cross-sections, the FE

model cannot be estimated.

Why?

2. The fixed effects model can be rewritten with a common

intercept included as

Yit = X ′

itβ + α + µi + εit,

and

µ1 + µ2 + . . . + µN = 0.

Obviously, we have αi = α + µi, and α is the average of the fixed

effects.

22

Page 23: Panel Data for Learing

3. One can add time effects (or period effects) in the model:

Yit = X ′

itβ + αi + δt + εit,

The δt contain the omitted variables, constant over

cross-sections, at every time point t.

The time effects capture the business cycle.

23

Page 24: Panel Data for Learing

4. If we think that the cross-sectional units are an i.i.d. sample

(typical for micro-applications), but serial correlation or period

heteroscedasticity is present (within each unit), then OLS can be

made more precise/efficient:

(a) V ar(εit) = σ2

t and all covariances between error terms are zero.

We have period heteroscedasticity. GLS can be applied

(Period weights):

(b) V ar(εit) = σ2

t , Cov(εit, εis) = σts, all other covariances zero. We

allow for serial correlation. GLS can be applied (Period

weights).

24

Page 25: Panel Data for Learing

Example: Grunfeld data

We consider investment data for 10 American firms from 1935-1954,

and consider the model

INVit = βi1V ALit + βi2CAPit + αi + εit

for 1 ≤ i ≤ N = 10, and 1 ≤ t ≤ T = 20. The variables are

⋄ Gross investment for the firm (INV)

⋄ Value of the firm (VAL)

⋄ Real Value of the Capital stock (plant and equipment) (CAP)

The data are in the excel file “grunfeld2.xls.”

25

Page 26: Panel Data for Learing

1. Have a look at the data in the Excel File. Write up the number of

observations, the number of variables, and the upper left cell of the data

matrix. Close the Excel file, create an unstructured Workfile and read in the

data (Proc/Import/Read Text Lotus Excel).

2. To apply a panel structure, double click on the “Range:” line at the top of

the workfile window, or select Proc/Structure/Resize Current Page. Select

Dated Panel, and enter the appropriate variables as “Date Series” and as

“Cross Section ID series.”

3. Open the investment series. Explore the “Descriptive Statistics and tests

menu.”

26

Page 27: Panel Data for Learing

4. Use View/Graph to (i) Make a line plot of the time series for every cross

section (ii) Make boxplots of the distribution of investment over the different

cross sections and over time.

5. Use Quick/Estimate Equation to estimate the fixed effects model. Specify

the equation “inv c cap value” and use Panel Options to indicate that you use

fixed effects.

6. Interpret your outcome. Would it be useful to add period effects? Test

whether they this is necessary with View/Fixed Random Effects testing.

7. Select an appropriate weighting scheme within Panel Options. Interpret your

outcome.

27

Page 28: Panel Data for Learing

4 Random Effects model

Model

Yit = c + X ′

itβ + εit

where the error term is decomposed as

εit = αi + vit.

⋄ αi is a random effect ∼ N(0, σ2

α).

It is the permanent component of the error term.

⋄ vit a noise term ∼ N(0, σ2

v).

It is the idiosyncratic component of the error term.

28

Page 29: Panel Data for Learing

(The vit are uncorrelated among cross-sections, are serially

uncorrelated at all leads and lags, within and across cross sections.

The random effects are uncorrelated among cross-sections.)

• At the price of one extra parameter σ2

α, the random effects model

allows for correlation within cross-section units:

For every i and t 6= s:

Cov(εit, εis) = Cov(αi + vit, αi + vis) = σ2

α

• The following Variance decomposition holds:

Var(εit) = Var(αi + vit) = σ2

α + σ2

v .

29

Page 30: Panel Data for Learing

⇒ Within groups/cross sections correlation:

ρ = Corr(εit, εis) =σ2

α

σ2α + σ2

v

.

The larger the value of ρ, the more unobserved heterogeneity.

• One estimates β by Generalized Least Squares, and obtains the

RE-estimator.

Different methods are existing to make GLS feasible.

30

Page 31: Panel Data for Learing

• Testing for correlated random effects:

The random effect αi needs to be uncorrelated with the X-variables.

This is a strong assumption. If not, there is an endogeneity problem,

and the RE-estimator is inconsistent.

H0 : Corr(αi, Xit) = 0

The Hausman test compares two estimators: the FE (always

consistent) and the RE estimator (consistent under H0).

One rejects H0 if the difference between the two estimators is large.

31

Page 32: Panel Data for Learing

Using Fixed or random effects?

⋄ In econometrics, the fixed effects model seems to be the most

appropriate (HO not needed).

⋄ If N is large, and T is small, and the cross-sectional units are a

random sample from a population, then random effects model

becomes attractive:

It is a parsimonious model, that captures within

group-correlation.

(For N large, FE requires estimation of many parameters)

⋄ Random effects is popular for modeling grouped data:

(i) Sample of 1000 children coming from 30 different schools

(ii) Sample of 1000 persons from 20 different villages

...

32

Page 33: Panel Data for Learing

Robust Standard Errors: For RE no weighted versions are available.

Using robust standard errors (or coefficient covariance) might be

appropriate. This only affects the SE, not the estimators.

1. White cross section: robust to V ar(εit) = σ2

i and Cov(εit, εjt) = σij .

[robust to cross-section heteroscedasticity and contemporenous correlation

among cross sections; appropriate if N << T .]

2. White period: robust to V ar(εit) = σ2

t and Cov(εit, εis) = σts.

[robust to serial correlation within cross-section and changing variances over

time; appropriate if cross-sections are random sample and T << N .]

3. White diagonal: robust to V ar(εit) = σ2

it

[robust to all forms of heteroscedasticity, but not robust for any type of

correlation over time of across cross-section.]

Can also be used for FE.

33

Page 34: Panel Data for Learing

Exercise Consider the grunfeld data in “grundfeld2.wf1.” The

model was:

INVit = βi1V ALit + βi2CAPit + αi + εit

1. Estimate the model as a random effects model.

2. What is the “within-group” correlation?

3. Perform the Hausman test. (View/Fixed random effects

testing/Correlated random effects)

4. Compute different types of robust SE. How is this affecting the

results?

34