




























































































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!





























































































online material by Bruce Hansen: his “Probability and Statistics”, is available
I don’t think I have to justify point number three. I am writing this in 2020, when typical data sets have hundreds, if not thousands observations and no- body would ever dream of running any kind of inferential procedure with less than 50 data points. Apart from OLS, there is no econometric technique in actual use that does not depend vitally on asymptotics, so I guess that readers should get familiar with the associated concepts if there is a remote chance that this will not be put them off econometrics completely. The t test, the F tests and, in general, all kinds of degrees-of-freedom corrections are ad-hockeries of the past; unbiasedness is overrated. Get over it. I promise I’ll try to be respectful of the readers and don’t treat them like id- iots. I assume that if you’re reading this, you want to know more than you do about econometrics, but this doesn’t give me the right to assume that you need to be taken by the hand and treated like an 11-year-old. Finally, a word of gratitude. A book like this is akin to a software project, and there’s always one more bug to fix. So, I’d like to thank first all my students who helped me eradicate quite a few. Then, my colleagues Stefano Fachin, Francesca Mariani, Giulio Palomba, Luca Pedini, Matteo Picchio and Claudia Pigini for making many valuable suggestions. Needless to say, the remaining shortcom- ings are all mine. Claudia also allowed me to grab a few things from her slides on IV estimation, so thanks for that too. If you want to join the list, please send me bug reports and feature requests. Also, I’m not an English native speaker (I suppose it shows). So, Anglophones of the world, please correct me whenever needed. The structure of this book is as follows: chapter 1 explores the properties of OLS as a descriptive statistic. Inference comes into play at chapter 2 with some general concepts, while their application to OLS is the object of chapter
In some cases, I will use a special format for short pieces of texts, like this. They contain ex- tra stuff that I consider interesting, but not in-
dispensable for the overall comprehension of the main topic.
This work is licensed under a Creative Commons “Attribution-ShareAlike 3.0 Unported” license.
ii
where we implicitly assume that if x i is not too different from x j , then we should expect yi to be broadly close to y (^) j : if we pick two people of the same age, with the same educational level and many other characteristics in common we would expect that their income should be roughly the same. Of course this won’t be true in all cases (in fact, chances are that this will never be true exactly), but hopefully our model won’t lead us to catastrophic mistakes. The reason why we want to build models is that, once the function m (·) is known, it becomes possible to ask ourselves interesting questions by inspect- ing the characteristics of that function. So for example, if it turned out that the export share of a firm is increasing in the expenditure in R&D, we may make con- jectures about the reasons why it should be so, look for some economic theory that could explain the result, and wonder if one could improve export competi- tiveness by giving the firms incentives to do research. Moreover, the door is open to forecasting: given the characteristics of a hy- pothetical firm or individual, the model makes it possible to guess what their export share or income (respectively) should be. I don’t think I have to convince the reader of how useful this could be in practice. Of course, we will want to build our model in the best possible way. In other words, our aim will be choosing the function m (·) according to some kind of optimality criterion. This is what the present course is about. But there’s more: as we will see, building an optimal model is impossible in general. At most, we may hope to build the best possible model for the data that we have available. Of course, there is no way of knowing if the model we built, that perhaps works rather well with our data, will keep working equally well with new data. Imagine you built a model for the inflation rate in a country with monthly data from January 2000 to December 2017. It may well be that your model performs (or, as we say, “fits the data”) very well for that period, but what guarantee do you have that it will keep doing so in 2018, or in the more distant future? The answer is: you have none. But still, this is something that we’d like to do; our mind has a natural tendency to generalise, to infer, to extrapolate. And yet, there is no logical compelling basis for proving that it’s a good idea to do so.^4 The way out is framing the problem in a probabilistic setting, and this is the reason why econometrics is so intimately related with probability and statistics. For the moment, we’ll start with the problem of choosing m (·) in a very sim- ple case, that is when we have no extra information x i. In this case, the function becomes a constant:
yi ' m ( x i ) = m
and the problem is very much simplified, because it means we have to pick a number m in some optimal way, given the data y 1 , y 2 ,... , yn. In other words, we have to find a function of the data which returns the number m. Of course, a function of the data is what we call a statistic. In the next section, I will prove
(^4) ‘The philosophically inclined reader may at this point google for “Bertrand Russel’s turkey”.
that the statistic we’re looking for is, in this case, the average of the yi s, that is Y ¯ = (^) n^1 ∑ ni = 1 yi.
1.2 The average
What is a descriptive statistic? It is a function of the data which synthesises a particular feature of interest of the data; of course, the more informative, the better. The idea behind descriptive statistics is more or less: we have some data on some real-world phenomenon; our data set, unfortunately, is too “large”, and we don’t have time/can’t/don’t feel like going through the whole thing. Hence, we are looking for a function of these data to tell us what we want, without being bothered with unnecessary details. The most obvious example of a descriptive statistic is, of course, the sample average. Let’s stick our observations y 1 , y 2 ,... , yn into a column vector y ; the sample average is nothing but
n
∑^ n i = 1
yi =
n
familiar to most readers; I prefer the matrix-based one not only because I find it more elegant, but also because it’s far easier to generalise. The nice feature
sum of the elements of x.^5 We use averages all the time. Why is the average so popular? As I said, we’re looking for a descriptive statistic m , as a synthesis of the information contained in our data set.
In 1929, Oscar Chisini (pronounced kee- zee -nee) pro- posed the following definition: for a function of interest g (·), the mean of the vector y is the number m that yields
ample, the average is the solution of the special case when the g (·) function is the sum of the vector’s elements, and the reader may want to spend some time with more exotic cases. Chisini’s idea may be further generalised: if our aim is to use m — that we haven’t yet chosen — as an imperfect but parsimonious description of the whole data set, the question that naturally arises is: how much information is lost?
(^5) Reminder: the inner products of two vectors a and b is defined as ∑ i ai bi. Mathematicians like the notation 〈 a , b 〉 for the inner product, on the grounds of its greater generality (google “Hilbert space” if you’re curious), but we econometricians are more accustomed to the “matrix” notation a ′ b , where the apostrophe means “transposed”.
may be complicated. What does the L ( m ) function look like for the grades in econometrics of our hypothetical class? Hard to say. Moreover, we often must come up with a summary statistic without know- ing in advance what it will be used for. Obviously, in these cases finding a one- size-fits-all optimal solution is downright impossible. We have to make do with something that is not too misleading. A possible choice is
L ( m ) =
∑^ n i = 1
The above criterion is a function of m based on the sum of squared residuals, that enjoys several desirable properties. Not only it’s simple to manipulate al- gebraically: it’s symmetric and convex, so that positive and negative residuals are penalised equally, and large errors are more costly than small ones. It’s not unreasonable to take this loss function as an acceptable approximation. More- over, this choice makes it extremely easy to solve the associated minimisation problem. Minimising L ( m ) with respect to m leads to the so-called least squares prob- lem. All is needed to find the minimum in (1.3) is taking the derivative of L ( m ) with respect to m ;
d L ( m ) d m
∑^ n i = 1
d
yi − m
d m
∑^ n t = 1
yi − m
The derivative must be 0 for a minimum, so that
∑^ n i = 1
yi − m ˆ
which in turn implies
n · m ˆ =
∑^ n t = 1
yi
and therefore m ˆ = n −^1 ∑ n i = 1 yi^ =^ Y ¯^.^ The reader is invited to verify that^ m ˆ^ is indeed a minimum, by checking that the second derivative d (^2) L ( m ) d m^2 is positive. Things are even smoother in matrix notation:
so the derivative is
d L ( m ) d m
whence
e ′ e = ∑ n i = 1 ( yi^ −^ Y ¯^ )
(^2) is a quantity that in this case we call deviance , but that we
will more often call SSR , as in Sum of Squared Residuals. The mathematically sophisticated way to say the same, that we used a few pages back, is m ˆ = Argmin m ∈R
L ( m );
where again, the hat ( ˆ ) on m indicates that, among all possible real numbers, we are choosing the one that minimises our loss function. The argument above, which leads to choosing the average as an optimal summary is, in fact, much more general than it may seem: many of the descrip- tive statistics we routinely use are special cases of the average, where the data y are subject to some preliminary transformation. In practice: the average of z , where zi = h ( yi ) can be very informative, if we choose the function h (·) wisely. The variance is the most obvious example: the sample variance^9 is just the aver- age of zi = ( yi − Y ¯ )^2 , which measures how far yi is from ¯ Y. Things get even more interesting when we express a frequency as an average: define the event E = { yi ∈ A }, where A is some subset of the possible values for yi ; now define the variable zi = I( yi ∈ A ), where I(·) is the so-called “indicator function”, that gives 1 when its argument is true and 0 when false. Evidently, the average of the zi , Z , is the relative frequency of E :
∑ n i = 1 zi n
= K / n ;
since zi can only be 0 or 1, K = ∑ n i = 1 zi^ is just the number of times the event^ E has occurred. I’m sure you can come up with more examples.
1.3 OLS as a descriptive statistic
Now let’s bring the explanatory variables x i back in. For the moment, let’s con- sider the special case where x i is a one-element vector, that is a scalar. A possible way to check if yi and xi are related to each other is to see if yi is “large” or “small” when xi is “large” or “small”. Define
zi = ( yi − Y ¯ )( xi − X ¯ )
which is, in practice, a sort of indicator of “matching magnitudes”: zi is positive when yi > Y ¯ and xi > X ¯ (both are “large”) or when yi < Y ¯ and xi < X ¯ (both are “small”); on the contrary, zi is negative when magnitudes don’t match. As
(^9) I’m not applying the “degrees of freedom correction”; I don’t see why I should, as long I’m using the variance as a descriptive statistic.
Equation (1.4) is a simple example of an econometric model. The number yi is split into two additive components: a systematic part, that depends on the variable xi (a linear function of xi , to be precise), plus a remainder term, that we just call the residual for now. In this example, m ( xi ) = mm xi + m (^) f (1 − xi ). It is convenient to rewrite (1.4) as
yi = m (^) f + ( mm − m (^) f ) xi + ei =
1 xi
] [^ m (^) f mm − m (^) f
so we can use matrix notation, which is much more compact and elegant
where
m (^) f mm − m (^) f
β 1 β 2
one is x. The i -th row of X is [1, 1] if the corresponding individual is male and [1, 0] otherwise. To be explicit:
y 1 y 2 .. . yn − 1 yn
1 x 1 1 x 2 .. .
1 xn − 1 1 xn
β 1 β 2
e 1 e 2 .. . en − 1 en
Therefore, the problem of choosing mm and m (^) f optimally is transformed
The solution is not difficult: find the solutions to^12
d
e ′ e = d
d
By using the well-known^13 rules for matrix differentiation, you have
if X ′ X is invertible (if you need a refresher on matrix inversion, and related mat- ters, subsection 1.A.3 is for you):
(^12) Need I remind the reader of the rule for transposing a matrix product, that is ( AB )′ (^) = B ′ (^) A ′? Obviously not. (^13) Not so well-known, maybe? Jump to subsection 1.A.1.
Equation (1.7) is the single most important equation in this book, and this is
the sum of squared residuals among all vectors with k elements (where k = 2 in this case):
β∈R k
e ′ e ,
and the expression in equation (1.7) turns the implicit definition into an explicit
statistic , from Ordinary Least Squares.^14 A very common idiom that economists use when referring to the calculation of OLS is “regressing y on X ”. The usage of the word “regression” here might seem odd, but will be justified in chapter 3. The “hat” symbol has exactly the same meaning as in eq. (1.2): of all the
minimises the associated loss function e ′ e. The vector
is our approximation to y. The term we normally use for the elements of ˆ y are the fitted values : the closer they are to y , the better we say that the model fits the data. In this example, a few simple calculations suffice to show that
X ′ X =
n nm nm nm
X ′ y =
[ ∑ n ∑ i^ =^1 yi xi = 1 yi
Sm + S (^) f Sm
where Sm =
xi = 1 yi and^ S^ f =^
xi = 0 yi : the sums of^ yi for males and females, respectively. By using the standard rule for inverting (2 × 2) matrices, which I will also assume known,^15
( X ′ X )−^1 =
nm n (^) f
nm − nm − nm n
so that
nm n (^) f
nm − nm − nm n
Sm + S (^) f Sm
nm n (^) f
nm S (^) f n (^) f Sm − nm S (^) f
and finally
S (^) f n (^) f Sm nm −^
S (^) f n (^) f
Y (^) f Y^ ¯ m − Y ¯ (^) f
(^14) Why “ordinary”? Well, because there are more sophisticated variants, so we call these “ordi- nary” as in “not extraordinary”. We’ll see one of those variants in section 4.2.1. (^15) If you’re in trouble, go to subsection 1.A.
In traditional textbooks, at this point you always get a picture similar to the one in Figure 1.1, which is supposed to aid intuition; I don’t like it very much, and will explain why shortly. Nevertheless, let me show it to you: in this example, we use the same data as in the present example.
Figure 1.1: OLS on six data points
x
y
( x 1 , y 1 )
( x 1 , ˆ y 1 )
m ( x ) = 0.4 + 0.475 x
In Figure 1.1, each black dot corresponds to a ( xi , yi ) pair; the dashed line plots the m ( x ) function and the residuals are the vertical differences between the dots and the dashed line ; the least squares criterion makes the line go through the dots in such a way that the sum of these differences (squared) is minimal. So, for example, for observation number 1 the observed value of xi is 4 and the observed observed value for yi is 1; the approximation yields ˆ y 1 = 0.4+0.475× 4 = 2.3 (observe the position of the white dot). Therefore, e 1 = y 1 − y ˆ 1 = −1.3 (the vertical distance between the black dot and the white dot). The example above can be generalised by considering the case where we have more than one explanatory variable, except for the fact that producing a figure akin to Figure 1.1 becomes difficult, if not impossible. Here, the natural thing to do is expressing our approximation as a function of the vector x i , that is
y ˆ i = β 0 + β 1 x 1 i + β 2 x 2 i +... + βk xki
For example, suppose we have data on each student in the class A. S. Tudent belongs to. How many hours each student spent studying econometrics, their previous grades in related subjects, and so on; these data, for the i -th student, are contained in the vector x ′ i , which brings us back to equation (1.5). The algebraic apparatus we need for dealing with the generalised problem is, luckily, unchanged; allow me to recap it briefly. If the residual we use for
and write
(a more detailed proof, should you need it, is in subsection 1.A.5). By putting together (1.8) and (1.9) you get a system of equations sometimes referred to as normal equations :
If you think that all this is very clever, well, you’re right. The inventor of this is arguably the greatest mathemati- cians of all time: the great Carl Friedrich Gauss, also known as the princeps mathematicorum.^17 Note, again, that the average can be obtained as the
the above formulae make it possible to compute all the rel- evant quantities without necessarily observing the matri- ces X and y ; in fact, all the elements you need are the fol- lowing:
where k is the number of columns of X , the number of unknown coefficients in
and using (1.10) you have
Equation (1.11) expresses the SSR as the difference between a scalar and the
that is the number of observation n , never comes into play, and could well be huge. I guess you now understand my lack of enthusiasm for Figure 1.1: if X has 3 columns, drawing a similar picture is difficult. For 4 or more columns, it be- comes impossible. Worse, the geometric intuition that it conveys may overlap with another geometric interpretation of OLS, which I consider more interesting and more useful, and is the object of section 1.4.
(^17) To be fair, the French mathematician Adrien-Marie Legendre rediscovered it independently a few years later.