**Lecture 13   Panel Data — Transcript & Summary | SozAI**
Source: https://sozai.app/transcript/lecture-13-panel-data/

Dr. Gallenstein's lecture 13 introduces panel data (multiple people over multiple time periods) and shows how it helps address omitted variable bias via fixed effects models.

## Key Takeaways

- Panel data combines cross-sectional and time dimensions, allowing analysis of change over time for the same individuals
- Panel data can control for time-invariant unobservable characteristics, reducing omitted variable bias
- Fixed effects and first-difference models remove individual-specific constant factors by using within-person variation
- Time-invariant variables like a fixed effect cannot be estimated separately once individual effects are removed (e.g., education dropped in the example)
- Serial correlation of errors over time must be considered when computing standard errors

## What the video covers

- Introduces lecture 13 on panel data, continuing tools for solving omitted variable bias
- Defines cross-sectional data (many units at one point in time) and time series data (one unit over many periods)
- Defines panel data as repeated cross-sections on the same individuals over multiple time periods, combining both
- Uses a wage-and-education example to contrast cross-sectional and panel data layouts, including a year variable
- Explains that the error term captures excluded variables and that correlation with regressors biases estimates
- Distinguishes time-variant and time-invariant unobservables
- Explains that panel data can control for time-invariant unobservables, eliminating an entire source of bias
- Presents first-difference style models using changes in variables over time (d-prefixed variables)
- Discusses demeaning/within transformation to remove person-specific averages, yielding a fixed effects estimator
- Notes the possibility of serial correlation in errors over time, which affects standard errors

## Chapters

1. 00:00 Introduction and Lecture Overview
2. 05:00 Cross-Sectional, Time Series, and Panel Data Defined
3. 16:40 Illustrating Cross-Sectional vs Panel Data Layouts
4. 26:40 Omitted Variable Bias and the Error Term
5. 46:40 Time-Variant and Time-Invariant Unobservables
6. 66:40 Controlling for Unobservables with Panel Data
7. 85:00 First-Difference and Demeaned Models
8. 111:40 Serial Correlation and Fixed Effects Estimation Example

Answers

## Questions about this video

What is the difference between cross-sectional and panel data according to the lecture?

Cross-sectional data covers multiple observational units at a single point in time. Panel data covers the same units observed over multiple time periods, combining cross-sectional and time dimensions.

How does panel data help with omitted variable bias?

Because panel data tracks the same individuals over time, it allows controlling for time-invariant unobservables such as innate characteristics, removing a major source of bias that cross-sectional data cannot handle.

Why was the education variable dropped in the fixed effects example?

Within a fixed effects model, education appeared to be time-invariant for the individuals in the example, so once person-specific effects are removed it has no within-person variation and is dropped.

## Full Transcript — Download SRT & Markdown

00:01

Speaker A

welcome back everyone this is dr galen stein and we are here again with lecture number 13.

00:06

Speaker A

okay in lecture number 13 we're going to look at something called panel data okay and this lecture is is going to partly be a continuation of what we've been looking at that is tools for how to solve the emitted

00:19

Speaker A

variable bias problem but then in another respect this lecture is also going to broaden our understanding of data so far in the class we've worked only with what's called cross-sectional data which i'll talk more about in a moment

00:33

Speaker A

cross-sectional data is is data that has a bunch of observations for different individuals typically at one moment in time and what we're going to look at today is what if we have data that also has a time dimension a time dimension

00:48

Speaker A

a time dynamic what if we have data that is multiple people but across multiple time periods do we want to introduce what that data would look like and what data like that allows us to do in order to solve that emitted variable

01:05

Speaker A

bias problem in fact we will find that when we have that kind of data there are certain things that we can control for that we weren't able to control for in the past which helps move us closer to that to solving that

01:20

Speaker A

emitted variable bias problem okay that's so that's kind of the overview here we're going to learn about panel data and then we'll learn some tools that we can use when we have panel data to solve that emitted variable bias problem

01:32

Speaker A

okay so with that introduction let's dive right in all right so introduction uh often when we seek to answer a research question we are not only interested in differences between people or some other observational unit we tend to work with people a lot in

01:49

Speaker A

this class and so i'll just refer to them as individuals but it could be you know differences between cities or villages or um you know some other unit of observation some sort of observational unit but i say usually when we answer a research

02:03

Speaker A

question we're not only interested in differences between people but we're also interested in differences across time sometimes we might want to know uh the impact of a program before and after it is implemented we might want to know how

02:18

Speaker A

education affects wages differently at different points in time if we want to know how variables change over time we need to incorporate more than just one time period of data and so that's what we're going to do today so let me define some things

02:34

Speaker A

cross-sectional data i mentioned it before cross-sectional data is a data set that contains information on multiple observational units like i said individuals groups cities countries villages etc it has information on multiple observational units so on multiple people at a single point in

02:54

Speaker A

time so there's one unit of time multiple units of observations so multiple people this has been exclusively the type of data that we've looked at so far in the course we have looked exclusively at cross-sectional data many times we've looked at data sets of

03:17

Speaker A

you know smallholder farmers in a village the data set was collected at one period in time and measured and collected information on multiple different people that's cross-sectional now there's another kind of data called time series data which is not covered in

03:36

Speaker A

this course time series data is a data set that contains information on a single observational unit it could be a person or a country or a village over many periods of time so instead of doing multiple people at

03:51

Speaker A

one period of time time series data does one person at multiple periods of time all right and then lastly and this will be the topic of today there's something called panel data panel data is a data set that contains

04:10

Speaker A

information for multiple observational units so for multiple people over multiple periods of time so panel data is a series of cross-sectional data sets collected on the same people over multiple periods of time so panel data kind of combines cross-sectional data

04:32

Speaker A

and time series data panel data is a powerful tool which we will see but now to drive this point home let me just try to make sure that it's clear what i'm talking about when i talk about these different kinds of data

04:46

Speaker A

specifically i want to talk about what does cross-sectional data look like and what does panel data look like okay so we'll just use an example so imagine we're studying the impact of education on individuals wages we could collect a cross-sectional data

05:01

Speaker A

set in which we collect data on multiple people's wages at the same point of time and that would look a little bit like this where we have multiple people so person one person two person three person four and then we have information on their

05:17

Speaker A

wage and information on their education level all of this was collected at one point in time so there's no point there's no reason to have a variable that indicates the time because this is all collected at the same point of time

05:31

Speaker A

okay so this is this is cross sectional data this should look very familiar because we've used cross sectional data throughout the course so far but now what if we collected data on the same people more than once we could collect data on the same people

05:49

Speaker A

twice which would allow us to capture changes in these individuals outcomes over time we can see if wages are increasing or decreasing over time see if the impact of education changes over time see if increases in education would have an

06:04

Speaker A

impact on wages et cetera so we call this panel data panel data is when we have more than one year of cross-sectional data for the same people all right so panda data we could collect data on the same individuals at

06:23

Speaker A

two different periods of time it could be more than two but for the purposes of our example let's say that we collect a um let's say we click the first year of data in 2015 and then we return and we

06:36

Speaker A

collect data from the same people in 2018 we will be able to capture changes in wages over the time period of 2015 to 2018.

06:47

Speaker A

so this is what that data would look like all right this is panel data all right so let's look at what a panel data set might look like given the illustration of the example i mentioned a moment ago

07:01

Speaker A

so again we have individuals their wages and education however you'll notice that for each individual now there are there's a repeat we have individual one once and then individual one twice so the same person but two observations for that same person

07:23

Speaker A

