Docsity

Econometrics: Causality, Correlation, and Regression Analysis, Appunti di Econometria

Toggle sidebar
bg1
Econometrics
1
Lecture 0. Econometrics in Action
EMPIRICAL EVIDENCE AND DECISION-MAKING
The aim is to understand, study the relation between variables.
Policy, individual and firms’ decisions typically entail
trade-offs.
Everyday everyone makes decisions, and the relevant
ones have a trade-off.
Spending more is generally beneficial but:
- governments/individuals/firms face binding budget constraints
- the return from an investment may be lower than expected and/or there may be decreasing returns to investment
- there may be better ways of spending those resources
Empirical evidence can (and should) inform policy/individual/firm decisions.
The good news - for policy-makers as much as for citizens - are that empirical work has greatly improved across all fields
in recent years...
A Tale of Two Revolutions
1) From the Leamer’s critique to the
credibility revolution
(Angrist and Pischke [2010])
- Until fairly recently, empirical work was very far from its current standards:
Leamer [1983]: ”Hardly anyone takes data analysis seriously. Or perhaps more accurately, hardly anyone takes anyone
else’s data analysis seriously.” (p. 37).
- Since then, many things have changed:
”Empirical work (...) has produced a credibility revolution in the fields of labor, public finance, and development
economics over the past 20 years.” (Angrist and Pischke [2010]; p. 26).
- ”Better data and more robust estimation methods are part of the story, as is a reduced emphasis on econometric
considerations that are not central to a causal interpretation of the main findings. But the primary force driving the
credibility revolution has been a
vigorous push for better and more clearly articulated research designs
.”(Angrist and
Pischke [2010]; p. 11).
2) the
Big Data revolution
(Einav and Levin [2014])
Increased access to
administrative data
: (government are sharing part of the data they have)
- all fields have shifted from relying on relatively small-sample surveys to administrative data with universal or
near-universal population coverage;
- admin data can be linked to observe individual outcomes longitudinally and over multiple policy areas
(education, health, tax records, fertility, crime, etc.)
Impressive expansion of
private sector data
(and not only by big internet companies)
- Available in real time
- On behaviours not previously measured (e.g. communication, social networks, internet search activity, mobility,
geolocation, etc.)
- Huge amount of information
The availability of all these data - with their size, their unusual structure, the amount of information they contain, etc. -
is inducing a major revolution in econometrics, bringing to forefront methods (classification and regression trees, lasso
and methods to estimate sparse models, boosting, model averaging, and cross-validation) that were previously almost
unheard of in economics.
THE IMPORTANCE OF COUNTERFACTUALS
Any statement on the effects of a given intervention (e.g. individual investment in education; firm’s investment in R&D;
policy intervention) needs to be accompanied by a serious discussion about counterfactuals.
When we make a choice, we will never know what would have happened if we hadn’t chosen that. [e.g., is this course
good because I find job quickly or I wasted 3 years because I have a great entrepreneurial spirit that got me the job]
Counterfactual
: what would have happened in the absence of the policy intervention?
In empirical work,
constructing a credible counterfactual
is a pre-requisite for the identification of a causal parameter
of interest and, at the same time, a major challenge...
In econometrics we can think at something that happens and to see its effects. Most theories in economics are ‘if I
change this, I’ll see this in reality’; econometrics takes the data and tests these models.
No counterfactual: every choice you make have no counterfactual, therefore you cannot know whether it was the right
choice.
The obvious challenge is that
we will never be able to observe the counterfactual reality
... E.g., what if the Nazi had
won the WWII.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c

Anteprima parziale del testo

Scarica Econometrics: Causality, Correlation, and Regression Analysis e più Appunti in PDF di Econometria solo su Docsity!

Lecture 0. Econometrics in Action

EMPIRICAL EVIDENCE AND DECISION-MAKING

The aim is to understand, study the relation between variables.

Policy, individual and firms’ decisions typically entail trade-offs. Everyday everyone makes decisions, and the relevant

ones have a trade-off.

Spending more is generally beneficial but:

  • governments/individuals/firms face binding budget constraints
  • the return from an investment may be lower than expected and/or there may be decreasing returns to investment
  • there may be better ways of spending those resources

Empirical evidence can (and should) inform policy/individual/firm decisions.

The good news - for policy-makers as much as for citizens - are that empirical work has greatly improved across all fields

in recent years...

A Tale of Two Revolutions

  1. From the Leamer’s critique to the credibility revolution (Angrist and Pischke [2010])
  • Until fairly recently, empirical work was very far from its current standards:

Leamer [1983]: ”Hardly anyone takes data analysis seriously. Or perhaps more accurately, hardly anyone takes anyone

else’s data analysis seriously.” (p. 37).

  • Since then, many things have changed:

”Empirical work (...) has produced a credibility revolution in the fields of labor, public finance, and development

economics over the past 20 years.” (Angrist and Pischke [2010]; p. 26).

  • ”Better data and more robust estimation methods are part of the story, as is a reduced emphasis on econometric

considerations that are not central to a causal interpretation of the main findings. But the primary force driving the

credibility revolution has been a vigorous push for better and more clearly articulated research designs.”(Angrist and

Pischke [2010]; p. 11).

  1. the Big Data revolution (Einav and Levin [2014])

Increased access to administrative data: (government are sharing part of the data they have)

  • all fields have shifted from relying on relatively small-sample surveys to administrative data with universal or

near-universal population coverage;

  • admin data can be linked to observe individual outcomes longitudinally and over multiple policy areas

(education, health, tax records, fertility, crime, etc.)

Impressive expansion of private sector data (and not only by big internet companies)

  • Available in real time
  • On behaviours not previously measured (e.g. communication, social networks, internet search activity, mobility,

geolocation, etc.)

  • Huge amount of information

The availability of all these data - with their size, their unusual structure, the amount of information they contain, etc. -

is inducing a major revolution in econometrics, bringing to forefront methods (classification and regression trees, lasso

and methods to estimate sparse models, boosting, model averaging, and cross-validation) that were previously almost

unheard of in economics.

THE IMPORTANCE OF COUNTERFACTUALS

Any statement on the effects of a given intervention (e.g. individual investment in education; firm’s investment in R&D;

policy intervention) needs to be accompanied by a serious discussion about counterfactuals.

When we make a choice, we will never know what would have happened if we hadn’t chosen that. [e.g., is this course

good because I find job quickly or I wasted 3 years because I have a great entrepreneurial spirit that got me the job]

Counterfactual: what would have happened in the absence of the policy intervention?

In empirical work, constructing a credible counterfactual is a pre-requisite for the identification of a causal parameter

of interest and, at the same time, a major challenge...

In econometrics we can think at something that happens and to see its effects. Most theories in economics are ‘if I

change this, I’ll see this in reality’; econometrics takes the data and tests these models.

No counterfactual: every choice you make have no counterfactual, therefore you cannot know whether it was the right

choice.

The obvious challenge is that we will never be able to observe the counterfactual reality... E.g., what if the Nazi had

won the WWII.

Cholera in London in the 1850s

John Snow did econometrics way before the computer was designed.

John Snow (15 March 1813 - 16 June 1858): English physician and leader in the adoption of anaesthesia

and medical hygiene; he is considered one of the fathers of modern epidemiology, because of his work

in tracing the source of a cholera outbreak in Soho, England, in 1854.

Snow believed that cholera is transmitted by contaminated drinking water and not by “bad air”, as the

prevailing (at the time) miasma theory held.

His grant application was rejected: “ The theory explored here, that cholera spreads through

contaminated water, is one that carries little credibility in the scientific community.. .”

But he was right and, to prove it, he exploited a natural experiment. He explained the phenomena as economists do

now.

The setting:

  • In the 1850s, in London the water was supplied to households by

competing private companies

  • Different companies would supply different areas, but sometimes

different companies supplied households in the same street

  • In south London, there were two main companies: i) Lambeth

Company and ii) Southwark and Vauxhall Company

  • In 1849, both companies would obtain their water directly from the

sewage-contaminated Thames; but in 1852, Lambeth Company moved its

water source 22 miles upstream (away from London’s sewage)

Blue: Southwark and Vauxhall Company; Red: Lambeth Company.

Perfect environment to test Snow ideas. If the problem was the air, the air was everywhere and the same. So, the

Cholera should have contaminated the same areas. But since the responsible was water, the concentration of Cholera

cases should have decreased in the households receiving better water.

The data:

  • 1853/54: cholera outbreak
    • Death rates per 10000 people by water company: Lambeth: 10; Southwark and Vauxhall: 150
    • The difference (+140) may be due to the different quality of the water but also to any other factor

which differs in the two areas (possibly including “bad air” although it is unlikely)

  • Snow compared death rates in a previous epidemic in 1849, before the change:
    • Lambeth: 150; Southwark and Vauxhall: 125
    • In 1849, there less deaths in Southwark and Vauxhall then in Lambeth (-25): if anything, before the

change in water supply, Lambeth was worse than Southwark and Vauxhall

  • The difference between the differences in number

