8 Fixed Effects Regression (Powerpoint)
8 Fixed Effects Regression (Powerpoint)
Jonathan Wörn
Presentation, data and programs at:
https://bit.ly/3ItnOGj
22.03.2022 J.W. 1
Today’s menu: Fixed effects
22.03.2022 J.W. 2
Idea & Examples
22.03.2022 J.W. 3
Fixed Effects
• A method to get closer to causal estimates with non-
experimental, observational data
• Is change in X associated with change in Y?
• Repeated measures / panel data
• Rules out confounding from time-invariant factors
– Neither observed and unobserved factors
22.03.2022 J.W. 4
Examples
22.03.2022 J.W. 5
Examples
22.03.2022 J.W. 6
Examples
22.03.2022 J.W. 7
Idea
Social participation and depressive symptoms
7
6
Depressive Symptoms
6
Depressive Symptoms
4 Cross-sectional
regression
3
6
Depressive Symptoms
6
Depressive Symptoms
22.03.2022 J.W. 12
Model
• Pooled linear regression for panel data
• Biased estimates if
22.03.2022 J.W. 13
Model
• … resulting in error components model
22.03.2022 J.W. 15
Syntax, Interpretation,
Sample Selection
22.03.2022 J.W. 16
Syntax
22.03.2022 J.W. 17
Interpretation
Observations
Persons
Correlation
regressors and
time constant,
person-specific
error
22.03.2022 J.W. 20
Maturation and period effects
Social participation and depressive symptoms
7
6
Depressive Symptoms
0
Year 1 Year 2 Year 3 Year 4 Year 5 Year 6
22.03.2022 J.W. 22
Maturation and period effects
22.03.2022 J.W. 23
Time constant variables
• Main effects of time-constant variables cannot be
estimated by FE-model
– Not necessary, as confounding is whiped out with
– Not logical to assume that a time constant variable causes a
change in the outcome
• Possible: Interaction time-constant with time-varying
variables
– Does the effect of a time-varying variable differ between
different groups?
– See „A real world example“
22.03.2022 J.W. 24
Sample selection
1. Include only persons who can potentially change
from the state of not being treated to the state of
being treated
– In example: those not participating in social activities (yet)
– When studying effects of marriage: those not (yet) married
22.03.2022 J.W. 25
Sample selection
2. Think carefully how to handle persons that change
to yet another state than treated later on
– In studies of marriage effects:
never married married divorce
– Keep?
– Exclude the person completely?
– Exclude only time points (“observations”) while divorced, but
keep while never married and married?
– (substantial considerations)
22.03.2022 J.W. 26
Sample selection
3. Exclude persons with only one observation
– They cannot provide a within estimation
22.03.2022 J.W. 27
Problems not solved by FE-models
• Endogeneity
– reversed causality
– time-varying confounders
– …
• Panel attrition associated with time-variant factors
• Selection into treatment
– Treatment effect on the treated
22.03.2022 J.W. 28
Getting the data in shape
22.03.2022 J.W. 29
Data format
panelvar timevar
22.03.2022 J.W. 30
Digression:
Transforming wide to long format
22.03.2022 J.W. 31
Describing xtset-data
• Describe transitions between statuses:
xttrans varname [, freq]
22.03.2022 J.W. 32
Describing xtset-data
• Describe variables: xtsum varlist
Varies only
between persons
Varies only
within persons
“Enough” within-
variation in treatment?
22.03.2022 J.W. 33
Describing xtset-data
• Tabulate variables: xttab varlist
Observation/timepoint-level Unit/person-level
• Also: distinct-command
to identify IDs with
certain features
22.03.2022 J.W. 34
Describing xtset-data
22.03.2022 J.W. 35
Useful commands for long data
J.W. 36
Useful commands for long data
• bysort: repeat command on subsets
– Sort and execute for each id and each wave:
bysort id wave
– Sort by id and wave, but execute by id:
bysort id (wave)
• Counting:
– Running count: gen run = _n
– Overall count: gen count = _N
• egen: extensions to generate
– egen newvar = fcn(arguments) [, options]
– fcn: min(exp), max(exp), and many more
22.03.2022 J.W. 37
Useful commands for long data
• Powerful combinations:
– bysort id (wave) : gen round = _n (each person: number rows in correct order)
– bysort id : gen total = _N (each person: how many rows)
22.03.2022 J.W. 38
Useful commands for long data
Goal: Finding first treatment, after treatment, ever treated
22.03.2022 J.W. 39
Useful commands for long data
Goal: Finding first treatment, after first treatment, ever treated
1. First treatment:
– bysort id (wave) :
gen first_social = sum(social == 1) == 1 & sum(social[_n - 1] == 1) == 0
Is 1 if condition is true: social is 1 in row _n and is not 1 in row _n-1
Is 0 otherwise.
22.03.2022 J.W. 40
A real world example:
Marriage & Happiness
22.03.2022 J.W. 41
A real world example
• Does marriage make happy?
• Based on a 50%-subsample from the German Family Panel
– 11 waves (2009-2019)
– 12.000 respondents, plus their partners, children, and parents
– Born 1971-73, 1981-83, 1991-93 und 2001-03
– https://www.pairfam.de/
• Log-file with syntax and output is available on course homepage
• For data access: Fill in data access form and send to me:
– https://www.pairfam.de/fileadmin/user_upload/uploads/Covid-19/
Antragsformular/DistributionTeachingVersion_pairfam11.0
_COVID-19_en.pdf
22.03.2022 J.W. 42
Interaction with constant variables
22.03.2022 J.W. 43
Impact functions using dummies
22.03.2022 J.W. 44
Impact functions using dummies
22.03.2022 J.W. 45
Concluding remarks
22.03.2022 J.W. 46
Application to other data structures
• Applicable to other panel data structures
– Children in families
– Children in schools
– Areas within countries
– …
• Model will exploit the variation within…
– families (different children)
– schools (different children)
– countries (different areas)
– …
– … and whipe out specifics of families, schools, countries, etc
22.03.2022 J.W. 47
Summary individual fixed effects
22.03.2022 J.W. 48
References
22.03.2022 J.W. 49