




















































Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!





















































Lecture 0. Econometrics in Action
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:
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
Leamer [1983]: ”Hardly anyone takes data analysis seriously. Or perhaps more accurately, hardly anyone takes anyone
else’s data analysis seriously.” (p. 37).
”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).
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).
Increased access to administrative data: (government are sharing part of the data they have)
near-universal population coverage;
(education, health, tax records, fertility, crime, etc.)
Impressive expansion of private sector data (and not only by big internet companies)
geolocation, etc.)
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.
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:
competing private companies
different companies supplied households in the same street
Company and ii) Southwark and Vauxhall Company
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:
which differs in the two areas (possibly including “bad air” although it is unlikely)
change in water supply, Lambeth was worse than Southwark and Vauxhall
of deaths in 1849 and in 1850 (-165) can be considered the
effect of the change in water supply
in water supply - Lambeth would still have had a slightly
larger number of deaths
Lambeth, if the change hadn’t been made.
Minimum Wages and Employment
Do minimum wages lead to higher unemployment?
minimum salary the more people are fired from firms.
confounding factors. How can I know that the consequences of the minimum salary will be worse than
a future without?
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.
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
Data are informative but they can also be deceptive:
Structure of data
We need to recognize basic data structures (3 types) and use appropriate estimation methods:
point in time. Example : votes for the Brexit Referendum by constituency
UK Consumer Price Index
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 =
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 =
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.
survived, because hits in the engine (untouched in the ones that survived) would often lead to plane crashes.
hit in the engine were not coming back!
(for instance, estimate the returns to education using data on educational choices made by individuals).
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.
socio-economic background
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!
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)
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
and one or more other (independent) variables (= controls).
(outcome / dependent variable)
i
(regressors / covariates / controls / explanatory variables / independent variables)
Linear Regression Model describes the relationship between outcome and regressors. We can have a :
~ one control
!
"
#!
!
~ k controls
!
"
#!
$
$!
%
%!
!
~ this is the most common, since in the real world we always have more than one variable affecting another
one!
"
$
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
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 !!
#!
$!
$#
$
#$
$$
&
#&
$&
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) !!
Intro to Estimation:
"
%
~ we will use the most widely used method of estimating the parameters 𝛽
"
and 𝛽
: Ordinary Least Squares
~ we will introduce the method with bivariate regression (i.e. one control) and we then extend it to multivariate
regression (i.e. multiple controls).
~ 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)
#!
$!
%!
) 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
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)
234
is well approximated by a
Normal distribution :
where SE(𝛽
234
) is the standard error of 𝛽
234
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.
With multivariate regression, we can conduct:
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):
5
is a t distribution with n − k − 1 degrees of freedom:
We can conduct hypothesis testing for a single coefficient in three ways:
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)
Four steps:
as two-sided (H1: βj ̸= 0), specify the level of significance α (e.g. α = 0.05), choose a decision variable
(t - statistic)
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):
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.
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:
variation that is explained by the regression):
From TSS= ESS+RSS we get
The coefficient of determination or R
2
is defined as: R
2
Interpretation: the percentage of the variation of Y that is explained by the regression model.
Properties of R
2
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.
2
= ρ
2
YX , i.e., the squared sample correlation coefficient between Y and
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
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
2
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.
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:
recording highest level of qualification (or ethnic group) ⇒ dummies for each level of education (or ethnic
group)
discretize it by creating dummies for value ranges: e.g. work experience ⇒ dummies
for: i) < 10 years; ii) 11 − 20 years; iii) > 20 years.
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:
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:
E(Wage i
|Female i
=0)=β 0
If we set female to zero, the gender of the individuals taken into account is male.
E(Wage i
|Female i
=1)=β 0
+β 1
β 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:
Wage i
= β 0
Male i
Wage i
= β 1
Female i
Male i
When we are considering Females beta one exists and beta two is zero.
But we cannot estimate:
Wage i
= β 0
Female i
Male 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.
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)
each individual behaves.
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.
In our example: Test Scorei = β 0
STRi + u i
More generally: Yi = β 0
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:
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
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:
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.
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:
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:
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.
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 one, suggesting that there was very little
heteroscedasticity
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 ).
(‘yhat’ is the chosen name for the new
variable)
(‘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: