Top Banner
Management and analysis of panel data in economics and finance Christopher F Baum Boston College and DIW Berlin January 2009
120

Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Mar 20, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Management and analysis of panel data ineconomics and finance

Christopher F Baum

Boston College and DIW Berlin

January 2009

Page 2: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Panel or longitudinal data are widely available in many fields ofeconomics and finance. Econometric analysis using panel datacan make use of estimators which can yield results morepowerful than those available from pure cross-section ortime-series data.

However, with this power we face a number of challenges inhandling the data and dealing with additional econometricissues—such as unobserved heterogeneity—that must beproperly handled to provide consistent estimates.

In this lecture, we will touch upon some of these issues, anddiscuss hands-on solutions for some of the data managementissues that arise in the context of panel data.

Page 3: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Panel or longitudinal data are widely available in many fields ofeconomics and finance. Econometric analysis using panel datacan make use of estimators which can yield results morepowerful than those available from pure cross-section ortime-series data.

However, with this power we face a number of challenges inhandling the data and dealing with additional econometricissues—such as unobserved heterogeneity—that must beproperly handled to provide consistent estimates.

In this lecture, we will touch upon some of these issues, anddiscuss hands-on solutions for some of the data managementissues that arise in the context of panel data.

Page 4: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Panel or longitudinal data are widely available in many fields ofeconomics and finance. Econometric analysis using panel datacan make use of estimators which can yield results morepowerful than those available from pure cross-section ortime-series data.

However, with this power we face a number of challenges inhandling the data and dealing with additional econometricissues—such as unobserved heterogeneity—that must beproperly handled to provide consistent estimates.

In this lecture, we will touch upon some of these issues, anddiscuss hands-on solutions for some of the data managementissues that arise in the context of panel data.

Page 5: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The discussion that follows is presented in much greater detailin three sources:

I An Introduction to Modern Econometrics Using Stata,Baum, C.F., Stata Press, 2006 (particularly Chapter 8).

I An Introduction to Stata Programming. Baum, C.F., StataPress, 2009.

I How to do xtabond2. Roodman, D. Forthcoming, StataJournal.http://ideas.repec.org/p/boc/asug06/8.html

Page 6: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The discussion that follows is presented in much greater detailin three sources:

I An Introduction to Modern Econometrics Using Stata,Baum, C.F., Stata Press, 2006 (particularly Chapter 8).

I An Introduction to Stata Programming. Baum, C.F., StataPress, 2009.

I How to do xtabond2. Roodman, D. Forthcoming, StataJournal.http://ideas.repec.org/p/boc/asug06/8.html

Page 7: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The discussion that follows is presented in much greater detailin three sources:

I An Introduction to Modern Econometrics Using Stata,Baum, C.F., Stata Press, 2006 (particularly Chapter 8).

I An Introduction to Stata Programming. Baum, C.F., StataPress, 2009.

I How to do xtabond2. Roodman, D. Forthcoming, StataJournal.http://ideas.repec.org/p/boc/asug06/8.html

Page 8: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Forms of panel data

To define the problems of data management, consider adataset in which we have k variables each with T time-seriesobservations. The second dimension of panel data need not becalendar time, but many estimation techniques assume that itcan be treated as such, so that operations such as firstdifferencing make sense.

These data may be commonly stored in either the long form orthe wide form, in Stata parlance. In the long form, eachobservation has both an i and t subscript.

Page 9: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Forms of panel data

To define the problems of data management, consider adataset in which we have k variables each with T time-seriesobservations. The second dimension of panel data need not becalendar time, but many estimation techniques assume that itcan be treated as such, so that operations such as firstdifferencing make sense.

These data may be commonly stored in either the long form orthe wide form, in Stata parlance. In the long form, eachobservation has both an i and t subscript.

Page 10: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Long form data:

. list, noobs sepby(state)

state year pop

CT 1990 3291967CT 1995 3324144CT 2000 3411750

MA 1990 6022639MA 1995 6141445MA 2000 6362076

RI 1990 1005995RI 1995 1017002RI 2000 1050664

Page 11: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

However, you often encounter data in the wide form, in whichdifferent variables (or columns of the data matrix) refer todifferent time periods.

Wide form data:

. list, noobs

state pop1990 pop1995 pop2000

CT 3291967 3324144 3411750MA 6022639 6141445 6362076RI 1005995 1017002 1050664

In a variant on this theme, the wide form data could also indexthe observations by the time period, and have the samemeasurement for different units stored in different variables.

Page 12: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

However, you often encounter data in the wide form, in whichdifferent variables (or columns of the data matrix) refer todifferent time periods.

Wide form data:

. list, noobs

state pop1990 pop1995 pop2000

CT 3291967 3324144 3411750MA 6022639 6141445 6362076RI 1005995 1017002 1050664

In a variant on this theme, the wide form data could also indexthe observations by the time period, and have the samemeasurement for different units stored in different variables.

Page 13: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

However, you often encounter data in the wide form, in whichdifferent variables (or columns of the data matrix) refer todifferent time periods.

Wide form data:

. list, noobs

state pop1990 pop1995 pop2000

CT 3291967 3324144 3411750MA 6022639 6141445 6362076RI 1005995 1017002 1050664

In a variant on this theme, the wide form data could also indexthe observations by the time period, and have the samemeasurement for different units stored in different variables.

Page 14: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The former kind of wide-form data, where time periods arearrayed across the columns, is often found in spreadsheets oron-line data sources.

These examples illustrate a balanced panel, where each unit isrepresented in each time period. That is often not available, asdifferent units may enter and leave the sample in differentperiods (companies may start operations or liquidate,household members may die, etc.) In those cases, we mustdeal with unbalanced panels. Stata’s data transformationcommands are uniquely handy in that context.

Page 15: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The former kind of wide-form data, where time periods arearrayed across the columns, is often found in spreadsheets oron-line data sources.

These examples illustrate a balanced panel, where each unit isrepresented in each time period. That is often not available, asdifferent units may enter and leave the sample in differentperiods (companies may start operations or liquidate,household members may die, etc.) In those cases, we mustdeal with unbalanced panels. Stata’s data transformationcommands are uniquely handy in that context.

Page 16: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Data management for panel data

The data management challenge: for most purposes of datatransformation, estimation and graphing, data are more easilyused in the long form. Stata constructs such as the by-grouprequire that we have the data stored that way. So if we havewide form data, how do we get there from here?

Page 17: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The solution to this problem is Stata’s reshape command, animmensely powerful tool for reformulating a dataset in memorywithout recourse to external files. In statistical packages lackinga data-reshape feature, common practice entails writing thedata to one or more external text files and reading it back in.With the proper use of reshape, this is not necessary in Stata.But reshape requires, first of all, that the data to be reshapedare labelled in such a way that they can be handled by themechanical rules that the command applies. In situationsbeyond the simple application of reshape, it may require someexperimentation to construct the appropriate command syntax.This is all the more reason for enshrining that code in a do-fileas some day you are likely to come upon a similar applicationfor reshape.

Page 18: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The reshape command works with the notion of xi,j data. Itssyntax lists the variables to be stacked up, and specifies the iand j variables, where the i variable indexes the rows and the jvariable indexes the columns in the existing form of the data. Ifwe have a dataset in the wide form, with time periodsincorporated in the variable names, we could use

. reshape long expp revpp avgsal math4score math7score, i(distid) j(year)(note: j = 1992 1994 1996 1998)

Data wide -> long

Number of obs. 550 -> 2200Number of variables 21 -> 7j variable (4 values) -> yearxij variables:

expp1992 expp1994 ... expp1998 -> expprevpp1992 revpp1994 ... revpp1998 -> revpp

avgsal1992 avgsal1994 ... avgsal1998 -> avgsalmath4score1992 math4score1994 ... math4score1998->math4scoremath7score1992 math7score1994 ... math7score1998->math7score

Page 19: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

You use reshape long because the data are in the wide formand we want to place them in the long form. You provide thevariable names to be stacked without their common suffixes: inthis case, the year embedded in their wide-form variablename. The i variable is distid and the j variable is year:together, those variables uniquely identify each measurement.Stata’s description of reshape speaks of i defining a uniqueobservation and j defining a subobservation logically related tothat observation. Any additional variables that do not vary overj are not specified in the reshape statement, as they will beautomatically replicated for each j .

Page 20: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

What if you wanted to reverse the process, and translate thedata from the long to the wide form?

. reshape wide expp revpp avgsal math4score math7score, i(distid) j(year)(note: j = 1992 1994 1996 1998)

Data long -> wide

Number of obs. 2200 -> 550Number of variables 7 -> 21j variable (4 values) year -> (dropped)xij variables:

expp -> expp1992 expp1994 ... expp1998revpp -> revpp1992 revpp1994 ... revpp199

> 8avgsal -> avgsal1992 avgsal1994 ... avgsal

> 1998math4score -> math4score1992 math4score1994 ..

> . math4score1998math7score -> math7score1992 math7score1994 ..

> . math7score1998

Page 21: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

What if you wanted to reverse the process, and translate thedata from the long to the wide form?

. reshape wide expp revpp avgsal math4score math7score, i(distid) j(year)(note: j = 1992 1994 1996 1998)

Data long -> wide

Number of obs. 2200 -> 550Number of variables 7 -> 21j variable (4 values) year -> (dropped)xij variables:

expp -> expp1992 expp1994 ... expp1998revpp -> revpp1992 revpp1994 ... revpp199

> 8avgsal -> avgsal1992 avgsal1994 ... avgsal

> 1998math4score -> math4score1992 math4score1994 ..

> . math4score1998math7score -> math7score1992 math7score1994 ..

> . math7score1998

Page 22: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

This example highlights the importance of having appropriatevariable names for reshape. If our wide-form datasetcontained the variables expp1992, Expen94, xpend_96and expstu1998 there would be no way to specify thecommon stub labeling the choices. However, one commoncase can be handled without the renaming of variables. Saythat we have the variables exp92pp, exp94pp, exp96pp,exp98pp. The command

reshape long exp@pp, i(distid) j(year)

will deal with that case, with the @ as a placeholder for thelocation of the j component of the variable name.

Page 23: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

This discussion has only scratched the surface of reshape’scapabilities. There is no substitute for experimentation with thiscommand after a careful perusal of help reshape, as it isone of the most complicated elements of Stata.

When working with panel data, we also must considercombining datasets, as often data are available for one panel ata time (for instance, cross-sectional information on the 100largest companies at each year-end). In this next section, wetake up that issue.

Page 24: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

This discussion has only scratched the surface of reshape’scapabilities. There is no substitute for experimentation with thiscommand after a careful perusal of help reshape, as it isone of the most complicated elements of Stata.

When working with panel data, we also must considercombining datasets, as often data are available for one panel ata time (for instance, cross-sectional information on the 100largest companies at each year-end). In this next section, wetake up that issue.

Page 25: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Combining datasets

You may be aware that Stata can only work with one dataset ata time. How, then, do you combine datasets in Stata? First ofall, it is important to understand that at least one of the datasetsto be combined must already have been saved in Stata format.Second, you should realize that each of Stata’s commands forcombining datasets provides a certain functionality, whichshould not confused with that of other commands.

For instance, consider the append command with two stylizeddatasets:

Page 26: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Combining datasets

You may be aware that Stata can only work with one dataset ata time. How, then, do you combine datasets in Stata? First ofall, it is important to understand that at least one of the datasetsto be combined must already have been saved in Stata format.Second, you should realize that each of Stata’s commands forcombining datasets provides a certain functionality, whichshould not confused with that of other commands.

For instance, consider the append command with two stylizeddatasets:

Page 27: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

dataset1 :

id var1 var2

112...

...

216...

...

449...

...

dataset2 :

id var1 var2

126...

...

309...

...

421...

...

604...

...

Page 28: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

These two datasets contain the same variables, as they mustfor append to sensibly combine them. If dataset2 containedidcode, Var1, Var2 the two datasets could not sensibly beappended without renaming the variables.1 Appending thesetwo datasets with common variable names creates a singledataset containing all of the observations:

1Recall that in Stata var1 and Var1 are two separate variables.

Page 29: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

combined :

id var1 var2

112...

...

216...

...

449...

...

126...

...

309...

...

421...

...

604...

...

The rule for append, then, is that if datasets are to becombined, they should share the same variable names anddatatypes (string vs. numeric). In the above example, if var1 indataset1 was a float while that variable in dataset2 wasa string variable, they could not be appended.

Page 30: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

combined :

id var1 var2

112...

...

216...

...

449...

...

126...

...

309...

...

421...

...

604...

...

The rule for append, then, is that if datasets are to becombined, they should share the same variable names anddatatypes (string vs. numeric). In the above example, if var1 indataset1 was a float while that variable in dataset2 wasa string variable, they could not be appended.

Page 31: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

It is permissible to append two datasets with differing variablenames in the sense that dataset2 could also contain anadditional variable or variables (for example, var3, var4).The values of those variables in the observations coming fromdataset1 would then be set to missing.

While append combines datasets by adding observations tothe existing variables, the other key command, mergecombines variables for the existing observations.

Page 32: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

It is permissible to append two datasets with differing variablenames in the sense that dataset2 could also contain anadditional variable or variables (for example, var3, var4).The values of those variables in the observations coming fromdataset1 would then be set to missing.

While append combines datasets by adding observations tothe existing variables, the other key command, mergecombines variables for the existing observations.

Page 33: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Consider these two stylized datasets:

dataset1 :

id var1 var2

112...

...

216...

...

449...

...

dataset3 :

id var22 var44 var46

112...

......

216...

......

449...

......

Page 34: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

We may merge these datasets on the common merge key: inthis case, the id variable:

combined :

id var1 var2 var22 var44 var46

112...

......

......

216...

......

......

449...

......

......

Page 35: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The rule for merge, then, is that if datasets are to be combinedon one or more merge keys, they each must have one or morevariables with a common name and datatype (string vs.numeric). In the example above, each dataset must have avariable named id. That variable can be numeric or string, butthat characteristic of the merge key variables must matchacross the datasets to be merged. Of course, we need not haveexactly the same observations in each dataset: if dataset3contained observations with additional id values, thoseobservations would be merged with missing values for var1and var2.

This is the simplest kind of merge: the one-to-one merge. Statasupports several other types of merges. But the key conceptshould be clear: the merge command combines datasets“horizontally”, adding variables’ values to existing observations.

Page 36: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The rule for merge, then, is that if datasets are to be combinedon one or more merge keys, they each must have one or morevariables with a common name and datatype (string vs.numeric). In the example above, each dataset must have avariable named id. That variable can be numeric or string, butthat characteristic of the merge key variables must matchacross the datasets to be merged. Of course, we need not haveexactly the same observations in each dataset: if dataset3contained observations with additional id values, thoseobservations would be merged with missing values for var1and var2.

This is the simplest kind of merge: the one-to-one merge. Statasupports several other types of merges. But the key conceptshould be clear: the merge command combines datasets“horizontally”, adding variables’ values to existing observations.

Page 37: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The long-form dataset is very useful if you want to addaggregate-level information to individual records. For instance,we may have panel data for a number of companies for severalyears. We may want to attach various macro indicators (interestrate, GDP growth rate, etc.) that vary by year but not bycompany. We would place those macro variables into adataset, indexed by year, and sort it by year.

We could then use the firm-level panel dataset and sort it byyear. A merge command can then add the appropriate macrovariables to each instance of year. This use of merge isknown as a one-to-many match merge, where the yearvariable is the merge key.

Note that the merge key may contain several variables: wemight have information specific to industry and year that shouldbe merged onto each firm’s observations.

Page 38: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The long-form dataset is very useful if you want to addaggregate-level information to individual records. For instance,we may have panel data for a number of companies for severalyears. We may want to attach various macro indicators (interestrate, GDP growth rate, etc.) that vary by year but not bycompany. We would place those macro variables into adataset, indexed by year, and sort it by year.

We could then use the firm-level panel dataset and sort it byyear. A merge command can then add the appropriate macrovariables to each instance of year. This use of merge isknown as a one-to-many match merge, where the yearvariable is the merge key.

Note that the merge key may contain several variables: wemight have information specific to industry and year that shouldbe merged onto each firm’s observations.

Page 39: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The long-form dataset is very useful if you want to addaggregate-level information to individual records. For instance,we may have panel data for a number of companies for severalyears. We may want to attach various macro indicators (interestrate, GDP growth rate, etc.) that vary by year but not bycompany. We would place those macro variables into adataset, indexed by year, and sort it by year.

We could then use the firm-level panel dataset and sort it byyear. A merge command can then add the appropriate macrovariables to each instance of year. This use of merge isknown as a one-to-many match merge, where the yearvariable is the merge key.

Note that the merge key may contain several variables: wemight have information specific to industry and year that shouldbe merged onto each firm’s observations.

Page 40: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

By default, merge creates a new variable _merge, which takeson integer values for each observation of 1 if that observationwas only found in the master dataset, 2 if it was only found inthe using dataset, or 3 if it was found in both datasets. In thiscase, we expect that tab _merge should reveal that all valuesequal 3. We can also use the uniqusing option to ensure thatthere are no duplicate values of year in the using file, as aduplicate value of distid must be a data entry error. If thesame year mistakenly appears on two records in the using file,asserting uniqusing will cause merge to fail.

You may also use a uniqmaster option, where the master fileshould contain only one record for the merge key (which mayinclude several variables), or the unique option in the case ofthe one-to-one merge where there should be a perfect matchbetween the two files.

Page 41: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

By default, merge creates a new variable _merge, which takeson integer values for each observation of 1 if that observationwas only found in the master dataset, 2 if it was only found inthe using dataset, or 3 if it was found in both datasets. In thiscase, we expect that tab _merge should reveal that all valuesequal 3. We can also use the uniqusing option to ensure thatthere are no duplicate values of year in the using file, as aduplicate value of distid must be a data entry error. If thesame year mistakenly appears on two records in the using file,asserting uniqusing will cause merge to fail.

You may also use a uniqmaster option, where the master fileshould contain only one record for the merge key (which mayinclude several variables), or the unique option in the case ofthe one-to-one merge where there should be a perfect matchbetween the two files.

Page 42: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

In your particular application, you may find that _merge valuesof 1 or 2 are appropriate. The key notion is that you shouldalways tabulate _merge and consider whether the results ofthe merge are sensible in the context of your work. It is anexcellent idea to use the uniqmaster, uniqusing or uniqueoptions on the merge command whenever those conditionsshould logically be satisfied in your data.

In comparison with a lengthy and complicated do-file using aset of replace statements, the merge technique is far better.This technique proves exceedingly useful when working withindividual data and panel data where we have aggregateinformation to be combined with the individual-level data.

Page 43: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

In your particular application, you may find that _merge valuesof 1 or 2 are appropriate. The key notion is that you shouldalways tabulate _merge and consider whether the results ofthe merge are sensible in the context of your work. It is anexcellent idea to use the uniqmaster, uniqusing or uniqueoptions on the merge command whenever those conditionsshould logically be satisfied in your data.

In comparison with a lengthy and complicated do-file using aset of replace statements, the merge technique is far better.This technique proves exceedingly useful when working withindividual data and panel data where we have aggregateinformation to be combined with the individual-level data.

Page 44: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

There are very good reasons to employ a one-to-many merge,as we did above with macro variables, or its inverse: amany-to-one merge, which would essentially reverse the rolesof the master and using datasets. But there is a great danger instumbling into the alternative to the one-to-many or one-to-onemerge: the many-to-many merge. This problem arises whenthere are multiple observations in both datasets for somevalues of the merge key variable(s).

Page 45: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The result of match-merging two datasets which both havemore than one value of the merge key variable(s) isunpredictable, as it depends on the sort order of the datasets.This leads to the seemingly illogical result that repeatedexecution of the same do-file will most likely result in a differentnumber of cases in the result dataset without any errorindication. There is no unique outcome for a many-to-manymerge. When it is encountered it usually results from a codingerror in one of the files.

Stata’s duplicates command is very useful in tracking downsuch errors. To prevent such difficulties in employing merge,you should specify either the uniqmaster or the uniqusingoption in a match merge. If no uniq. . . option is used,observations may be matched inappropriately.

Page 46: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The result of match-merging two datasets which both havemore than one value of the merge key variable(s) isunpredictable, as it depends on the sort order of the datasets.This leads to the seemingly illogical result that repeatedexecution of the same do-file will most likely result in a differentnumber of cases in the result dataset without any errorindication. There is no unique outcome for a many-to-manymerge. When it is encountered it usually results from a codingerror in one of the files.

Stata’s duplicates command is very useful in tracking downsuch errors. To prevent such difficulties in employing merge,you should specify either the uniqmaster or the uniqusingoption in a match merge. If no uniq. . . option is used,observations may be matched inappropriately.

Page 47: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Estimation for panel data

We first consider estimation of models that satisfy the zeroconditional mean assumption for OLS regression: that is, theconditional mean of the error process, conditioned on theregressors, is zero. This does not rule out non-i .i .d . errors, butit does rule out endogeneity of the regressors and, generally,the presence of lagged dependent variables. We will deal withthese exceptions later.

The most commonly employed model for panel data, the fixedeffects estimator, addresses the issue that no matter how manyindividual-specific factors you may include in the regressor list,there may be unobserved heterogeneity in a pooled OLSmodel. This will generally cause OLS estimates to be biasedand inconsistent.

Page 48: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Estimation for panel data

We first consider estimation of models that satisfy the zeroconditional mean assumption for OLS regression: that is, theconditional mean of the error process, conditioned on theregressors, is zero. This does not rule out non-i .i .d . errors, butit does rule out endogeneity of the regressors and, generally,the presence of lagged dependent variables. We will deal withthese exceptions later.

The most commonly employed model for panel data, the fixedeffects estimator, addresses the issue that no matter how manyindividual-specific factors you may include in the regressor list,there may be unobserved heterogeneity in a pooled OLSmodel. This will generally cause OLS estimates to be biasedand inconsistent.

Page 49: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Given longitudinal data y X , each element of which has twosubscripts: the unit identifier i and the time identifier t , we maydefine a number of models that arise from the most generallinear representation:

yit =K∑

k=1

Xkitβkit + εit , i = 1, N, t = 1, T (1)

Assume a balanced panel of N × T observations. Since thismodel contains K × N × T regression coefficients, it cannot beestimated from the data. We could ignore the nature of thepanel data and apply pooled ordinary least squares,pooledOLS which would assume that βkit = βk ∀ k , i , t , but that modelmight be viewed as overly restrictive and is likely to have a verycomplicated error process (e.g., heteroskedasticity acrosspanel units, serial correlation within panel units, and so forth).Thus the pooled OLS solution is not often considered to bepractical.

Page 50: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Given longitudinal data y X , each element of which has twosubscripts: the unit identifier i and the time identifier t , we maydefine a number of models that arise from the most generallinear representation:

yit =K∑

k=1

Xkitβkit + εit , i = 1, N, t = 1, T (1)

Assume a balanced panel of N × T observations. Since thismodel contains K × N × T regression coefficients, it cannot beestimated from the data. We could ignore the nature of thepanel data and apply pooled ordinary least squares,pooledOLS which would assume that βkit = βk ∀ k , i , t , but that modelmight be viewed as overly restrictive and is likely to have a verycomplicated error process (e.g., heteroskedasticity acrosspanel units, serial correlation within panel units, and so forth).Thus the pooled OLS solution is not often considered to bepractical.

Page 51: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

One set of panel data estimators allow for heterogeneity acrosspanel units (and possibly across time), but confine thatheterogeneity to the intercept terms of the relationship. Thesetechniques, the fixed effects and random effects models, weconsider below. They impose restrictions on the model aboveof βkit = βk ∀i , t , k > 1, assuming that β1 refers to the constantterm in the relationship.

Page 52: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

An alternative technique which may be applied to “small N,large T ” panels is the method of seemingly unrelatedregressions or SURE. The “small N, large T ” setting refers tothe notion that we have a relatively small number of panel units,each with a lengthy time series: for instance, financial variablesof the ten largest U.S. manufacturing firms, observed over thelast 40 calendar quarters. The SURE technique (implementedin Stata as sureg) requires that the number of time periodsexceeds the number of cross-sectional units.

Page 53: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The general structure above may be restricted to allow forheterogeneity across units without the full generality (andinfeasibility) that this equation implies. In particular, we mightrestrict the slope coefficients to be constant over both units andtime, and allow for an intercept coefficient that varies by unit orby time. For a given observation, an intercept varying over unitsresults in the structure:

yit =K∑

k=2

Xkitβk + ui + εit (2)

Page 54: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

There are two interpretations of ui in this context: as aparameter to be estimated in the model (a so-called fixedeffect) or alternatively, as a component of the disturbanceprocess, giving rise to a composite error term [ui + εit ]: aso-called random effect. Under either interpretation, ui is takenas a random variable.

If we treat it as a fixed effect, we assume that the ui may becorrelated with some of the regressors in the model. Thefixed-effects estimator removes the fixed-effects parametersfrom the estimator to cope with this incidental parameterproblem, which implies that all inference is conditional on thefixed effects in the sample. Use of the random effects modelimplies additional orthogonality conditions—that the ui are notcorrelated with the regressors—and yields inference about theunderlying population that is not conditional on the fixed effectsin our sample.

Page 55: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

There are two interpretations of ui in this context: as aparameter to be estimated in the model (a so-called fixedeffect) or alternatively, as a component of the disturbanceprocess, giving rise to a composite error term [ui + εit ]: aso-called random effect. Under either interpretation, ui is takenas a random variable.

If we treat it as a fixed effect, we assume that the ui may becorrelated with some of the regressors in the model. Thefixed-effects estimator removes the fixed-effects parametersfrom the estimator to cope with this incidental parameterproblem, which implies that all inference is conditional on thefixed effects in the sample. Use of the random effects modelimplies additional orthogonality conditions—that the ui are notcorrelated with the regressors—and yields inference about theunderlying population that is not conditional on the fixed effectsin our sample.

Page 56: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

We could treat a time-varying intercept term similarly: as eithera fixed effect (giving rise to an additional coefficient) or as acomponent of a composite error term. We concentrate here onso-called one-way fixed (random) effects models in which onlythe individual effect is considered in the “large N, small T ”context most commonly found in economic and financialresearch. Stata’s set of xt commands include those whichextend these panel data models in a variety of ways. For moreinformation, see help xt.

Page 57: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

One-way fixed effects: the within estimator

Rewrite the equation to express the individual effect ui as

yit = X ∗it β

∗ + Ziα + εit (3)

In this context, the X ∗ matrix does not contain a units vector.The heterogeneity or individual effect is captured by Z , whichcontains a constant term and possibly a number of otherindividual-specific factors. Likewise, β∗ contains β2 . . . βK fromthe equation above, constrained to be equal over i and t . If Zcontains only a units vector, then pooled OLS is a consistentand efficient estimator of [β∗ α]. However, it will often be thecase that there are additional factors specific to the individualunit that must be taken into account, and omitting thosevariables from Z will cause the equation to be misspecified.

Page 58: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The fixed effects model deals with this problem by relaxing theassumption that the regression function is constant over timeand space in a very modest way. A one-way fixed effects modelpermits each cross-sectional unit to have its own constant termwhile the slope estimates (β∗) are constrained across units, asis the σ2

ε . This estimator is often termed the LSDV(least-squares dummy variable) model, since it is equivalent toincluding (N − 1) dummy variables in the OLS regression of yon X (including a units vector). The LSDV model may bewritten in matrix form as:

y = Xβ + Dα + ε (4)

where D is a NT ×N matrix of dummy variables di (assuming abalanced panel of N × T observations).

Page 59: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The model has (K − 1) + N parameters (recalling that the β∗

coefficients are all slopes) and when this number is too large topermit estimation, we rewrite the least squares solution as

b = (X ′MDX )−1(X ′MDy) (5)

whereMD = I − D(D′D)−1D′ (6)

is an idempotent matrix which is block–diagonal inM0 = IT − T−1ιι′ (ι a T –element units vector).

Premultiplying any data vector by M0 performs the demeaningtransformation: if we have a T–vector Zi , M0Zi = Zi − Zi ι. Theregression above estimates the slopes by the projection ofdemeaned y on demeaned X without a constant term.

Page 60: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The model has (K − 1) + N parameters (recalling that the β∗

coefficients are all slopes) and when this number is too large topermit estimation, we rewrite the least squares solution as

b = (X ′MDX )−1(X ′MDy) (5)

whereMD = I − D(D′D)−1D′ (6)

is an idempotent matrix which is block–diagonal inM0 = IT − T−1ιι′ (ι a T –element units vector).

Premultiplying any data vector by M0 performs the demeaningtransformation: if we have a T–vector Zi , M0Zi = Zi − Zi ι. Theregression above estimates the slopes by the projection ofdemeaned y on demeaned X without a constant term.

Page 61: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The estimates ai may be recovered from ai = yi − b′Xi , sincefor each unit, the regression surface passes through that unit’smultivariate point of means. This is a generalization of the OLSresult that in a model with a constant term the regressionsurface passes through the entire sample’s multivariate point ofmeans.

The large-sample VCE of b is s2[X ′MDX ]−1, with s2 based onthe least squares residuals, but taking the proper degrees offreedom into account: NT − N − (K − 1).

Page 62: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The estimates ai may be recovered from ai = yi − b′Xi , sincefor each unit, the regression surface passes through that unit’smultivariate point of means. This is a generalization of the OLSresult that in a model with a constant term the regressionsurface passes through the entire sample’s multivariate point ofmeans.

The large-sample VCE of b is s2[X ′MDX ]−1, with s2 based onthe least squares residuals, but taking the proper degrees offreedom into account: NT − N − (K − 1).

Page 63: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

This model will have explanatory power if and only if thevariation of the individual’s y above or below the individual’smean is significantly correlated with the variation of theindividual’s X values above or below the individual’s vector ofmean X values. For that reason, it is termed the withinestimator, since it depends on the variation within the unit.

It does not matter if some individuals have, e.g., very high yvalues and very high X values, since it is only the withinvariation that will show up as explanatory power. This is thepanel analogue to the notion that OLS on a cross-section doesnot seek to “explain” the mean of y , but only the variationaround that mean.

Page 64: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

This model will have explanatory power if and only if thevariation of the individual’s y above or below the individual’smean is significantly correlated with the variation of theindividual’s X values above or below the individual’s vector ofmean X values. For that reason, it is termed the withinestimator, since it depends on the variation within the unit.

It does not matter if some individuals have, e.g., very high yvalues and very high X values, since it is only the withinvariation that will show up as explanatory power. This is thepanel analogue to the notion that OLS on a cross-section doesnot seek to “explain” the mean of y , but only the variationaround that mean.

Page 65: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

This has the clear implication that any characteristic whichdoes not vary over time for each unit cannot be included in themodel: for instance, an individual’s gender, or a firm’sthree-digit SIC (industry) code. The unit-specific intercept termabsorbs all heterogeneity in y and X that is a function of theidentity of the unit, and any variable constant over time for eachunit will be perfectly collinear with the unit’s indicator variable.

Page 66: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The one-way individual fixed effects model may be estimatedby the Stata command [XT] xtreg using the fe (fixed effects)option. The command has a syntax similar to regress:

xtreg depvar indepvars, fe [options]

As with standard regression, options include robust andcluster(). The command output displays estimates of σ2

u(labeled sigma_u), σ2

ε (labeled sigma_e), and what Stataterms rho: the fraction of variance due to ui . Stata estimates amodel in which the ui of Equation (2) are taken as deviationsfrom a single constant term, displayed as _cons; thereforetesting that all ui are zero is equivalent in our notation to testingthat all αi are identical. The empirical correlation between uiand the regressors in X ∗ is also displayed as corr(u_i, Xb).

Page 67: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The one-way individual fixed effects model may be estimatedby the Stata command [XT] xtreg using the fe (fixed effects)option. The command has a syntax similar to regress:

xtreg depvar indepvars, fe [options]

As with standard regression, options include robust andcluster(). The command output displays estimates of σ2

u(labeled sigma_u), σ2

ε (labeled sigma_e), and what Stataterms rho: the fraction of variance due to ui . Stata estimates amodel in which the ui of Equation (2) are taken as deviationsfrom a single constant term, displayed as _cons; thereforetesting that all ui are zero is equivalent in our notation to testingthat all αi are identical. The empirical correlation between uiand the regressors in X ∗ is also displayed as corr(u_i, Xb).

Page 68: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The fixed effects estimator does not require a balanced panel.As long as there are at least two observations per unit, it maybe applied. However, since the individual fixed effect is inessence estimated from the observations of each unit, theprecision of that effect (and the resulting slope estimates) willdepend on Ni .

We wish to test whether the individual-specific heterogeneity ofαi is necessary: are there distinguishable intercept termsacross units? xtreg,fe provides an F -test of the nullhypothesis that the constant terms are equal across units. Ifthis null is rejected, pooled OLS would represent a misspecifiedmodel. The one-way fixed effects model also assumes that theerrors are not contemporaneously correlated across units of thepanel. This hypothesis can be tested (provided T > N) by theLagrange multiplier test of Breusch and Pagan, available as theauthor’s xttest2 routine (findit xttest2).

Page 69: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The fixed effects estimator does not require a balanced panel.As long as there are at least two observations per unit, it maybe applied. However, since the individual fixed effect is inessence estimated from the observations of each unit, theprecision of that effect (and the resulting slope estimates) willdepend on Ni .

We wish to test whether the individual-specific heterogeneity ofαi is necessary: are there distinguishable intercept termsacross units? xtreg,fe provides an F -test of the nullhypothesis that the constant terms are equal across units. Ifthis null is rejected, pooled OLS would represent a misspecifiedmodel. The one-way fixed effects model also assumes that theerrors are not contemporaneously correlated across units of thepanel. This hypothesis can be tested (provided T > N) by theLagrange multiplier test of Breusch and Pagan, available as theauthor’s xttest2 routine (findit xttest2).

Page 70: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

We have considered one-way fixed effects models, where theeffect is attached to the individual. We may also define atwo-way fixed effect model, where effects are attached to eachunit and time period. Stata lacks a command to estimatetwo-way fixed effects models. If the number of time periods isreasonably small, you may estimate a two-way FE model bycreating a set of time indicator variables and including all butone in the regression.

The joint test that all of the coefficients on those indicatorvariables are zero will be a test of the significance of time fixedeffects. Just as the individual fixed effects (LSDV) modelrequires regressors’ variation over time within each unit, a timefixed effect (implemented with a time indicator variable) requiresregressors’ variation over units within each time period. If weare estimating an equation from individual or firm microdata,this implies that we cannot include a “macro factor” such as therate of GDP growth or price inflation in a model with time fixedeffects, since those factors do not vary across individuals.

Page 71: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

We have considered one-way fixed effects models, where theeffect is attached to the individual. We may also define atwo-way fixed effect model, where effects are attached to eachunit and time period. Stata lacks a command to estimatetwo-way fixed effects models. If the number of time periods isreasonably small, you may estimate a two-way FE model bycreating a set of time indicator variables and including all butone in the regression.

The joint test that all of the coefficients on those indicatorvariables are zero will be a test of the significance of time fixedeffects. Just as the individual fixed effects (LSDV) modelrequires regressors’ variation over time within each unit, a timefixed effect (implemented with a time indicator variable) requiresregressors’ variation over units within each time period. If weare estimating an equation from individual or firm microdata,this implies that we cannot include a “macro factor” such as therate of GDP growth or price inflation in a model with time fixedeffects, since those factors do not vary across individuals.

Page 72: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The between estimator

Another estimator that may be defined for a panel data set isthe between estimator, in which the group means of y areregressed on the group means of X in a regression of Nobservations. This estimator ignores all of theindividual-specific variation in y and X that is considered by thewithin estimator, replacing each observation for an individualwith their mean behavior. This estimator is not widely used, buthas sometimes been applied where the time series data foreach individual are thought to be somewhat inaccurate, orwhen they are assumed to contain random deviations fromlong-run means. If you assume that the inaccuracy has meanzero over time, a solution to this measurement error problemcan be found by averaging the data over time and retaining onlyone observation per unit.

Page 73: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

This could be done explicitly with Stata’s collapse command.However, you need not form that data set to employ thebetween estimator, since the command xtreg with the be(between) option will invoke it. Use of the between estimatorrequires that N > K . Any macro factor that is constant overindividuals cannot be included in the between estimator, sinceits average will not differ by individual.

We can show that the pooled OLS estimator is a matrixweighted average of the within and between estimators, withthe weights defined by the relative precision of the twoestimators. We might ask, in the context of panel data: whereare the interesting sources of variation? In individuals’ variationaround their means, or in those means themselves? The withinestimator takes account of only the former, whereas thebetween estimator considers only the latter.

Page 74: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

This could be done explicitly with Stata’s collapse command.However, you need not form that data set to employ thebetween estimator, since the command xtreg with the be(between) option will invoke it. Use of the between estimatorrequires that N > K . Any macro factor that is constant overindividuals cannot be included in the between estimator, sinceits average will not differ by individual.

We can show that the pooled OLS estimator is a matrixweighted average of the within and between estimators, withthe weights defined by the relative precision of the twoestimators. We might ask, in the context of panel data: whereare the interesting sources of variation? In individuals’ variationaround their means, or in those means themselves? The withinestimator takes account of only the former, whereas thebetween estimator considers only the latter.

Page 75: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The random effects estimator

As an alternative to considering the individual-specific interceptas a “fixed effect” of that unit, we might consider that theindividual effect may be viewed as a random draw from adistribution:

yit = X ∗it β

∗ + [ui + εit ] (7)

where the bracketed expression is a composite error term, withthe ui being a single draw per unit. This model could beconsistently estimated by OLS or by the between estimator, butthat would be inefficient in not taking the nature of thecomposite disturbance process into account.

Page 76: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

A crucial assumption of this model is that ui is independent ofX ∗: individual i receives a random draw that gives her a higherwage. That ui must be independent of individual i ’s measurablecharacteristics included among the regressors X ∗. If thisassumption is not sustained, the random effects estimator willyield inconsistent estimates since the regressors will becorrelated with the composite disturbance term.

If the individual effects can be considered to be strictlyindependent of the regressors, then we might model theindividual-specific constant terms (reflecting the unmodeledheterogeneity across units) as draws from an independentdistribution. This greatly reduces the number of parameters tobe estimated, and conditional on that independence, allows forinference to be made to the population from which the surveywas constructed.

Page 77: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

A crucial assumption of this model is that ui is independent ofX ∗: individual i receives a random draw that gives her a higherwage. That ui must be independent of individual i ’s measurablecharacteristics included among the regressors X ∗. If thisassumption is not sustained, the random effects estimator willyield inconsistent estimates since the regressors will becorrelated with the composite disturbance term.

If the individual effects can be considered to be strictlyindependent of the regressors, then we might model theindividual-specific constant terms (reflecting the unmodeledheterogeneity across units) as draws from an independentdistribution. This greatly reduces the number of parameters tobe estimated, and conditional on that independence, allows forinference to be made to the population from which the surveywas constructed.

Page 78: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

In a large survey, with thousands of individuals, a randomeffects model will estimate K parameters, whereas a fixedeffects model will estimate (K − 1) + N parameters, with thesizable loss of (N − 1) degrees of freedom. In contrast to fixedeffects, the random effects estimator can identify theparameters on time-invariant regressors such as race orgender at the individual level.

Therefore, where its use can be warranted, the random effectsmodel is more efficient and allows a broader range of statisticalinference. The assumption of the individual effects’independence is testable and should always be tested.

Page 79: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

In a large survey, with thousands of individuals, a randomeffects model will estimate K parameters, whereas a fixedeffects model will estimate (K − 1) + N parameters, with thesizable loss of (N − 1) degrees of freedom. In contrast to fixedeffects, the random effects estimator can identify theparameters on time-invariant regressors such as race orgender at the individual level.

Therefore, where its use can be warranted, the random effectsmodel is more efficient and allows a broader range of statisticalinference. The assumption of the individual effects’independence is testable and should always be tested.

Page 80: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

To implement the one-way random effects formulation ofEquation (7), we assume that both u and ε are meanzeroprocesses, distributed independent of X ∗; that they are eachhomoskedastic; that they are distributed independently of eachother; and that each process represents independentrealizations from its respective distribution, without correlationover individuals (nor time, for ε). For the T observationsbelonging to the i th unit of the panel, we have the compositeerror process

ηit = ui + εit (8)

This is known as the error components model with conditionalvariance

E [η2it |X ∗] = σ2

u + σ2ε (9)

and conditional covariance within a unit of

E [ηitηis|X ∗] = σ2u, t 6= s. (10)

Page 81: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

To implement the one-way random effects formulation ofEquation (7), we assume that both u and ε are meanzeroprocesses, distributed independent of X ∗; that they are eachhomoskedastic; that they are distributed independently of eachother; and that each process represents independentrealizations from its respective distribution, without correlationover individuals (nor time, for ε). For the T observationsbelonging to the i th unit of the panel, we have the compositeerror process

ηit = ui + εit (8)

This is known as the error components model with conditionalvariance

E [η2it |X ∗] = σ2

u + σ2ε (9)

and conditional covariance within a unit of

E [ηitηis|X ∗] = σ2u, t 6= s. (10)

Page 82: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The covariance matrix of these T errors may then be written as

Σ = σ2ε IT + σ2

uιT ι′T . (11)

Since observations i and j are independent, the full covariancematrix of η across the sample is block-diagonal in Σ: Ω = In ⊗Σwhere ⊗ is the Kronecker product of the matrices.

Page 83: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Generalized least squares (GLS) is the estimator for the slopeparameters of this model:

bRE = (X ∗′Ω−1X ∗)−1(X ∗′

Ω−1y)

=

(∑i

X ∗′

i Σ−1X ∗i

)−1(∑i

X ∗′

i Σ−1yi

)(12)

To compute this estimator, we require Ω−1/2 = [In ⊗ Σ]−1/2,which involves

Σ−1/2 = σ−1ε [I − T−1θιT ι′T ] (13)

whereθ = 1− σε√

σ2ε + Tσ2

u

(14)

Page 84: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Generalized least squares (GLS) is the estimator for the slopeparameters of this model:

bRE = (X ∗′Ω−1X ∗)−1(X ∗′

Ω−1y)

=

(∑i

X ∗′

i Σ−1X ∗i

)−1(∑i

X ∗′

i Σ−1yi

)(12)

To compute this estimator, we require Ω−1/2 = [In ⊗ Σ]−1/2,which involves

Σ−1/2 = σ−1ε [I − T−1θιT ι′T ] (13)

whereθ = 1− σε√

σ2ε + Tσ2

u

(14)

Page 85: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The quasi-demeaning transformation defined by Σ−1/2 is thenσ−1

ε (yit − θyi): that is, rather than subtracting the entireindividual mean of y from each value, we should subtract somefraction of that mean, as defined by θ. Compare this to theLSDV model in which we define the within estimator by settingθ = 1. Like pooled OLS, the GLS random effects estimator is amatrix weighted average of the within and between estimators,but in this case applying optimal weights, as based on

λ =σ2

ε

σ2ε + Tσ2

u= (1− θ)2 (15)

where λ is the weight attached to the covariance matrix of thebetween estimator. To the extent that λ differs from unity,pooled OLS will be inefficient, as it will attach too much weighton the between-units variation, attributing it all to the variationin X rather than apportioning some of the variation to thedifferences in εi across units.

Page 86: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The setting λ = 1 (θ = 0) is appropriate if σ2u = 0, that is, if

there are no random effects; then a pooled OLS model isoptimal. If θ = 1, λ = 0 and the appropriate estimator is theLSDV model of individual fixed effects. To the extent that λdiffers from zero, the within (LSDV) estimator will be inefficient,in that it applies zero weight to the between estimator.

The GLS random effects estimator applies the optimal λ in theunit interval to the between estimator, whereas the fixed effectsestimator arbitrarily imposes λ = 0. This would only beappropriate if the variation in ε was trivial in comparison withthe variation in u, since then the indicator variables that identifyeach unit would, taken together, explain almost all of thevariation in the composite error term.

Page 87: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The setting λ = 1 (θ = 0) is appropriate if σ2u = 0, that is, if

there are no random effects; then a pooled OLS model isoptimal. If θ = 1, λ = 0 and the appropriate estimator is theLSDV model of individual fixed effects. To the extent that λdiffers from zero, the within (LSDV) estimator will be inefficient,in that it applies zero weight to the between estimator.

The GLS random effects estimator applies the optimal λ in theunit interval to the between estimator, whereas the fixed effectsestimator arbitrarily imposes λ = 0. This would only beappropriate if the variation in ε was trivial in comparison withthe variation in u, since then the indicator variables that identifyeach unit would, taken together, explain almost all of thevariation in the composite error term.

Page 88: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

To implement the feasible GLS estimator of the model all weneed are consistent estimates of σ2

ε and σ2u. Because the fixed

effects model is consistent its residuals can be used to estimateσ2

ε . Likewise, the residuals from the pooled OLS model can beused to generate a consistent estimate of (σ2

ε + σ2u). These two

estimators may be used to define θ and transform the data forthe GLS model.

Because the GLS model uses quasi-demeaning, it is capable ofincluding variables that do not vary at the individual level (suchas gender or race). Since such variables cannot be included inthe LSDV model, an alternative estimator must be definedbased on the between estimator’s consistent estimate of(σ2

u + T−1σ2ε ).

Page 89: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

To implement the feasible GLS estimator of the model all weneed are consistent estimates of σ2

ε and σ2u. Because the fixed

effects model is consistent its residuals can be used to estimateσ2

ε . Likewise, the residuals from the pooled OLS model can beused to generate a consistent estimate of (σ2

ε + σ2u). These two

estimators may be used to define θ and transform the data forthe GLS model.

Because the GLS model uses quasi-demeaning, it is capable ofincluding variables that do not vary at the individual level (suchas gender or race). Since such variables cannot be included inthe LSDV model, an alternative estimator must be definedbased on the between estimator’s consistent estimate of(σ2

u + T−1σ2ε ).

Page 90: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The feasible GLS estimator may be executed in Stata using thecommand xtreg with the re (random effects) option. Thecommand will display estimates of σ2

u, σ2ε and what Stata calls

rho: the fraction of variance due to εi . Breusch and Paganhave developed a Lagrange multiplier test for σ2

u = 0 which maybe computed following a random-effects estimation via thecommand xttest0.

You can also estimate the parameters of the random effectsmodel with full maximum likelihood. The mle option on thextreg, re command requests that estimator. The applicationof MLE continues to assume that X ∗ and u are independentlydistributed, adding the assumption that the distributions of uand ε are Normal. This estimator will produce a likelihood ratiotest of σ2

u = 0 corresponding to the Breusch–Pagan testavailable for the GLS estimator.

Page 91: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The feasible GLS estimator may be executed in Stata using thecommand xtreg with the re (random effects) option. Thecommand will display estimates of σ2

u, σ2ε and what Stata calls

rho: the fraction of variance due to εi . Breusch and Paganhave developed a Lagrange multiplier test for σ2

u = 0 which maybe computed following a random-effects estimation via thecommand xttest0.

You can also estimate the parameters of the random effectsmodel with full maximum likelihood. The mle option on thextreg, re command requests that estimator. The applicationof MLE continues to assume that X ∗ and u are independentlydistributed, adding the assumption that the distributions of uand ε are Normal. This estimator will produce a likelihood ratiotest of σ2

u = 0 corresponding to the Breusch–Pagan testavailable for the GLS estimator.

Page 92: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

A Hausman test may be used to test the null hypothesis thatthe extra orthogonality conditions imposed by the randomeffects estimator are valid. The fixed effects estimator, whichdoes not impose those conditions, is consistent regardless ofthe independence of the individual effects. The fixed effectsestimates are inefficient if that assumption of independence iswarranted. The random effects estimator is efficient under theassumption of independence, but inconsistent otherwise.

Therefore, we may consider these two alternatives in theHausman test framework, estimating both models andcomparing their common coefficient estimates in a probabilisticsense. If both fixed and random effects models generateconsistent point estimates of the slope parameters, they will notdiffer meaningfully. If the assumption of independence isviolated, the inconsistent random effects estimates will differfrom their fixed effects counterparts.

Page 93: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

A Hausman test may be used to test the null hypothesis thatthe extra orthogonality conditions imposed by the randomeffects estimator are valid. The fixed effects estimator, whichdoes not impose those conditions, is consistent regardless ofthe independence of the individual effects. The fixed effectsestimates are inefficient if that assumption of independence iswarranted. The random effects estimator is efficient under theassumption of independence, but inconsistent otherwise.

Therefore, we may consider these two alternatives in theHausman test framework, estimating both models andcomparing their common coefficient estimates in a probabilisticsense. If both fixed and random effects models generateconsistent point estimates of the slope parameters, they will notdiffer meaningfully. If the assumption of independence isviolated, the inconsistent random effects estimates will differfrom their fixed effects counterparts.