of deaths in 1849 and in 1850 (-165) can be considered the

effect of the change in water supply

  • The assumption is that - in the absence of the change

in water supply - Lambeth would still have had a slightly

larger number of deaths

  • Southwark and Vauxhall acts as counterfactual for Lambeth: because it tells us what would have happened to

Lambeth, if the change hadn’t been made.

  • Snow is considered the father of the Difference-in-Differences econometric approach (widely used today)

Minimum Wages and Employment

Do minimum wages lead to higher unemployment?

  • It is not straightforward to answer this question
  • We face two key challenges:
    1. Identification of potential affected workers, to understand where trade-offs happen. The higher the

minimum salary the more people are fired from firms.

  1. Definition of a proper counterfactual (what would have happened without any MW change), to exclude

confounding factors. How can I know that the consequences of the minimum salary will be worse than

a future without?

  • Minimum wages are usually introduced/changed in an entire country and affect all workers (in low-pay occupations)

Stocks and Covid Vaccine

Announcements

09 Nov 2020: Pfizer and

BioNTech announce their

vaccine

Stock prices for Pfizer and

AstraZeneca (left) and FTSE

index (right).

AstraZeneca works as the

counterfactual of Pfizer. Using

time, we can asset something about causality.

The Effects of Brexit on GBP Exchange Rate

GBP Exchange Rate and Brexit Referendum. Huge drop for a currency just in

few hours.

Exchange Rate and

the “Brexit

Odyssey”

Causality of Brexit

on the currency.

The Effects of Capitol Hill Insurrection

Figure - Trump’s approval rating; before (left) and after (right) the 6th of January 2021

Do we need a counterfactual in this case? And which one?

Figure - Trump’s approval rating compared to previous U.S. presidents

UNDERSTANDING THE DATA

Data are informative but they can also be deceptive:

  • We need to fully understand the nature of the data we are looking at
  • We need to read them through a clear theoretical framework (a theory helps us identifying a research question)
  • Theory would allows us to rule out, for instance, spurious correlations and to identify potential confounding factors

Structure of data

We need to recognize basic data structures (3 types) and use appropriate estimation methods:

  1. cross-sectional data: consist of a sample of multiple entities (individuals, firms, schools, states, etc.) taken at a given

point in time. Example : votes for the Brexit Referendum by constituency

  1. time-series data: consist of a single entity (or a small group of entities) observed at multiple time periods. Example :

UK Consumer Price Index

  1. panel/longitudinal data: consist of multiple entities observed at multiple periods (i.e., same entities observed multiple

times). Example : understanding society (the UK longitudinal household panel).

Sample selection: an example from WWII

We also need to be able to recognize and deal with more complex features of our data, such as sample selection; let’s

consider a military example from WW2 =

  • policy question: how to armor planes in order to minimize the risk of them being shot down by enemy fighters?
  • policy trade-off: armor makes planes heavier, they become less maneuverable and use more fuel.
  • armoring the planes too much is a problem, but armoring the planes too little is also a problem: not only we want

to know how much to armor them but also where.

To answer this question, during WW2 the US army collected data on bullet holes in military planes coming back from

engagement in Europe =

  • the idea was to reinforce the areas where the planes were more likely to be hit.
  • the data showed that the engine and fuel system were hit significantly less than other parts of the planes.

It isn’t that surprising that the fuselage gets hit more often than the engine? We should expect a more uniform

distribution of bullet holes in the planes and, if anything, we would expect enemy artillery to aim at the engine. This is

what we should see if we had data on a random sample – if not the entire population - of planes hit by enemy fighters:

HOWEVER, we don’t have a random sample…

we have a selected sample: we observe only the planes that managed to return to the U.S. despite being hit.

  • Hungarian mathematician Abraham Wald argued that one should armor the areas not hit of the planes that

survived, because hits in the engine (untouched in the ones that survived) would often lead to plane crashes.

  • survivor’ bias: the reason planes were flying back to the US with fewer hits to the engine was that planes that got

hit in the engine were not coming back!

  • if sample selection had not been taken into account, policy conclusions would have been dramatically wrong!!

CAUSALITY VS CORRELATION

  • The main aim of regression analysis is to understand causal effects between economic variables.
  • Most often empirical work is carried out using observational (= non-experimental, come from the real world) data

(for instance, estimate the returns to education using data on educational choices made by individuals).

  • We will deal with problems arising from using observational data to estimate causal effects; in some cases,

economists can overcome these difficulties by running controlled experiments. HOWEVER, experiments are often

unfeasible: we need to combine institutional setting, economic theory, econometrics and statistics to estimate