the same thing for person two here's person two and we observe them twice person three again we observe them twice person four we observe them twice now also notice that we're adding and we are adding an additional variable

07:40

Speaker A

in this case the year this measures or this indicates the year in which the data is collected so there's year one and year two in this specific example year one is 2015 year two is 2018. but you can see here

07:57

Speaker A

that we have person one we observed them in in 2015 or year one here's their wages and their education level in 2015.

08:08

Speaker A

and then here's person one again in year two we measure the same person but in a different year year two is 2018 as i mentioned before here is person one's wages in 2018 and here's their education level you can

08:24

Speaker A

see that person one's wages went up from 2015 to 2018 you can also see that their education went up from 12 to 13 between 2015 and 2018.

08:41

Speaker A

all right we can see the same for person two for person two we observe them we have data for them in 2015 year one okay and the same person person two the same person in the second year year two 2018 we have their wages

08:59

Speaker A

and their education okay so we have a new variable that indicates the year in which the data was collected and then we have data for the same person in the second year same person in the second year so now we

09:15

Speaker A

have two observations per person year one and year two okay now this this step here what i've just done is kind of establishing for you what this panel data looks like all right now i want to begin and go through a process as i talk and

09:40

Speaker A

explain how panel data is useful and why it's a powerful tool and i want to set up for us kind of the assumptions we need to utilize it and then what i'm going to do is i'm going to go through

09:54

Speaker A

two specific specific models that we can use on panel data all right so that's kind of an outline so let's jump into that all right so when we have panel data we need to take into consideration that we now have variation

10:12

Speaker A

across individuals and across time so just looking back here again we have variation across individuals and across time what do i mean by that variation so variation across individuals that means different people have different wages different people have different levels of income

10:33

Speaker A

i'm sorry of education so you can see person one has 12 years of education in the first year and person two is eight years of education in the first year et cetera so there's variation there are there are

10:44

Speaker A

differences between different individuals in the data that's normal for cross-sectional data that's what we have in cross-sectional data but now in panel data we also have variation across time so you can see that even for person one their wages is their wages are different

11:05

Speaker A

across time for person one their wage is 15.4 for person one and year two their wages are 16.5 and so now we have variation across individuals and across time and therefore when we conduct an analysis using panel data

11:25

Speaker A

we need to take into consideration that when we run a regression we have variation both in terms of uh individuals and in terms of of time all right so then i just want i've written a regression model here

11:39

Speaker A

just so that i can be clear about subscripts because they're these subscripts are going to be important as we talk about um panel data so you see here i have a simple linear regression model that has a dependent

11:53

Speaker A

variable y intercept term an independent variable x1 another independent variable x2 and then of course the error term but when you look at this regression there should be one thing that sticks out to you as being new and that is that each of

12:10

Speaker A

the variables has two subscripts instead of one you can see here on the dependent variable it has a subscript i and a subscript t now in the past we're used to seeing the subscript i the subscript i indicates that

12:29

Speaker A

this dependent variable takes different values depending on what person it is so the subscript i indicates the individual so person one will have a different dependent variable than person two and person three etc a different value for the dependent

12:47

Speaker A

variable i should say but what's new here is the introduction of this second the second subscript t here t indicates uh the year all right so now we have subscripts i for individual and subscript subscript t for year or time so i

13:11

Speaker A

is typically used for the cross-sectional unit which is often individuals and so we have i and then t is the scrub subscript we often times use for time which is usually the year okay so we have variation in the

13:27

Speaker A

dependent variable across individual and across time same thing for our independent variables in our error term so let's try to make this more clear just to make sure that we understand these these these subscripts these indexes because we need we need to be very

13:46

Speaker A

comfortable with these subscripts as we go through the left the rest of the lecture so let's just look at this example of regression where we're regressing wage on education and i want to make sure that we understand what the subscripts mean

14:00

Speaker A

so i want to i want to just think about this and then i want to look at a data set and we'll just make sure that we understand it so so when i have the subscript when i have

14:12

Speaker A

the subscript i and subscript t this indicates that wages are varying across individuals and across time so now let's look at let's just look at a couple questions so if i if i asked you what is wage subscript one comma two that means wage

14:31

Speaker A

for person 1 at time period 2. can you find that on this data set wage for person 1 in time period 2. where would that be in this data set this is just to make sure that we understand these subscripts

14:47

Speaker A

where where would we find that what is the value what is the wage value for person one at time period two all right if you've selected this one you're correct 16.5 what about the wage for person three at

15:00

Speaker A

time period one can you find that person three at time period one if you said nineteen you're correct all right what is the education level for person four at time period 2. can you pick that out if you pick 13 you're correct all right

15:16

Speaker A

well done that was just a very simple thing to make sure we understand how these indexes work all right with that done let's let's move forward all right now for us to understand the power and potential of panel data

15:34

Speaker A

we need to again kind of review this omitted variable bias and then we can kind of work our way up set ourselves up for understanding uh why panel data is important okay so panel data gives us a powerful tool for

15:50

Speaker A

identifying unbiased coefficient estimates relative to a standard cross-sectional analysis to illustrate this we need to first review the core problem and regression analysis omitted variable bias consider the following regression model cross-sectional regression model and so you can you can tell that it's cross-sectional

16:08

Speaker A

because it only has an index i that means it only varies between individuals there's no variation across time okay so we have just a simple cross-sectional regression model here it looks very familiar i'm sure now we know that beta 1 had our

16:24

Speaker A

estimated beta 1 will be biased if if the x variable if the independent variable is correlated with the error term all right we also know that the error term contains all the information for variables that are excluded from the

16:40

Speaker A

model we know that x will be correlated with the error term if there exists at least one variable zi that is omitted from the model for which these two conditions hold all right this should all look very familiar the basic idea

16:58

Speaker A

is this the beta one hat estimate they don't i'm sorry the beta 1 estimate beta 1 hat will be correlated it will be biased if x is correlated with the error term x will be correlated with the error term

17:15

Speaker A

if there is a if there is a variable that is omitted from the model we'll call that variable z and that variable satisfies these two conditions the two conditions are z the human to variable must be correlated with x and z

17:32

Speaker A

emit a variable must be correlated with y if this omitted variable z is correlated with both x and y then my estimate of beta 1 hat will be biased i'm sorry my estimate of beta 1 which is beta 1 hat will be biased

17:50

Speaker A

okay so omitted variable bias is a serious problem because we frequently have some omitted variable z that is unobservable so this is a problem that a variable bias is a problem because we very frequently are going to have

18:05

Speaker A

omitted variables and we're very frequently going to have omitted variables for which we do not have data that means they're not observed in our data set we don't have data on them they're either truly unobservable or we do not observe them in our data set if

18:24

Speaker A

that's the case then we will have omitted variable bias in our standard cross-sectional regression all right but now panel data is a powerful tool to help solve this problem and and we'll see why all right so how does panel data help us

18:42

Speaker A

to solve the omitted variable bias problem all right now to answer that question i'm going to go through quite a number of slides here and we're going to kind of work our way up kind of build some different concepts

18:52

Speaker A

okay so consider the following regression model using panel data all right so this is just the same model but now we have a panel data set and so we have variation across individuals i and we have variation across time

19:07

Speaker A

t so we we now have observations for x and y that will vary by individual i and time period t this regression as stated will likely suffer from considerable omitted variable bias we will now incrementally demonstrate how some or all of the spies can be

19:25

Speaker A

removed using panel data all right so the first thing we want to notice is that this model omits a control variable for the passage of time we know that x changes over time so admitting the passage of time will

19:38

Speaker A