Page 94: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

To implement the Hausman test, you estimate each form of themodel, using the commands estimates store set after eachestimation, with set defining that set of estimates: for instance,set might be fix for the fixed effects model. Then thecommand hausman setconsist seteff will invoke the Hausmantest, where setconsist refers to the name of the fixed effectsestimates (which are consistent under the null and alternative)and seteff referring to the name of the random effectsestimates, which are only efficient under the null hypothesis ofindependence. This test is based on the difference of the twoestimated covariance matrices (which is not guaranteed to bepositive definite) and the difference between the fixed effectsand random effects vectors of slope coefficients.

Page 95: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The Hausman–Taylor estimator

If the Hausman test indicates that the random effects ui cannotbe considered orthogonal to the individual level error, aninstrumental variables estimator may be utilized to generateconsistent estimates of the coefficients on the time-invariantvariables. The Hausman–Taylor estimator (1981) assumes thatsome of the regressors in X are correlated with u, but that noneare correlated with ε. This estimator is available in Stata asxthtaylor.

Page 96: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Their approach is based on dividing the regressors into fourcategories: the interaction of time varying (X ) / time invariant(Z ) and uncorrelated with ui (1) / correlated with ui (2). Forexample, X2 are those time-varying regressors that are thoughtto be correlated with ui . Identification of the parametersrequires that K1 (the number of X1 variables) be at least aslarge as L2 (the number of Z2 variables).

The application of the Hausman–Taylor estimator circumventsthe problem of X2 and Z2 variables being potentially correlatedwith ui , but requires that we can identify variables of type 1 thatare surely not correlated with the random effects.

Page 97: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Their approach is based on dividing the regressors into fourcategories: the interaction of time varying (X ) / time invariant(Z ) and uncorrelated with ui (1) / correlated with ui (2). Forexample, X2 are those time-varying regressors that are thoughtto be correlated with ui . Identification of the parametersrequires that K1 (the number of X1 variables) be at least aslarge as L2 (the number of Z2 variables).

The application of the Hausman–Taylor estimator circumventsthe problem of X2 and Z2 variables being potentially correlatedwith ui , but requires that we can identify variables of type 1 thatare surely not correlated with the random effects.

Page 98: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The IV estimator for panel data

Stata also provides an instrumental variables estimator for thefixed effects and random effects models in which some of the Xvariables are correlated with the idiosyncratic error ε. These arequite different assumptions about the nature of any suspectedcorrelation between regressor and the composite error termfrom those underlying the Hausman–Taylor estimator. Thextivreg command also supports fixed effects, betweeneffects, and first-differenced estimators in an instrumentalvariables context.

Page 99: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Considering our discussion of instrumental variables estimationvia ivreg2, the features of ivreg2 are also available for paneldata in xtivreg2, which is a “wrapper” for ivreg2. Thisroutine of Mark Schaffer’s extends Stata’s xtivreg’s supportfor the fixed effect (fe) and first difference (fd) estimators. Thextivreg2 routine is available from ssc.

Just as ivreg2 may be used to conduct a Hausman test of IVvs. OLS, Schaffer and Stillman’s xtoverid routine may beused to conduct a Hausman test of random effects vs. fixedeffects after xtreg, re and xtivreg, re. This routine canalso calculate tests of overidentifying restrictions after thosetwo commands as well as xthtaylor. The xtoverid routineis also available from ssc.

Page 100: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Considering our discussion of instrumental variables estimationvia ivreg2, the features of ivreg2 are also available for paneldata in xtivreg2, which is a “wrapper” for ivreg2. Thisroutine of Mark Schaffer’s extends Stata’s xtivreg’s supportfor the fixed effect (fe) and first difference (fd) estimators. Thextivreg2 routine is available from ssc.

Just as ivreg2 may be used to conduct a Hausman test of IVvs. OLS, Schaffer and Stillman’s xtoverid routine may beused to conduct a Hausman test of random effects vs. fixedeffects after xtreg, re and xtivreg, re. This routine canalso calculate tests of overidentifying restrictions after thosetwo commands as well as xthtaylor. The xtoverid routineis also available from ssc.

Page 101: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The first difference estimator

The within transformation used by fixed effects models removesunobserved heterogeneity at the unit level. The same can beachieved by first differencing the original equation (whichremoves the constant term). In fact, if T = 2, the fixed effectsand first difference estimates are identical. For T > 2, theeffects will not be identical, but they are both consistentestimators of the original model. Stata’s xtreg does notprovide the first difference estimator, but xtivreg2 providesthis option as the fd model.

The ability of first differencing to remove unobservedheterogeneity also underlies the family of estimators that havebeen developed for dynamic panel data (DPD) models. Thesemodels contain one or more lagged dependent variables,allowing for the modeling of a partial adjustment mechanism.

Page 102: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The first difference estimator

The within transformation used by fixed effects models removesunobserved heterogeneity at the unit level. The same can beachieved by first differencing the original equation (whichremoves the constant term). In fact, if T = 2, the fixed effectsand first difference estimates are identical. For T > 2, theeffects will not be identical, but they are both consistentestimators of the original model. Stata’s xtreg does notprovide the first difference estimator, but xtivreg2 providesthis option as the fd model.

The ability of first differencing to remove unobservedheterogeneity also underlies the family of estimators that havebeen developed for dynamic panel data (DPD) models. Thesemodels contain one or more lagged dependent variables,allowing for the modeling of a partial adjustment mechanism.

Page 103: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

A serious difficulty arises with the one-way fixed effects modelin the context of a dynamic panel data (DPD) model particularlyin the “small T , large N" context. As Nickell (1981) shows, thisarises because the demeaning process which subtracts theindividual’s mean value of y and each X from the respectivevariable creates a correlation between regressor and error.

The mean of the lagged dependent variable containsobservations 0 through (T − 1) on y , and the meanerror—which is being conceptually subtracted from eachεit—contains contemporaneous values of ε for t = 1 . . . T . Theresulting correlation creates a bias in the estimate of thecoefficient of the lagged dependent variable which is notmitigated by increasing N, the number of individual units.

Page 104: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

A serious difficulty arises with the one-way fixed effects modelin the context of a dynamic panel data (DPD) model particularlyin the “small T , large N" context. As Nickell (1981) shows, thisarises because the demeaning process which subtracts theindividual’s mean value of y and each X from the respectivevariable creates a correlation between regressor and error.

The mean of the lagged dependent variable containsobservations 0 through (T − 1) on y , and the meanerror—which is being conceptually subtracted from eachεit—contains contemporaneous values of ε for t = 1 . . . T . Theresulting correlation creates a bias in the estimate of thecoefficient of the lagged dependent variable which is notmitigated by increasing N, the number of individual units.

Page 105: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The demeaning operation creates a regressor which cannot bedistributed independently of the error term. Nickelldemonstrates that the inconsistency of ρ as N →∞ is of order1/T , which may be quite sizable in a “small T " context. If ρ > 0,the bias is invariably negative, so that the persistence of y willbe underestimated. For reasonably large values of T , the limitof (ρ− ρ) as N →∞ will be approximately −(1 + ρ)/(T − 1): asizable value, even if T = 10. With ρ = 0.5, the bias will be-0.167, or about 1/3 of the true value. The inclusion ofadditional regressors does not remove this bias. Indeed, if theregressors are correlated with the lagged dependent variable tosome degree, their coefficients may be seriously biased as well.

Page 106: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Note also that this bias is not caused by an autocorrelated errorprocess ε. The bias arises even if the error process is i .i .d . Ifthe error process is autocorrelated, the problem is even moresevere given the difficulty of deriving a consistent estimate ofthe AR parameters in that context.

The same problem affects the one-way random effects model.The ui error component enters every value of yit byassumption, so that the lagged dependent variable cannot beindependent of the composite error process.

Page 107: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Note also that this bias is not caused by an autocorrelated errorprocess ε. The bias arises even if the error process is i .i .d . Ifthe error process is autocorrelated, the problem is even moresevere given the difficulty of deriving a consistent estimate ofthe AR parameters in that context.

The same problem affects the one-way random effects model.The ui error component enters every value of yit byassumption, so that the lagged dependent variable cannot beindependent of the composite error process.

Page 108: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

A solution to this problem involves taking first differences of theoriginal model. Consider a model containing a laggeddependent variable and a single regressor X :

yit = β1 + ρyi,t−1 + Xitβ2 + ui + εit (16)

The first difference transformation removes both the constantterm and the individual effect:

∆yit = ρ∆yi,t−1 + ∆Xitβ2 + ∆εit (17)

There is still correlation between the differenced laggeddependent variable and the disturbance process (which is nowa first-order moving average process, or MA(1)): the formercontains yi,t−1 and the latter contains εi,t−1.

Page 109: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

But with the individual fixed effects swept out, a straightforwardinstrumental variables estimator is available. We may constructinstruments for the lagged dependent variable from the secondand third lags of y , either in the form of differences or laggedlevels. If ε is i .i .d ., those lags of y will be highly correlated withthe lagged dependent variable (and its difference) butuncorrelated with the composite error process.

Even if we had reason to believe that ε might be following anAR(1) process, we could still follow this strategy, “backing off”one period and using the third and fourth lags of y (presumingthat the timeseries for each unit is long enough to do so).

Page 110: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

But with the individual fixed effects swept out, a straightforwardinstrumental variables estimator is available. We may constructinstruments for the lagged dependent variable from the secondand third lags of y , either in the form of differences or laggedlevels. If ε is i .i .d ., those lags of y will be highly correlated withthe lagged dependent variable (and its difference) butuncorrelated with the composite error process.

Even if we had reason to believe that ε might be following anAR(1) process, we could still follow this strategy, “backing off”one period and using the third and fourth lags of y (presumingthat the timeseries for each unit is long enough to do so).

Page 111: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Dynamic panel data estimators

The DPD (Dynamic Panel Data) approach of Arellano and Bond(1991) is based on the notion that the instrumental variablesapproach noted above does not exploit all of the informationavailable in the sample. By doing so in a Generalized Methodof Moments (GMM) context, we may construct more efficientestimates of the dynamic panel data model. TheArellano–Bond estimator can be thought of as an extension ofthe Anderson–Hsiao estimator implemented by xtivreg, fd.

Page 112: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Arellano and Bond argue that the Anderson–Hsiao estimator,while consistent, fails to take all of the potential orthogonalityconditions into account. Consider the equations

yit = Xitβ1 + Witβ2 + vit

vit = ui + εit (18)

where Xit includes strictly exogenous regressors, Wit arepredetermined regressors (which may include lags of y ) andendogenous regressors, all of which may be correlated with ui ,the unobserved individual effect. First-differencing the equationremoves the ui and its associated omitted-variable bias. TheArellano–Bond estimator sets up a generalized method ofmoments (GMM) problem in which the model is specified as asystem of equations, one per time period, where theinstruments applicable to each equation differ (for instance, inlater time periods, additional lagged values of the instrumentsare available).

Page 113: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

The instruments include suitable lags of the levels of theendogenous variables (which enter the equation in differencedform) as well as the strictly exogenous regressors and anyothers that may be specified. This estimator can easilygenerate an immense number of instruments, since by period τall lags prior to, say, (τ − 2) might be individually considered asinstruments. If T is nontrivial, it is often necessary to employthe option which limits the maximum lag of an instrument toprevent the number of instruments from becoming too large.This estimator is available in Stata as xtabond. A moregeneral version, allowing for autocorrelated errors, is availableas xtdpd.

Page 114: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

A potential weakness in the Arellano–Bond DPD estimator wasrevealed in later work by Arellano and Bover (1995) andBlundell and Bond (1998). The lagged levels are often ratherpoor instruments for first differenced variables, especially if thevariables are close to a random walk. Their modification of theestimator includes lagged levels as well as lagged differences.

The original estimator is often entitled difference GMM, whilethe expanded estimator is commonly termed System GMM.The cost of the System GMM estimator involves a set ofadditional restrictions on the initial conditions of the processgenerating y . This estimator is available in Stata as xtdpdsys.

Page 115: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

A potential weakness in the Arellano–Bond DPD estimator wasrevealed in later work by Arellano and Bover (1995) andBlundell and Bond (1998). The lagged levels are often ratherpoor instruments for first differenced variables, especially if thevariables are close to a random walk. Their modification of theestimator includes lagged levels as well as lagged differences.

The original estimator is often entitled difference GMM, whilethe expanded estimator is commonly termed System GMM.The cost of the System GMM estimator involves a set ofadditional restrictions on the initial conditions of the processgenerating y . This estimator is available in Stata as xtdpdsys.

Page 116: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

An excellent alternative to Stata’s built-in commands is DavidRoodman’s xtabond2, available from SSC (finditxtabond2). It is very well documented in his paper, referencedabove. The xtabond2 routine handles both the difference andsystem GMM estimators and provides several additionalfeatures—such as the orthogonal deviationstransformation—not available in official Stata’s commands.

As any of the DPD estimators are instrumental variablesmethods, it is particularly important to evaluate theSargan–Hansen test results when they are applied. Roodman’sxtabond2 provides C tests (as discussed in re ivreg2) forgroups of instruments. In his routine, instruments can be either“GMM-style" or “IV-style". The former are constructed per theArellano–Bond logic, making use of multiple lags; the latter areincluded as is in the instrument matrix. For the system GMMestimator (the default in xtabond2 instruments may bespecified as applying to the differenced equations, the levelequations or both.

Page 117: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

An excellent alternative to Stata’s built-in commands is DavidRoodman’s xtabond2, available from SSC (finditxtabond2). It is very well documented in his paper, referencedabove. The xtabond2 routine handles both the difference andsystem GMM estimators and provides several additionalfeatures—such as the orthogonal deviationstransformation—not available in official Stata’s commands.

As any of the DPD estimators are instrumental variablesmethods, it is particularly important to evaluate theSargan–Hansen test results when they are applied. Roodman’sxtabond2 provides C tests (as discussed in re ivreg2) forgroups of instruments. In his routine, instruments can be either“GMM-style" or “IV-style". The former are constructed per theArellano–Bond logic, making use of multiple lags; the latter areincluded as is in the instrument matrix. For the system GMMestimator (the default in xtabond2 instruments may bespecified as applying to the differenced equations, the levelequations or both.

Page 118: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Another important diagnostic in DPD estimation is the AR testfor autocorrelation of the residuals. By construction, theresiduals of the differenced equation should possess serialcorrelation, but if the assumption of serial independence in theoriginal errors is warranted, the differenced residuals should notexhibit significant AR(2) behavior. These statistics areproduced in the xtabond and xtabond2 output. If asignificant AR(2) statistic is encountered, the second lags ofendogenous variables will not be appropriate instruments fortheir current values.

A useful feature of xtabond2 is the ability to specify, forGMM-style instruments, the limits on how many lags are to beincluded. If T is fairly large (more than 7–8) an unrestricted setof lags will introduce a huge number of instruments, with apossible loss of efficiency. By using the lag limits options, youmay specify, for instance, that only lags 2–5 are to be used inconstructing the GMM instruments.

Page 119: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Another important diagnostic in DPD estimation is the AR testfor autocorrelation of the residuals. By construction, theresiduals of the differenced equation should possess serialcorrelation, but if the assumption of serial independence in theoriginal errors is warranted, the differenced residuals should notexhibit significant AR(2) behavior. These statistics areproduced in the xtabond and xtabond2 output. If asignificant AR(2) statistic is encountered, the second lags ofendogenous variables will not be appropriate instruments fortheir current values.

A useful feature of xtabond2 is the ability to specify, forGMM-style instruments, the limits on how many lags are to beincluded. If T is fairly large (more than 7–8) an unrestricted setof lags will introduce a huge number of instruments, with apossible loss of efficiency. By using the lag limits options, youmay specify, for instance, that only lags 2–5 are to be used inconstructing the GMM instruments.

Page 120: Management and analysis of panel data in economics and …fmPanel or longitudinal data are widely available in many fields of economics and finance. Econometric analysis using panel

Although the DPD estimators are linear estimators, they arehighly sensitive to the particular specification of the model andits instruments. There is no substitute for experimentation withthe various parameters of the specification to ensure that yourresults are reasonably robust to variations in the instrument setand lags used. If you are going to work with DPD models, youshould study Roodman’s “How to do xtabond2” paper so thatyou fully understand the nuances of this estimation strategy.