causal parameters of interest.

  • Using observational (non-experimental) data pose major challenges :
  • lack of a counterfactual
  • confounding effects (omitted factors): schooling decisions follow from self-selection on, for example, motivation or

socio-economic background

  • simultaneous causality: for example, richer countries have higher levels of education, but which is causing which?

Often only a correlation can be established, and correlation is NOT causality: correlation means that two variables X

and Y move together, causation means that a change in X induces a change in Y.

Remember: correlations are important since they give us empirical facts!

  • immigration share and crime rate in the UK =

o time series evidence:

§ immigration rises & crime decreases

o cross-sectional evidence (2004 and 2014):

§ note: each dot represents a UK Local Authority (like provinces in Italy)

§ the relation is positive: more immigrants means more crime

§ HOWEVER, we cannot stop here because we know that this reasoning is too simplistic, as correlation does

not me causality

§ in fact, we see this in the fact that more people means more crime (immigrants or not)

  • migrants live in cheaper neighborhoods (à more crime)

o panel data evidence (2004-2009 and 2009-2014):

§ see the line is flat (= no

relations between the 2

variables) or even

downward sloping (more

immigrants and less crime)

Lecture 1. OLS Review

LINEAR REGRESSION MODEL

  • REMEMBER : Regression Analysis is the study of the relationship between one (dependent) variable (= outcome)

and one or more other (independent) variables (= controls).

  • Key steps and ingredients that need to be defined :
    1. population of interest = the population we are studying (cannot be too big, e.g. workers in the UK)
    2. variables of interest = Y i

(outcome / dependent variable)

X

i

(regressors / covariates / controls / explanatory variables / independent variables)

• A

Linear Regression Model describes the relationship between outcome and regressors. We can have a :

  • bivariate (simple) regression =

~ one control

!

"

#!

!

  • multivariate (multiple) regression =

~ k controls

!

"

#!

$

$!

%

%!

!

~ this is the most common, since in the real world we always have more than one variable affecting another

one!

- ABOUT THE FORMULAS =

"

$

etc. are typically referred to as the parameters of the regression model:

o 𝛽

"

= intercept parameter , it measures the average value of Y when all X equal zero

is often not economically meaningful by itself

o 𝛽

$

, etc. = slope parameters , they measure the change in Y resulting from a unit change in a given X (holding

constant all other controls) – this is typically what we are most interested in

!

: error term (or disturbance / residuals):

o it captures everything that we cannot see (it causes us some troubles)

o it captures any other variable and factor - that we are not explicitly controlling for - that affect Y in addition to

X

o some of these factors may be random shocks (events), others are omitted variables (luck)

o they are all treated as unobserved (since they are unobservable characteristics)

è we will never be able to truly represent the real world: ceteris paribus among all the inputs, we will always have

different results !!

  • Typically, we do not observe the whole population of interest; we have a random sample of n observations :
  • we denote a particular observation for individual i in the random sample by: (𝑌 !

#!

$!

  • the random sample is )

$#

$

#$

$$

&

#&

$&

  • because of random sampling, the observations are independent from each other and identically distributed (i.i.d.)
  • if you take a non-random variable, you cannot make inferences about the population of inference! In general, we

are not interested in discoveries in our sample per se, we do that so that we can apply our findings to a broader

population (we use the sample as an instrument to learn something about the population outside world) !!

OLS ESTIMATION

Intro to Estimation:

  • we are going to use our random sample to learn about the population model
  • more specifically, we are going to use our sample to try to estimate the parameters 𝛽

"

%

~ we will use the most widely used method of estimating the parameters 𝛽

"

and 𝛽

: Ordinary Least Squares

(OLS)

~ we will introduce the method with bivariate regression (i.e. one control) and we then extend it to multivariate

regression (i.e. multiple controls).

- REMEMBER =

~ we use Greek letters for the population parameters, and Latin letters for the sample ones

~ estimation: if the sample is representative, then b1 will be close to 𝛽

~ the “hat” (𝑌

) means estimated

è basically, there’s no correlation between the variables that we observe ( X ) and the one we don’t ( u ) !!

#!

$!

%!

!

) are independent and identically distributed (i.i.d.) à this is true with random sampling!!

#!

$!

%!

!

) have finite fourth moments (i.e., large outliers are unlikely)

  1. the regressors (𝑋

#!

$!

%!

) are NOT perfectly multicollinear.

è this means that none of the regressors can be written as a perfect linear function of only the other regressors; this

is rarely violated in practice, however, if the correlation between any two regressors is high, that will also be