result in omitted variable bias if time also affects the outcome variable therefore we first include a time variable so the first things that we'll do is make sure that we control for the fact that time is changing in our data set

19:53

Speaker A

we'll introduce a new variable t where t and notice t has a subscript only of t not i doesn't vary across i and only very varies across t all right where t t subscript t equals one if you're in year two and it

20:12

Speaker A

equals zero if you're in year one and so this t variable is a variable that is capturing the passage of time all right that will that will help that will be an improvement over this original model so adding control variable for time can

20:29

Speaker A

allow us to determine how the dependent variable changes over time however we may still have omitted variable bias in fact we only almost certainly will but now this will begin to allow us to to see the great advantage of panel data

20:45

Speaker A

so here we go the great advantage of panel data is that panel data can allow us to control for a particular kind of emitted variable bias to see this we will disaggregate the error term into two components all right so we have this error term

21:01

Speaker A

this error term varies it varies across individuals and across time and what we're going to do to illustrate what we're able to do using panel data is we're going to disaggregate this error term and we're going to disaggregate it into

21:22

Speaker A

two different terms we're going to say a i all right so this this variable a i and this variable v i t all right we're going to take this error term and we're going to decompose it into these two different

21:40

Speaker A

components of the error term okay now what does that mean what is what does this mean to disaggregate the error term what we're saying is that the error term let's go back here what we're saying this error term

21:55

Speaker A

remember the error term captures all the information from all the variables that are excluded from the model remember the error term captures all the information that is excluded from the regression model now with panel data we can imagine

22:18

Speaker A

that some of that information that is excluding that is excluded from the model which means is captured by epsilon that by the air term some of this information that is excluded from the model varies only across individuals not across time and other

22:40

Speaker A

information varies across individuals and varies across time and so what we're doing is we're decomposing this error term into different components so the different components work like this there is one component so a part of the error term

22:58

Speaker A

is composed entirely of variables that do not change over time that means as time changes the variable doesn't change and so we call that this a i so a i accounts for all omitted variables that vary across individuals

23:17

Speaker A

but do not vary across time so a i accounts for all omitted variables that vary across individuals that means they're different between people but they do not vary over time they're different between people that means they vary between people but they do not vary over

23:39

Speaker A

time so one uh one example of this let's say that we did not observe the sex of an individual so they could be male or female now that that variable varies between individuals different some people are men and some people are women

23:59

Speaker A

but it does not vary over time it does not vary over time that means if you go from 2015 to 2018 the male in 2015 is also a male in 2018.

24:12

Speaker A

the the female in 2015 is also a female in 2018. so this a i accounts for all the variables that are like that all the variables that change between people that may be different between people but do not change over time

24:33

Speaker A

all right so a i accounts for that it varies across people so it has an index i but it does not vary across time so it does not have an index t all right and then this v i t accounts

24:48

Speaker A

for all emitted variables that vary over time and across individuals okay so so any variable that varies between people that means different people can have different values and it varies across across time that means it changes as time goes on

25:08

Speaker A

all the omitted variables that vary across time and across individuals is captured by v i t alright so just recapping here the error term the error term in this regression accounts for all the omitted variables it captures the information

25:28

Speaker A

for all the emitted variables everything that's excluded from the model and what i'm saying is is that this error term we can say that this error term is composed of two parts all the omitted variables that do not

25:41

Speaker A

vary across time so that's that's a i and then all the variables that do vary across time and individuals so it's v i t all right v e i t varies across individuals i and time so it has a subscript t

25:58

Speaker A

all right so these error terms allow us to see why panel models are so powerful we can now distinguish between different kinds of unobservable characteristics okay so remember the epsilon captures the error term captures all the information that is emitted from the

26:18

Speaker A

regression that means it's capturing all the information from omitted variables all information from the omitted variables even the un so and especially the unobserved omitted variables all the variables that are emitted from the model that we do not observe or captured by

26:37

Speaker A

the error term and so now when we decompose it into a and v we can see that a accounts for all the unobserved variables that do not vary across time and v accounts for all the unobserved variables that vary across individuals

27:04

Speaker A

and time all right so now i want to make a really important distinction here and make sure that we're defining these terms i wanted to find two different kinds of unobservables now if you remember in the past i've talked about

27:19

Speaker A

observables and unobservables observables are variables they're it's information that we have in our data set an observable variable is something that is capable of being observed and is in our data an unobservable could be something that is literally it cannot be measured

27:39

Speaker A

so it's literally not observable um or a variable that is not in our data that means it's not observed in our data okay and we know that all that all that unobserved information goes into the error term but

27:56

Speaker A

now what i'm saying now so before i've defined observables and unobservables now i'm coming back and i'm going to define two different kinds of unobservables two different kinds of unobservables the first kind of unobservable is called a time variant unobservable

28:18

Speaker A

time variant unobservable so time variant time variant unobservables are factors that change over time they are time variant they change over time they vary across time so time variant varies across time time variant varies across time so an

28:38

Speaker A

unobservable that varies across time is a time variant unobservable and all time variant on observables are captured by v all right and now i also have time invariant unobservables so your unobservable factors uh that do not change over time

29:02

Speaker A

unobservable unobservable factors that do not change across time so these are captured by a i okay two different kinds of unobservables it's very important to recognize what these are and to make this distinction time variant on observables factors that change over time and time

29:25

Speaker A

invariant on observables factors that do not change over time okay so let's uh let's just give some examples to to make this more clear okay let's let's do an example so let's go back to our wage example and uh we want to identify the impact of

29:46

Speaker A

wages of i'm sorry of education on wages so we have this uh this model that we could run using panel data we can see that wage varies across individual and time education varies across individual and time we have

30:01

Speaker A

our error term we also have a time term so a term that accounts for the passage of time in this regression model we only have two independent variables and so there are going to be quite a number of unobs

30:15

Speaker A

of omitted variables in this regression quite a number of variables that are ending up in our error term so now i want to think about some of these possible omitted variables and i want to think about which ones are

30:28

Speaker A

time variant and which ones are time invariant all right which ones are time variant and which ones are time invariant all right so just give us just give us a little exercise in terms of in terms of understanding these two

30:45

Speaker A

different concepts notice here i'm saying time invariant omitted variables i could also say unobservables but i'm just right now i just want to specify the distinction between time variant and time invariant and recognize that in this particular regression there are a lot of

31:02

Speaker A

omitted variables in this error term okay they may or may not be observed okay so time variant variables so let's think what are some variables that are going to differ between people and differ across time so one example might be experience that

31:21

Speaker A

means as time goes on people gain more experience so experience will vary across time in 2015 people will probably have less experience than they have in 2018 it's hard to imagine it going the opposite way okay so experience varies across time it

31:42

Speaker A

also vary across people that means different people have different amounts of experience okay marital status so marital status might change across time obviously it changes between people some people are married some people are not but it also can change across time

31:58

Speaker A

single people can get married married people can get divorced okay so marital status can change across time it's time variant it varies across time the number of children number of children can vary across time as you go from 2015 to 2018 people can

32:17

Speaker A

have more children and so the number of children that someone has varies across time various economic indicators can change across time the the economy can grow at different rates at different times and so these are all variables that will

32:33

Speaker A

change across time they're time variant they vary across time and these are also all variables that are omitted from our model okay what about time invariant omitted variables so what are some time invariant variables variables that do not change across

32:54

Speaker A

time what are some variables that do not change across time uh well how about ability now this might be debatable but we might be able to say that someone's ability someone's innate competencies don't change some people's innate competency

33:11

Speaker A

competencies do not change over time and so there might be a time invariant variable that means it uh it varies between people some people have some some people just have different levels of ability but it does not change over time that

33:29

Speaker A

means uh my innate competencies are the same today as they are a year from now okay or intelligence it's the iq we might argue and this is debatable we might argue that people's iq their their latent level of intelligence

33:46

Speaker A

doesn't change over time they might change their level of education they might change the amount of knowledge they have but their innate intelligence doesn't change now it'll differ between people some people have a higher iq and some people have a lower iq

34:01

Speaker A

but it doesn't change over time we can argue that and someone might argue that it does but we might be able to argue that it doesn't uh the city of residence well that might change and so we might

34:12

Speaker A

that's debatable depends on the time frame um the city of residence might change um but it might not uh home country that won't change where somebody is from will not change um where they were born will not change

34:28

Speaker A

over time it will be different between different people but will not change over time okay so here are some examples of time variant and time invariant um omitted variables so if these variables are not in our data set then these

34:43

Speaker A

var these will be time invariant on observables and these will be time these are time variant unobservables these are time invariant unobservables okay so now um so we're building our way up we're working our way up so i'm saying that

35:00

Speaker A

panel that panel data is really it's a powerful tool because when we use panel data we can we can dissect our error term into these two components all right well it's not yet clear exactly why that's so powerful but i will show you as we keep

35:17

Speaker A

going all right so now what do i want to do well let's take that this disaggregated this disaggregated error term and put this back into our original regression here all right so this uh this results in the following regression

35:33

Speaker A

model which we can call a fixed effects regression model or a fixed effect a fixed effects model you'll notice this is the same standard model that we had before so it's this model except now we're plugging our our disaggregated error terms in for

35:50

Speaker A

epsilon okay and now this error term this error term that accounts for the time in variant unobservables or the time invariant omitted variables this a i we call this the individual fixed effect so an individual fixed effect is a term

36:12

Speaker A

that accounts for all the variation in the dependent variable that does not vary across time and is thus fixed across time which is why it's called fixed effect it's a fixed effect it's fixed across time we call it an individual fixed effect

36:28

Speaker A

because it varies between individuals and is fixed across time now in this lecture i'm going to pretty much exclusively talk about these kinds of fixed effects individual fixed effects you'll find when you do research that you could also have other

36:44

Speaker A

fixed effects you'll you can use fixed effects for different types of variation in your data but for now we'll stick to this so this fixed effect variable this ai it varies only for individuals it captures all the variation in the

36:59

Speaker A

dependent variable due to differences across individuals but it's fixed across time all right so this a this a i term it accounts for all the variation in the dependent variable that is due to differences across individuals all right that isn't captured in the

37:26

Speaker A

regression model so it accounts for all the variation in the dependent variable due to differences across individuals all right so this is it's very significant to notice this individual fixed effect and differentiate it from uh the other error term

37:44

Speaker A

now so here we go we're building our way up we're building our way up all right i hope that the anticipation is building dr galestein why is panel data so powerful why is it so useful um okay so we're getting close the power

37:58

Speaker A

of panel data models is that it allows us to control for this ai it allows us to control for the time invariant on observables so if we control for ai then we will not have any omitted variable bias that is

38:17

Speaker A

due that is due to time invariant on observables we will not have enumerated variable bias that is due to time invariant on observables we eliminate one kind of unobservable variable and therefore one potential source of emitted variable bias

38:39

Speaker A

okay so the power of panel data models is that it allows us to control for this ai it allows us to control for and eliminate all the time invariant on observables now in the past in the past when we've

38:56

Speaker A

worked with a regression model with a cross-sectional regression model we have only been able to control for uh observable variables we've only been able to control for variables that we have that we include in the model so we're

39:13

Speaker A

only able to control for variables that are observable you can remember this also from when we discussed propensity score matching when we use propensity score matching if you remember the first assumption is selection on observables that means that means propensity for matching only

39:32

Speaker A

works when i can assume that that basically that my only omitted variables are observable variables and therefore i can account for them using the data in my data set all right that's a very restrictive assumption it's very restrictive when i

39:49

Speaker A

can only rely on observable information on observable variables what panel data allows us to do that's why this is so powerful and so interesting and so exciting i hope you're excited okay why this is so significant is that we can use panel data to control

40:08

Speaker A

not only for observable variables but also for time invariant unobservables we can control for everything for all the unobservable variables that vary across time or that i'm sorry that do not vary across time that means we eliminate an entire source

40:28

Speaker A

of potential omitted variable bias we eliminate an entire section of the of our error term that's quite significant okay so let's uh let's try to make this more clear so in panel data models we can control for a i we only then need to worry about

40:48

Speaker A

omitting time variant on observables okay so if we think that we can use other independent variables in our data set to control for all time variant factors that affect both x and y then we will obtain an unbiased beta 1

41:04

Speaker A

hat that means if we use a panel data model we're able to control for all the time invariant on observables and therefore if we can assume that we can control for the time variant in unobservables the time variant factors if we can assume that we

41:25

Speaker A

can control for all the time variant factors using independent variables in our regression model then we are able to get an unbiased coefficient all right so panel data models allow us to eliminate an entire entire section an entire portion of our

41:41

Speaker A

of our variable bias all right so um so let's go back here and and let's apply this to our example so the impact of education on wages all right so we have this uh regression model again except now

41:55

Speaker A

when we're looking at it we're disaggregating the epsilon into the two component error terms ai and vit all right now we've got some time variant omitted variables and we have spent some time in variant omitted variables so time vary intermittent variables is

42:14

Speaker A

experience marital status number of children and and i changed this last one um professional network okay and then time invariant unobservables we're saying ability intelligence city of residence like i said that one that that one you can easily see that as a time

42:29

Speaker A

variant one because people can't move between cities okay and then home country which is definitely a time invariant emitted variable okay so these are some different variables and so what we can do is this we can include the independent variables

42:45

Speaker A

that are time variant that means they change over time so so here are the time variant omitted variables so if we have data on experience marital status the number of children the some measure of people's professional network things that change over time all right

43:03

Speaker A

we're going to include those in the model we can include those in the model i'm realizing that i need to give a t here there we go all right we can include all these time variant independent variables in

43:19

Speaker A

our regression model and then we can use a panel data model to control for a i and if we do that then we will get an unbiased estimate of beta 1 which is what we want so if we include independent variables

43:35

Speaker A

for all time variant factors and use a panel data model to control for a i the time invariant factors then we will obtain an unbiased beta 1 hat alright so then this is a powerful tool all right so next we will see two kinds

43:54

Speaker A

of panel data models there are others but we will focus on two in this in this class in in this lecture these models will demonstrate how we use panel data to control for ai but real quick first let's just be clear

44:11

Speaker A

about an assumption that we're making so for panel data models for the ones that we use in this lecture to produce unbiased estimates you must assume that we have selection on observables and or selection on time invariant unobservables

44:28

Speaker A

so let's relate this the independent variable of interest is not correlated with time variant with the time variant error term after including all the relevant time variant independent variables that you have in your data so what's that mean

44:44

Speaker A

that means that there is no correlation between the independent variable of interest and the time variant error term conditional on the fact so long as we control for time variant independent variables this is w time variant independent variables and

45:04

Speaker A

we are controlling for the time invariant factors all right so this expression means that the independent variable of interest x i t is not correlated with the time variant error term v i t if we control for the time invariant

45:20

Speaker A

factors ai and the time variant of observables in our data set wit this implies that we do not have emitted variable bias all right we can only validate this assumption by intuition we have to ask ourselves the question

45:36

Speaker A

can we make a strong conceptual argument for why we think that the independent variable of interest will not be correlated with the time variant on observables all right that can be hard to do but that's that's the goal you have to make it a

45:53

Speaker A

conceptual argument for whether or not this assumption holds all right with all of that said i will now begin the process and finish the process of explaining or you know illustrating two different models two different two different panel data models that we

46:14

Speaker A

can use to control for those time those time invariant unobservables all right the first one is called the first difference model and then the next one will be the fixed effects model all right and then after that i'll talk

46:30

Speaker A

briefly about standard errors and then we'll get into a stata demo for both of these models all right first difference model all right so remember our regression kind of our our our uh regression here where we have y

46:49

Speaker A

our dependent variable which varies across individual and time uh we have t which varies across time it's the time variable x the independent variable of interest which varies across individual and time we have our error term that accounts for the unobservables the

47:06

Speaker A

time invariant on observables and the error term that accounts for the time variant on observables all right so we first need to recognize that we do not observe ai directly it is an error term after all we're saying that this is a part of

47:19

Speaker A

the error term we don't observe a i directly therefore we cannot include ai in the empirical regression that means ai isn't a variable we don't have the ai variable in our data set so we can't just include the ai variable it's an error

47:34

Speaker A

term so if it's an error term how do we control for it if we cannot directly include it in the regression all right well both of these models are going to show you how two different ways of doing it let's do

47:46

Speaker A

the first difference first all right so here's our generic regression the first difference model takes the difference between time periods time period one and two and by taking the difference we will eliminate the ai all right so consider the following

48:03

Speaker A

regression models for when t equals one and when t equals zero all right so basically we're going to take this model and we're gonna first um look at we're gonna first see what it looks like when t equals one

48:16

Speaker A

and then we're gonna see what it looks like when t equals zero all right so let's do that so when t equals one what does this regression model look like when t equals one so first this is the second time period

48:32

Speaker A

so we have y i and then the second time period so that's 2. all right we have beta 0. the t if it equals 1 is just 1. and so you have delta 0 delta being the coefficient on t here so

48:46

Speaker A

you have beta0 plus delta zero okay you have x i t at this t so so capital t equals one when lowercase t equals two so because the second time all right so we have this we have a

49:01

Speaker A

i again all right and then we have the our term okay now what happens when t equals zero uh very similar the subscript for the lowercase t is now one all right but the capital t equals zero and so you get rid of this delta zero

49:19

Speaker A

all right so here we go the use of the this here this is what the regression model looks like when t equals one so this is making it basically in the second time period and this is what the regression model

49:29

Speaker A

looks like in in when capital t equals zero so in the first time period now take the difference that is subtract the two models subtract this model from this model all right so here we find the difference you have y i 2 minus y i 1

49:46

Speaker A

equals beta 0 plus delta 0 minus beta 0 plus beta 1 x i 2 minus beta 1 x i 1 plus a i minus a i plus v i two minus v i one all right so reiterating here

50:04

Speaker A

and now and now simplifying we see that the beta zeros cancel out we see that the alpha i's cancel out and we can also pull out this beta 1. so now we have y i 2 minus y i 1

50:22

Speaker A

equals delta 0 plus beta 1 times the the difference in the x's plus the difference in the error terms now notice that a i cancels out all right so here's the big thing when we do the first difference model

50:37

Speaker A

and we subtract we subtract all this information across time the ai term cancels out so here you can see the panel data here you can see that the panel data by taking a difference eliminates all the time invariant on

50:54

Speaker A

observables all right because if you take the difference the time and variant on observables cancel out all right so you have this and now we just rewrite these terms in term in terms of differences so y i 2 minus y

51:10

Speaker A

i 1 well that's a person i's dependent variable in the second year minus person i's dependent variable in the first year so this is just the change in person i's dependent variable it's just the change in personalized dependent variable so

51:29

Speaker A

we'll use this delta this is delta the greek letter delta to represent the change in y so delta the change in y all right so we have the change in y equals lowercase delta 0 plus beta 1 times the change

51:45

Speaker A

in x so delta x plus now the change in the error term all right so here's the first different regret the first difference regression it is composed of the change over time of the dependent variable regressed on the change of the

52:02

Speaker A

independent variable you'll notice so you'll notice that now this model is cross-sectional it is only indexed by i because we've differenced out the changes across time all right so we have y we have the change in y and we have the change in x all right so

52:25

Speaker A

it only varies between individuals it does not vary across time because the time differences have been removed right beta 1 hat will be unbiased so long as there's no correlation right between the change in x and the change in the error term

52:41

Speaker A

all right which is equivalent to the assumption i made before okay that is the first difference model i'll illustrate that in stata all right fix effects model basically the fix fx model we do pretty much the same thing but

52:56

Speaker A

just procedurally different and there are some subtle differences between the two models the fix fx model is much more common than the first difference model and i would recommend using it in most situations so let's but let's let's continue and

53:13

Speaker A

you'll notice that we do a very very similar thing here all right so here here's our original regression again the fixed effects model differences out the mean of each variable over time and this eliminates a all right so we're doing a

53:29

Speaker A

very similar procedure here to get rid of ai to get rid of the time in variant on observables so consider the above model where each variable is averaged over time so that means uh let me let's take this let's take

53:44

Speaker A

this regression and imagine that we we calculate the average for each of the variables so the average y variable across types we're averaging it across time we're averaging it across time all right so we take the average of the y

54:00

Speaker A

variable across time and so we get y bar i so this is the average dependent variable for each across time all right and then here this is connected to the intercept it's basically beta0 times one and the average of one

54:20

Speaker A

is one so here we go and then here's the time variable the average of the time variable across time is just again the time variable so there's no change here all right and so now we here we take the average

54:33

Speaker A

of the x i t variable over time uh and so we get x bar i okay we take the average of the ai variable over time which this does not vary over time and so it remains the same

54:48

Speaker A

no change when we take the average uh and then finally we take the average of the error term across time and so we get v i bar you can see now in this in this regression there's no variation across

55:01

Speaker A

time so in this model there's no variation across time we're taking the means then what we do is we take the difference so basically we take this model and we subtract this model from it alright so here is our our difference

55:15

Speaker A

model and we can simplify it all right and so what we do is basically we just simplify this down and when you look at it beta 0s cancel out delta 0 t t cancels out so these cancel out

55:32

Speaker A

these cancel out a i cancels out and what we do is we take this y minus y bar x minus x bar and v minus v bar and create new variables that we call uh y and we have these two dots to

55:50

Speaker A

basically represent that it's the d meaned y uh so y minus the mean is y uh with the two dots x minus the mean is x with the two dots and then v minus the mean is with two

56:05

Speaker A

dots and so now you'll notice here that a i again cancels out so here you can see that the panel data by taking a difference eliminates all time invariant on observables all right so again we are eliminating all the time invariant on observables

56:22

Speaker A

and here is the fixed of x regression it is composed of the demeaned dependent variable regressed on the d mean independent variable what do i mean by demeaned i mean it is it is so the dependent variable minus

56:37

Speaker A

the the average across time so we are removing the mean we're removing the average and so that's why we're calling it d mean the d mean dependent variable and the d mean to independent variable and the d mean to error term

56:54

Speaker A

so this is the fixed effects regression model notice that this model is still panel data it is indexed by i and t all right so the fixed effects model removes the time invariant on observables by subtracting the means of each variable over time

57:08

Speaker A

because the time and variable factors do not change over time the means the same as the observation and they are eliminated from the model all right so beta 1 hat will be unbiased as long as there's no correlation

57:20

Speaker A

between the d mean x and the d meaned error term all right a couple final points before we do standard errors we're really we're we're close to the demo um all right two two quick points or hopefully quick all right so panel data

57:37

Speaker A

models discussed here will include only time variant independent variables that means if you include independent variables in your regression you will only include variables that vary across time you will not include variables that do not change over time you will not include

57:57

Speaker A

time invariant control variables because the panel data model will absorb those effects alright so when you're picking out variables to go in a panel data model and one of the models that we're showing you a fix effects model

58:09

Speaker A

you will not include independent variables you will not include independent variables that do not change over time all right that's point number one point number two it's just a couple wrapping up points the panel data models that we've

58:27

Speaker A

discussed here will not include time variant independent variables that change linearly with the change in time i think the best way to explain that is to use a couple examples but the point is this there are some independent variables

58:46

Speaker A

that do change across time and you still won't use them you won't include them in your regression let me give you some examples so for example if year what let's say let's just say that year one is 2015 and year two is 2016.

59:02

Speaker A

all right so we have two years of data chosen 15 2016. if you did that you're going to run a fixed effects model then you will not include variables such as age or experience in the regression age will increase by one between years

59:20

Speaker A

and so the change in the age variable is identical to the change in time right so just so age does change across time it is time variant it varies across time but age varies across the exact same it varies in the exact same way as time

59:37

Speaker A

does if if one of my panels one of my years is 2015 and the other year is 2016 then age will change also by one years change it by one and age is changing by one and so we will not

59:51

Speaker A

include age because it's changing by the exact same amount as the change in time all right so that's the first thing now why not experience well this is debatable okay so we can debate this um but likewise if the vast majority of

60:07

Speaker A

your sample gains one year of experience between year one and year two you cannot include experience because the change in experience will be identical to the change in time so my point here is this let's say that you're doing this

60:20

Speaker A

regression model and you have experience as one of your variables but every single person in your data set increases their experience by one between 2015 and 2016.

60:32

Speaker A

that means nobody takes a year off basically if everyone's level of experience goes up by one between year one and year two then you would not include experience because it's changing linearly with the change in time it's going up

60:47

Speaker A

in time by the exact same amount as time is changing all right so you wouldn't include that either okay so those are just two final points all right lastly standard errors i'll just go through this quickly and then

60:57

Speaker A

we'll get into this data demo all right so when we're using panel data model we must be careful to estimate unbiased standard errors just as in the standard ols models so remember uh remember when we did uh standard cross-sectional regressions

61:14

Speaker A

we talked about heteroskedasticity we needed to control for heteroskedasticity or else we might get unbiased uh we might get i'm sorry we might get biased we might get biased standard errors if we didn't control for heteroskedasticity all right however given that panel data

61:31

Speaker A

has a time component we must also be careful to avoid serial correlation as well so heteroskedasticity is when the variance of the error term is correlated with the independent variables we've talked about that before serial correlation is when the error

61:43

Speaker A

term is correlated with itself over time all right we're not going to talk extensively about serial correlation but we just need to remember that because there's a change in time uh there's an additional component of of of possible bias in our standard errors

61:58

Speaker A

that we need to control for uh just in practice and we could go into tremendous detail on this but i i'm just going to kind of mention what we do in practice to solve these problems in panel data we

62:08

Speaker A

use robust standard errors and these robust standard errors are just a little bit different than what we did the robust standard errors do control for heteroskedasticity but we use a special kind of standard error that will allow us to control

62:21

Speaker A

for the serial correlation as well and so what we'll do as you'll see when we do the fixed effects model is that we will use cluster robust standard errors that cluster at the cross-sectional unit okay i'll show you what that looks like

62:36

Speaker A

in the data all right so with that said let's do some panel data in stata all right so what we're going to do is we're going to use we're going to do fixed effects regression we're going to do fixed effects

62:50

Speaker A

regression all right we're going to use we're going to fix the fx regression first and then we're going to go to the fix the first difference regression second uh i know we're going in the opposite direction of what i of what i did in the

63:04

Speaker A

lecture but i have what i did in the slides but i have my reasons all right so let's go ahead first now that we've got our data okay first let me just point out wage fe i'm using the wage fe

63:17

Speaker A

data all right i'm using the wage fe data the wage fixed effects data all right i'm using the wage fix effects data all right so here we go the first thing i want to do all right actually stepping back the purpose of

63:32

Speaker A

this regression let's come over here let's just be clear this is a panel data set we want to use this panel data set to estimate estimate the impact of education on wages the all right the the panel includes

64:04

Speaker A

variation across across individuals just like a standard cross section and it includes variation across time in this case we have two years of data we so we have data on 505 individuals collected for two years 2015 and 2017.

64:55

Speaker A

all right so that's what this data looks like we want to use this now let's visualize it first i want to i want to make sure that we understand what what what what panel data looks like all right so

65:09

Speaker A

this is here's panel data all right so here's our data set we have we have a we have a variable here that indicates for the individual now perhaps i should take a moment in the past at times we've had data sets that have a

65:24

Speaker A

have an id variable and other times we we haven't in the past when i've used this wage data set i have not had an individual id an individual id is just a number that uniquely labels a specific person or

65:39

Speaker A

specific time so in this case the id number this is a unique individual id so that means when the id number equals 1 that is person number one that is a person that is one person id when the id variable equals two that

65:56

Speaker A

means it labels person two all right when id variable equals three that means person three so these numbers they don't have um this is i wouldn't even call this a categorical variable although perhaps you could it's a label this variable just labels

66:14

Speaker A

your data okay that means that means you never include the id variable in a descriptive statistics table okay if you ever put together a descriptive statistics table do not include the id all right the id is the idea is not it's not technically

66:33

Speaker A

a variable in the way that we would think you don't include it in your regression the id variable labels the information in your data set okay all right so we have id for the id for individual all right

66:50

Speaker A

and then we have this variable for year this indicates the year so zero we can come over here and look at it equals zero if the data comes from 2015 and equals one if the data comes from 2017.

67:03

Speaker A

all right so here we go what we have here is we have person one observed in 2015 so year zero or 2017 year one all right and so and we have their information for these different years so we have

67:23

Speaker A

person one's wage in 2015 and person one's wage in two 2017. we have a person wants education in 2015 and we have person one's education in 2012. we have their experience we have uh their ethnicity we have their gender

67:39

Speaker A

we have whether or not they're married we have the gdp growth rate in those years we have their network connection we have their iq whether or not they work in the service sector manufacturing sector or agricultural sector et cetera all right so we have we have

67:56

Speaker A

information for each person for two different years and so we have variation across individuals that means our information differs between different people and we have variation across time that means for each person we have variation between we have variation across time

68:19

Speaker A

now as we look through this data set we might be able to see what variables we could consider to be time variant and time invariant so time variant variables would be variables that change over time time invariant variables are variables

68:36

Speaker A

that do not change over time okay so year changes across time obviously it's the year wages are going to change across time so this is a time variant variable it changes across time it's time variant education level will change

68:54

Speaker A

across time so that's time variant experience will change across time so that's time variant ethnicity will that change across time no that is time invariant uh will gender change across time know that it's time invariant will marital status change across time

69:14

Speaker A

yes it can at least people can go from being single to married or be married to single and so the married variable the the married variable is a time variant variable it changes across time gdp growth does that change across time

69:30

Speaker A

yes time variant your network connections the level of network connections that will vary across time all right so it's time variant iq we're going to say that iq is doesn't change across time and so iq stays the same for each person

69:51

Speaker A

across time so that is time invariant time invariant does not change over time what sector of the economy you work in that will change over time people can switch sectors so that's time variant so we have three different sectors here

70:08

Speaker A

we have the service sector manufacturing sector agricultural sector okay so just looking through our data we can see some different time variant and time invariant variables now obviously we have omitted variables or missing variables obviously there's other things that affect people's wages

70:23

Speaker A

that we don't have data for and those things that are omitted those things that are missing from our data set these unobserved variables they could be time variant or time invariant okay all right so that's what our data

70:37

Speaker A

looks like with the panel data set all right so then let's let's run a regression first first let's do the naive model what's the naive model with panel data the naive model might be to just run an ols regression

71:00

Speaker A

of wage on a bunch of independent variables we want to know education so we do education and experience and um non-white female and married we just include some variables here gdp growth network iq service okay so the naive model doesn't take into

71:30

Speaker A

account the fact that we have panel latest the knife model does not account for the panel data it does not account for the fact that we have variation over time and across individuals and it does not take advantage of

72:02

Speaker A

our ability to to control for time and control for time invariant on observables all right all right so it's just a straightforward regression so we can run this we can run this and see what we get let's see let's increase this

72:36

Speaker A

nope oh you know what i'm looking at the wrong do file i apologize here we go this look at the wrongdo file here we go let's run this thing hmm all right let's just don't save let's open up another do file

73:09

Speaker A

here all right now let's run it here we go alright so here we go so here's our regression uh we find education is positive and significant we find ethnicities negative and significant we find gdp growth is highly negative and

73:31

Speaker A

significant uh iq is positive and significant okay so we find a bunch of stuff but now but now will our estimates be biased in the naive model in the naive model we have not accounted for or controlled directly for time okay

74:00

Speaker A

so time will be an omitted variable so time will be an omitted variable so we'll probably have a minute variable bias well why is that well because time probably affects wages and time also probably affects uh the amount of education that people have

74:21

Speaker A

as uh as as time moves forward education probably goes up on average and so the correlation between time and and education is positive and i would assume the same also for wages and so we'll probably have some upward

74:34

Speaker A

bias all right so um sort of emitted variable bias here but more importantly in the naive model we have not controlled for time invariant on servables therefore if we think that there are some time invariant if there are some time

75:11

Speaker A

invariant factors that are omitted and would be would be related to wages and education then then we will have omitted variable bias okay so do we think do we think that there are any factors that might be omitted from this model

75:42

Speaker A

any factors that are time invariant that are time invariant they do not change over time but are omitted well i gave two in the lecture so so possible uh possible examples of time invariant time invariant omitted variables so two possible examples could

76:10

Speaker A

be uh ability and we might say that iq measures ability but maybe not um and then we also could say um a home um country of origin origin okay those are two things that are not going to change over time

76:31

Speaker A

but could have an effect on wages and educational level and so this model is not controlling for those two things and so we'll probably have them in the variable bias so this won't work so let's do a fixed

76:46

Speaker A

effects model all right and now i'm just going to show you how to do this in stata all right i'm just going to show you the commands we're not going to do this by hand first what we do is we do a command

76:57

Speaker A

called xt set in this case what we're doing is we're setting our fixed effect we're setting our fixed effect all right so let me let me explain this step one set the fixed effect all right the fixed all right the fixed effect is

77:21

Speaker A

the level is the observational unit that we control for basically the observational unit that corresponds to that a i variable that we had in our lecture all right so in this case xt set id all right in this case we want we want

78:04

Speaker A

to control for we want to control for all variation all variation between people that does not change over time all right so we use id this id variable indicates for the individual all right step two specify the fixed effects model all right so here we

78:44

Speaker A

go we do x t x t reg we put our dependent variable we got a control for the time and then we have our independent variable of interest and then all right so now remember you can only include time

79:07

Speaker A

variant variables the time invariant variables will be controlled for by the fixed effect all right so let's go through it can we include education well yes that's our independent variable of interest what about experience now in the lecture i mentioned that we

79:36

Speaker A

can include experience um if there's if basically if the change in experience is different than the change over time in this example we have two two years have passed between the first data set in a second if every single

79:53

Speaker A

experience variable goes up by two that means everyone just gets two years of additional experience then we wouldn't include experience because it's changing at the same rate as the time so let's take a look let's just get an idea

80:05

Speaker A

all right so two years have have passed and so if if if the experience level goes up for each person by two then we need to exclude experience so let's see do we see that so reverse for so for person one

80:20

Speaker A

experience goes up by one year for person two experience goes up by one year person three goes up by one year for person four does not go up at all for person five it goes up by two year

80:30

Speaker A

okay so no problem experience changes in a way that's different than just a linear change over time so we can include experience all right can we can we include non-white no that's time invariant can we include female no that's time invariant can we include

80:49

Speaker A

married yes can we include gdp growth actually we won't include gdp growth because the gdp the annual the average annual gdp growth is the same in 2015 as it i'm sorry the and the average annual gdp growth is one variable for 2015 and it's

81:11

Speaker A

one variable for 2017 so that means it will be perfectly multi-co-linear with the year variable so we cannot include gdp growth all right what about network yes that can change over time so let's do network iq we're saying that's time invariant it

81:29

Speaker A

doesn't change over time so we can't include it what about the sector of the economy that can change over time so we can we can include that um let's just let's just do service all right so now then we need to specify

81:43

Speaker A

a couple more things we put fe that means fixed effect fe means fixed effect and then i mentioned to you this a different error term thing um we need to use robust standard errors and they need to be clustered at the

82:01

Speaker A

at the observational unit so we're going to do vce that's just a code for a different kind of robust standard error cluster id all right so there we go let's run these two things this is going to give us our fixed

82:13

Speaker A

effects estimate there we go this is going to give us our fixed effects estimate okay now let's see why was education dropped from the model let me take a look why is education being dropped from the model it's because education looks like

82:39

Speaker A

it's going up by one for every year that means i didn't code when i created my education variable i didn't code it very well so that's a mistake i'm just going to edit uh this later but uh let me see

82:57

Speaker A

here jen um all right jen let's see chin all right now oh yeah that's perfect okay so here we go uh so we've set this up we have x x t set id and then we have x t reg and

84:11

Speaker A

now all we do is run this so you see our naive model here now we're going to run this fixed effects model all right and here we go here's our fixed effects model all right here's our fixed effects model we have

84:26

Speaker A

our dependent variable we have all of our independent variables year is highly significant so that means wages are going up over time that makes sense we have education and now we should be getting an unbiased coefficient on education as

84:42

Speaker A

long as we think that there are no omitted variables that are time variant so time variant omitted variable or time variant relevant um omitted variables all right so and so um it's significant at the five percent level and then so on

85:02

Speaker A

all right nothing else is significant all right so our coefficient our coefficient estimate is 0.23 and it's significant at the 5 level those stars mean significance well let's just write it out significant at the 5 level all right significant five percent

85:30

Speaker A

level okay all right so our coefficient estimate is zero point two three and it's significant at the five 5 level now the question is is this biased or unbiased and now that is going to be based entirely on whether or not we can make

85:49

Speaker A

an argument for for whether or not we have controlled for all the time variant unobservables are there time variant observables are there things that we do not include in the regression that are changing over time that will be

86:07

Speaker A

correlated with education and with the wage we'll talk more about the intuition for this um in class all right so if we think so let's just let's just let's assume let's assume for now that there are no relevant

86:28

Speaker A

time variant on observables if that's the case then we would say that an additional year of education education causes wages to increase by 0.23 dollars per hour okay all right so there we go this is uh lecture number 15 panel data fix

87:14

Speaker A

effects model now i am going to switch over all right now i'm going to switch over to a different data set and illustrate and illustrate the first difference model all right so this one over here is going to be the

87:38

Speaker A

first difference model all right now to use the first difference model we need to have data that's just a little bit different all right this data so when we use a first difference model basically it has the same information

87:55

Speaker A

but it's just organized differently in the last data set we had the data that was basically stacked on top of each other so for each individual person we had two observations and it was diff and there are different

88:09

Speaker A

observations by year now what we have is basically we've organized our panel data in a different way all right so for each person for each individual we only have one uh we only have one observation basically and so we've only one row okay but

88:30

Speaker A

i have two versions of each variable i have the 2015 version of the variable which i just call wage and 2017 version of the variable which i call wage 17.

88:41

Speaker A

i have the 2015 variable of education and of the 2017 variable of education 2015 variable for experience 2017 variable experience so you can see i have the variables set side by side i have the variable set side by side to

88:57

Speaker A

each other instead of stacking them basically i i can organize my data in two different ways i've organized it this way so that we can do this first difference in a little bit more intuitive way all right okay so here we go

89:14

Speaker A

first difference all right first difference now to do a first difference model the first step so step one is create the difference variables so create the difference variables all right so that means we need to go through and we need to generate a

89:39

Speaker A

difference variable what i'm going to call uh delta wage equals the wage in 2017 minus the wage in 2015.

89:51

Speaker A

wage d educ equals education in 2017 minus education in 2015. gen d experience so this will be the change in experience let's see let's make this more clear okay experience 17 minus experience of 2015. all right generate the change in i'm going to do network

90:24

Speaker A

first i'm going to come back to married in a second because that will have its own unique uh requirements so network so we've got gonna put that d there gotta put that d on it all right all right network 17 minus

90:43

Speaker A

network all right gen all right do we do non-white no it doesn't change over time do we do female no it doesn't change over time do we do gdp growth all right let's skip that one iq do we do iq no it doesn't change over

91:06

Speaker A

time okay actually let's let's let's go ahead and let's do change in gdp growth all right gdp growth 17 minus gdp growth all right all right so here are a bunch of variables we're creating these variables they are the change in variables

91:31

Speaker A

we don't create change variables for the variables that don't change over time these are the change across time alright so you take the 2017 version you subtract the 2015 version all right so there we go um now i skipped one i skipped married

91:49

Speaker A

okay i've married equals one if married in 2015 and then married 17 equals one if they're married in 2017. well this creates some unique this creates a unique situation if i create the difference just imagine this if i did married 17 minus married

92:05

Speaker A

i would get some very interesting results so let's just look at the married variable so here we go married now if i did married 17 minus married 15 i would get zero minus zero so that would be zero

92:17

Speaker A

one minus one that'd be zero zero minus zero would be zero one minus one okay these are all zero all right but now we if we look closely enough we might find someone that's different let's see if is there anyone in here that changes

92:29

Speaker A

over time i'm betting that there is let's see is there anyone that changes over time is there anyone that changes over time if they don't change over time then this will be a time invariant variable and we don't need to

92:44

Speaker A

create a difference but i think i think that they're different i think that we could find an example of them being different all right let's see let's see i haven't found one yet so not very different um well this might

93:01

Speaker A

not be the way to show you let me let me go well let's actually let's check it let's see if these are these let's see if these vary across time some married uh married 17. actually these guys have exactly the same mean

93:17

Speaker A

they have exactly the same mean well this actually might be a time invariant variable in this data set this might be a time invariant variable that means no one got married and no one got divorced let's do delta married and let's see but

93:32

Speaker A

it looks like they're identical it looks like they're identical all right so let's just we'll just verify it married 17 minus married okay all right let's create all these variables let's run this boom all right so now we've created all these difference

93:49

Speaker A

variables i'm going to check that married variable all right let me check that married variable actually oh whoops some d married it's zero okay in this data set married does not change over time no one got married and no one got

94:09

Speaker A

divorced okay all right so there we go there we go we have our change variables so now what do we do we run a cross set we run a regression like it's a cross-sectional regression so we do reg

94:24

Speaker A

the change in wage equals the change in education oh sorry we don't use equals here all right change in education change in experience change network change in gdp growth and then i i thought we would use change in married but actually in this data set

94:46

Speaker A

there is no change uh and so we exclude that all right and then we'll use our robust standard errors all right so let's run this regression we've season we just use ordinarily squares okay let's see here so you

97:33

Speaker A

so okay so here we go uh we have all of our different var we have all of our difference variables and so we're just going to run our regression with all of our difference variables oh let me let me close this down

99:46

Speaker A

all right so here we go we've got so the change in wage all right we have the impact of the change in education impact of the change in experience and impact of the change in network and then the change in the gdp growth is

99:59

Speaker A

omitted all right i'll come back to that just a minute a moment ago i hesitated on creating this change variable but i'll show you why i'll show you why this is omitted just a second all right so first let's just notice

100:12

Speaker A

that here as long as our assumptions hold as long as we do not have any omitted variables that are related to wage and education that are time variant then these are unbiased coefficient estimates or this is an unbiased coefficient

100:32

Speaker A

estimate for for education so basically the impact of education on wage all right so here it is um it is insignificant now i will note that this particular data set slice slightly different than the other one and so it's

100:47

Speaker A

the reason that the result is different is not because the method would necessarily give you different results sometimes they do sometimes they don't but the reason that this is the is that the data sets a little bit different

100:58

Speaker A

okay so then let me just quickly clarify what this delta gdp growth variable is why this is omitted why is it emitted so let's look at the data set and and see so if you look at gdp growth

101:14

Speaker A

gdp growth is the same for every single person well why well that's an economy-wide measurement the gdp growth in the united states 2015 and this is the gdp growth in the united states in 2017 every person in our data set is from the

101:31

Speaker A

united states and so this variable does not change between different people it does not change it is not individually variant is not individual variant okay so when we when we take the difference between them the difference is just

101:51

Speaker A

the difference is just 0.6 basically it's just 0.6 for everyone it's the same number for everyone in the data set all right so then when we include it what happens is is that the delta gdp so the change in gdp is multi-co-linear

102:10

Speaker A

it's perfectly multi-collinear with the constant term which is just a vector of ones and so as you remember from multicollinearity if you have perfect multicollinearity one of those variables needs to be dropped and that's why this variable got dropped

102:25

Speaker A

all right okay so there we go that's illustrating how to use the first difference regression now in this case our coefficient estimate is 0.15 we conclude that we conclude that education has no impact on wages all right thank you very much and i hope

102:54

Speaker A

you have a great day

Topics: panel data cross-sectional data time series data omitted variable bias fixed effects first differences time-invariant unobservables serial correlation econometrics regression

Study this video

- [Flashcards from this video](https://sozai.app/tools/flashcard-maker/?from=transcript&id=91959)
- [Quiz on this video](https://sozai.app/tools/quiz-generator/?from=transcript&id=91959)
- [Crossword from this video](https://sozai.app/tools/crossword-maker/?from=transcript&id=91959)
- [Word search from this video](https://sozai.app/tools/word-search-maker/?from=transcript&id=91959)
- [Study guide from this video](https://sozai.app/tools/study-guide-maker/?from=transcript&id=91959)

Free, made by AI from this transcript. No signup.


---
This is the markdown twin of https://sozai.app/transcript/lecture-13-panel-data/ — the same content, without the markup.
Published by SozAI (https://sozai.app). Reuse and quotation are allowed with attribution and a link back.
Machine-readable index: https://sozai.app/llms.txt · data API: https://sozai.app/api/