problematic!

è intuition: if two regressors are highly correlated, we cannot separately identify their individual impact on the

outcome (see the appendix on perfect multicollinearity)

Under the OLS assumptions 1-4, we have the following properties of the OLS estimator =

234

is an unbiased estimator for the population parameter b à 𝔼)𝛽

234

  • = 𝛽. If I use a small sample I might

obtain an average that is completely different from the real one.

234

is a consistent estimator for the population parameter b : as the sample size n increases, 𝛽

234

gets closer

and closer to b (i.e. 𝛽

234

converges in probability to 𝛽

234

for n going to infinite)

  1. the Central Limit Theorem (CLT) implies that if n is large, the distribution of 𝛽

234

is well approximated by a

Normal distribution :

where SE(𝛽

234

) is the standard error of 𝛽

234

  • that is – the square root of the estimated variance of 𝛽

234

è NOTE: for more, see appendix on the variance of OLS estimator for univariate regressions

point 2 and 3 are asymptotic property (i.e., estimated b and true b will converge at infinite).

Homoskedasticity and Gauss-Markov Theorem

Definition : The error term u i

is homoskedastic if the variance of the

conditional distribution of ui given Xi is constant for i = 1, ..., n and

in particular does not depend on X i

. Otherwise, the error term is

heteroskedastic .

Does the variance of residuals increases / decreases with X i

Homoscedastic errors are more or less equally distanced. For

heteroskedastic errors think as y=wage and x=education - > there is

much more variation on average. There is on average an increase

in variance.

If we make a fifth assumption:

The error term u i

is

homoskedastic .

Then the following theorem applies:

Gauss-Markov Theorem: given the OLS

assumptions and homoscedastic errors,

OLS is Best Linear Unbiased Estimator

(BLUE), that is, the OLS estimator has

minimum variance among all unbiased

estimators of the β that are linear

functions of the variables.

Unbiasness means centered on the true

value.

This means that we are able to estimate the true population parameters β more accurately if we use the OLS method

rather than any other method that also gives unbiased linear estimates of the true parameters.

HYPOTHESIS TESTING

With multivariate regression, we can conduct:

  1. hp tests on a single coefficient
  2. hp tests on multiple coefficients (joint hp testing)

Usually, we test the null hypothesis that one coefficient is (or, a set of coefficients are) equal to zero, because it is

essentially a test of whether or not X has any effect on Y.

When we can reject this special null hypothesis that βj = 0, we say that “βj is statistically significant”, or “βj is

positive/negative and statistically significant.”

We can also test whether βj = 5, or 2, or any other number.

Testing a Single Coefficient

To test a hypothesis about a single coefficient, the Central Limit Theorem (CLT) tells us that

5

5

6

7

%

In practice, we have to estimate 𝜎

6

7

%

, that in turn depends on 𝜎

$ 4

, the estimated variance of the error term. We have

n−k−1 degrees of freedom to estimate this variance (where n = number of observations and k = number of controls),

thus an unbiased estimator of σ

2

is

As a consequence of this (it can be shown that):

  • small sample size n: the distribution of the standardised 𝛽

5

is a t distribution with n − k − 1 degrees of freedom:

  • large sample size n: the t distribution converges to a standard normal when n is large:

We can conduct hypothesis testing for a single coefficient in three ways:

  1. using critical values
  2. with confidence interval
  3. with p-values

Note that all these three approaches are equivalent - and routinely performed all together by standard econometric

softwares (which typically report critical values, p-values and confidence intervals)

  1. Critical values

Four steps:

  1. Formulate the null hypothesis (e.g. H0: βj = 0 - > no correlation), formulate the alternative hypothesis, usually

as two-sided (H1: βj ̸= 0), specify the level of significance α (e.g. α = 0.05), choose a decision variable

(t - statistic)

  1. Calculate the actual value of the t-statistic under the null.
  2. Compute the critical value according to the significance level α.
  3. Decide whether you can or cannot reject the null hypothesis.
  1. Confidence Interval

We can create a confidence interval for βj.

For example, a 95% confidence interval for βj is given by

We can use this interval to conduct the test (define: L=lower bound and U=upper bound):

  • if βj < 0 and confidence interval is [L < 0,U < 0], or
  • if βj > 0 and confidence interval is [L > 0,U > 0]

then, 0 is outside the 95% confidence interval and we can reject the null hypothesis at the 5% level. Beta has to be

sufficiently far from 0 in order to be significant.

  1. p-value

We can also use the p-value to conduct the test: Suppose we set the significance level to: α = 0.

If the p-value is < 0.05 = α, we reject the null hypothesis at the 5% level.

If the p-value is > 0.05 = α, we fail to reject the null hypothesis at the 5% level.

Hypothesis Tests on Multiple Coefficients

In multiple regression analysis, we might be interested in testing:

  • Explained/Model Sum of Squares (ESS) is the total variation of the fitted Y values around their average (i.e., the

variation that is explained by the regression):

  • Residual Sum of Squares (RSS) is the unexplained variation of the Y values around the regression line:

From TSS= ESS+RSS we get

1= ESS/TSS + RSS/TSS

The coefficient of determination or R

2

is defined as: R

2

= ESS/TSS = 1 – RSS/TSS.

Interpretation: the percentage of the variation of Y that is explained by the regression model.

Properties of R

2

1. 0 ≤ R

2

§ R2 = 1 implies a perfect fit, i.e., all the Yi ’s lie on a straight line.

§ R2 = 0 implies no linear relationship between Y and X , i.e., the Yi’s are randomly distributed around the

horizontal line that passes through Ybar.

  1. For the bivariate (simple) regression, R

2

= ρ

2

YX , i.e., the squared sample correlation coefficient between Y and

X.

Adjusted R-squared: 𝑹

The R

2

never gets smaller as we include more variables in the model, even if these variables do not contribute to

explain the variation in Y

This is an important limitation of this measure: including irrelevant variables increases the R

2

  • it leaves R

2

unchanged

only if the estimated coefficient on the added regressor is exactly equal to zero.

Therefore we need to use a modified version of the coefficient of determination, the Adjusted R

2

where: n = sample size; k = number of regressors.

Properties of the Adjusted R

2

, or, R

2

≤ R

2

  • Adding a regressor to the model has two opposite effects on 𝑹

o The RSS falls, which increases R.

o The factor n−1/n-k- 1 increases, which decreases 𝑹

Whether 𝑹

increases or decreases depends on which of the two effects is stronger.

is always positive, but 𝑹

can sometimes be negative.

can be used to compare two regressions with the same dependent variable but different number of

regressors.

BINARY VARIABLES

We now consider the case of dummy (binary) variables which takes only the values 0 or 1.

Variables in the regression can be binary (i.e. taking values 0 or 1) if the underlying variable:

  1. is binary: e.g. EU citizen or not, with or without children, employed in the public or the private sector;
  2. takes a few discrete values (a categorical variable) and we create a dummy for each value: e.g. a variable

recording highest level of qualification (or ethnic group) ⇒ dummies for each level of education (or ethnic

group)

  1. is continuous, but we

discretize it by creating dummies for value ranges: e.g. work experience ⇒ dummies

for: i) < 10 years; ii) 11 − 20 years; iii) > 20 years.

  1. is continuous (e.g. income) but has been measured as binary (e.g. is your income above or below a certain

threshold?) or as a categorical variables (e.g. in which of the following range of values is your income?)

Dummy variables can be regressors, outcomes or both.

We discuss here the case of binary regressors. We will discuss in another topic the case of binary outcomes.

Binary Regressors

Nothing major changes when some regressor Xi is a binary variable, we just need to be careful with:

  • the interpretation of the coefficients, relative to the excluded category
  • with the “dummy variable trap”

Suppose we are interested in estimating the gender gap in wages. We estimate the (bivariate) regression model

Wage i

=β 0

+β 1

Female i

+u i

where Female i

is a dummy variable that equals 1 if i is female and equals 0 if i is male. β 0

in this case is the average

wage of males. I expect β 1

to be negative due to gender gap. Negative between females earn less, the following one is

positive because males earn more.

To interpret the coefficients, note that:

  • Average wages for male workers:

E(Wage i

|Female i

=0)=β 0

If we set female to zero, the gender of the individuals taken into account is male.

  • Average wages for female workers:

E(Wage i

|Female i

=1)=β 0

+β 1

  • Gender gap (i.e. difference in avg wages between female and male workers):

β 1

=E(Wage i

|Female i

=1)−E(Wage i

|Female i

Beta one is the difference between the first two groups.

Suppose you create another dummy variable, Male i

, that takes value 1 if the workers is male and zero otherwise.

We could estimate the alternative specifications:

  • Male dummy instead of female dummy:

Wage i

= β 0

  • β 1

Male i

  • u i
  • Male and female dummy together - but removing the constant β 0 :

Wage i

= β 1

Female i

  • β 2

Male i

  • u i

When we are considering Females beta one exists and beta two is zero.

But we cannot estimate:

Wage i

= β 0

  • β 1

Female i

  • β 2

Male i

  • u i

Because here we have three coefficients (stata will automatically drop either Female or Male). This equation shows

perfect collinearity.

β 0

β 1

Female i

β 2

Male i

1 0 = Male 1 = Male

1 0 = Male 1 = Male

1 1 = Female 0 = Female

The sum of the lines is one that corresponds to the constant.

If we take male as dummy, we will have different coefficient but same average values.

The latter regression violates OLS Assumption 4, since the variables Female i

, Male i

, and the constant are perfectly

multicollinear: Female i

= 1 − Male i

⇒ dummy variable trap.

For any given variable (e.g. gender, level of education, area of origin), we cannot include a full set of dummy variables

and the constant: one of the dummy variables needs to be removed from the regression.

Which dummy variable we remove will change the estimated coefficients but it will not affect our economic conclusions:

the dummy left out is the

excluded category and the coefficients on the other dummies are relative to that group

Alternatively, we can exclude the constant from the regression and keep the full set of dummies: each coefficient will

identify the average value of the outcome for the corresponding group.

APPENDIX

Variance of OLS estimator with univariate regression

In an univariate regression, if the sample size n is large, the distribution of βˆ0 and βˆ1 are well approximated by a

Normal distribution:

We have:

A statistical model representing aggregate consumption can be written as

c = f (i) + e,

where c denotes consumption, i is income, and e is a random error which accounts for the many factors that affect

consumption that we have omitted from this simple model (e.g. wealth)

  • Economic theory describes the systematic part, f (i). It is a theory based on data, but it not telling precisely how

each individual behaves.

  • e is the non-systematic, random error component that we know is present but cannot be observed.

Adding random errors converts our economic model into a statistical one, which gives us a basis for statistical

inference.

Social scientists, educators, and parents have long been concerned with the causal effects of class size, a key input to

education production.

Many countries have implemented important reforms to cap class size.

Small classes are costly, therefore evidence on their effectiveness is welcome.

Policy question: What is the effect on test scores (or some other outcome measure) of reducing class size by one

student per class?

Economic model :

Test Scores = f (STR) with: ∂Test Scores/∂ STR < 0

STR = Student Teacher ratio - > number of students per teacher. The larger this variable is the lower is the

performance of the students.

Regression equation:

Test Scores = β0 + β1STR

Looking at the Data

We will go through the steps of regression analysis with a specific example in mind (following the textbook by Stock

and Watson).

We use data from 420 California school districts.

Variables recorded for each district:

Average standardised test score in that district (testscr) Student-teacher ratio in that district, that is, average class size

(str)

Quantitative question: are avg test scores higher in schools with lower student-teacher ratio?

When looking at the relationship between 2 variables, it is always good to start by looking at a scatterplot.

In Stata: scatter testscr str

Estimating a Regression

Recall that we are interested in the effect of a one unit

increase in STR on test scores.

This effect is measured by the slope of a line relating test

scores to STR. It is β1 in the equation

Test Scores = β0 + β1STR

Another way to think about β1 is

β1 = ∆Test Scores/∆STR

In Stata: scatter testscr str || lfit testscr str Stata

command: lfit – fits the ‘best’ line to the data

points.

Ý

We do not see that much of a relation.

There might be one, but we expect it not to be that

strong. Indeed Þ

Beta on tells how much change in the student-

teacher ratio, changes the students’ performance.

  1. Population of interest: all California school districts
  2. Random variables
  • Xi : student-teacher ratio in district i (STRi )
  • Yi : average standardised test score in district i (Test Score i
  1. 3 Linear Regression Model: describes the relationship between the two random variables.

In our example: Test Scorei = β 0

  • β 1

STRi + u i

More generally: Yi = β 0

  • β 1 i

X + ui

In our example of test scores and STR, what does ui represent? It represents the error. So, everything else that is

different across districts. It captures other determinants of test scores that we are not considering.

For example:

  • Teacher quality in school district i.
  • Computer availability in school district i. Family income in school district i.
  • Education level of parents in school district i.
  • Luck on test, grading mistakes, etc.

The variables that are in ui are sometimes called omitted variables,

i.e., variables that affect Y other than X.

Each dot is a district. Dots above the line have positive residuals.

Difference between the expected value and the actual one.

We typically do not observe the whole population of interest: we

typically draw a random sample from the population of interest.

Suppose we choose n school districts at random and measure their

STR (Xi ) and average test scores (Yi ).

We denote a particular observation in the random sample by (Xi,Yi).

The random sample is

((X1, Y1), (X2, Y2), ..., (Xn, Yn)).

Because of random sampling, the observations (Xi , Yi ) are

independent of each other and identically distributed (i.i.d.).

Regression Output and its Interpretation

We will now estimate the parameters β0 and β1 in the regression model Test Scorei = β 0

  • β 1

STRi + u i

using Stata.

New command: regress/reg

698.933 is our beta zero, meanwhile - 2 ,

is beta one.

Beta zero is the intercept of the regression

line. In this case it has no meaning. It is the

test score you would have if the teacher

ratio was 0 (it makes no sense).

If I increase the STR by one unit, the test

score will decrease by 2.2.

The actual estimates of βˆ0 and βˆ1 with the data on STR and Test Scores in the 420 California districts are

βˆ0 = 698.9 βˆ1 = −2.

In other words, the regression results are suggesting that the linear relationship between STR and Test Scores is

Test Scoresi = 698.9 − 2.28 × STRi + ui

This tells us the following:

  1. How changes in the STR affect average test scores.
  • Increasing (decreasing) STR by 1 decreases (increases) average test scores by 2.28 points.

We can also do the testing using the p-value, just like we did

for testing a hypothesis about the mean height of adult men.

We can compute the p-value associated with the test

whether β1 = 0 as:

Since the p-value is so close to zero, these data are telling us

that there is very strong statistical evidence against H0, i.e.,

very strong evidence that class size does affect test scores.

We could also reject H0 at a significance level of 0.001.

  1. Testing Using Confidence Intervals

We can also form confidence intervals for our estimates

βˆ0 and βˆ1.

We not only want to have a best guess at what the effect

we are interested in is, but we also want to have some idea

how precise that guess is. CI’s are a very convenient way of

summarising this.

A 95% confidence interval (CI) for β1 is given by

In our example, this CI is [−3.22, −1.34].

We are 95% confident that this interval covers the true β1. More loosely, the evidence suggests that decreasing the

student-teacher ratio by 1 will increase average test scores somewhere between 1.34 and 3.22 points.

Confidence intervals are directly related to hypothesis tests.

More specifically, our 95% CI of [−3.22, −1.34] means that we would reject any H0 outside of this interval at the 5%

significance level, and not reject any H0 inside this interval.

For example, we would

Heteroscedasticity and Robust Std Errors

Reminder:

  • Errors are homoscedastic if the variance of each ui is constant for all i; they are heteroscedastic otherwise.
  • OLS is BLUE if errors are homoscedastic.
  • Under homoscedasticity, we can estimate the standard error of βˆ1 as
  • Instead under heteroscedasticity,

In practice, some heteroscedasticity is almost always present.

Therefore, it is standard practice in empirical work to allow for heteroscedasticity, and make statistical inference based

on heteroscedasticity-robust standard errors.

In Stata:

  • regress testscr str ⇒ assumes homoscedasticity
  • regress testscr str, robust ⇒ allows for heteroscedasticity when estimating the standard error of coefficients.

Regression output without robust standard errors

If there is heteroskedasticity we say that we

underestimated the standard errors.

The robust regression eliminates the heteroskedasticity.

Regression output with robust standard errors

If we have heteroskedasticity we are looking at the

standard error. Standard error is the inferential part. Then

we test the significance. In this case, our conclusions do

not change. There might be cases in which the std. error

doubles or increases significantly.

  • Estimated coefficients are unaffected by the use of

robust standard errors.... of course! we are changing

the way we estimate standard errors, which has

implications for inference but not for point estimates

  • Robust standard errors are slightly larger than non-

robust one, suggesting that there was very little

heteroscedasticity

  • The marginal increase in standard errors slightly reduces the significance of the estimates (i.e. the t-stat decreases

and the CI becomes wider), but they remain strongly statically significant.

The assumption of homoskedasticity has to be based on the inference and not on the bias.

We need to worry about correctly estimating the coefficient and finding the best standard errors. Since the sdt errors

are small (of the previous tables) the heteroskedasticity is minimal. Remember that heteroskedasticity is a scatterplot

in which at the beginning the difference between expected and actual value is larger and it diminishes the more we

get far from the origin point.

Post-Estimation Commands

We can use so-called post-estimation commands to compute the b

predicted values (Yi ) for Xi ’s in the sample, as well as the residuals (uˆi ).

  • Predicted values: predict yhat, xb

(‘yhat’ is the chosen name for the new

variable)

  • Residuals: predict uhat, residual

(‘uhat’ is the chosen name for the new

variable)

Question in the exam: command + name chosen

for the variable + comma + command.

Actual (left) and predicted (for each district)

(right) values of test score: