Week 7: Multiple Regression

Week 7: Multiple Regression

Week 7: Multiple Regression Brandon Stewart1 Princeton October 24, 26, 2016 1These slides are heavily influenced by Matt Blackwell, Adam Glynn, Jens Hainmueller and Danny Hidalgo. Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 1 / 145 Where We've Been and Where We're Going... Last Week I regression with two variables I omitted variables, multicollinearity, interactions This Week I Monday: F matrix form of linear regression I Wednesday: F hypothesis tests Next Week I break! I then ::: regression in social science Long Run I probability ! inference ! regression Questions? Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 2 / 145 1 Matrix Algebra Refresher 2 OLS in matrix form 3 OLS inference in matrix form 4 Inference via the Bootstrap 5 Some Technical Details 6 Fun With Weights 7 Appendix 8 Testing Hypotheses about Individual Coefficients 9 Testing Linear Hypotheses: A Simple Case 10 Testing Joint Significance 11 Testing Linear Hypotheses: The General Case 12 Fun With(out) Weights Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 3 / 145 Why Matrices and Vectors? Here's one way to write the full multiple regression model: yi = β0 + xi1β1 + xi2β2 + ··· + xiK βK + ui Notation is going to get needlessly messy as we add variables Matrices are clean, but they are like a foreign language You need to build intuitions over a long period of time (and they will return in Soc504) Reminder of Parameter Interpretation: β1 is the effect of a one-unit change in xi1 conditional on all other xik . We are going to review the key points quite quickly just to refresh the basics. Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 4 / 145 Matrices and Vectors A matrix is just a rectangular array of numbers. We say that a matrix is n × K (\n by K") if it has n rows and K columns. Uppercase bold denotes a matrix: 2 3 a11 a12 ··· a1K 6 a21 a22 ··· a2K 7 A = 6 7 6 . .. 7 4 . 5 an1 an2 ··· anK Generic entry: aik where this is the entry in row i and column k Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 5 / 145 Design Matrix One example of a matrix that we'll use a lot is the design matrix, which has a column of ones, and then each of the subsequent columns is each independent variable in the regression. 2 3 1 exports1 age1 male1 6 1 exports2 age2 male2 7 X = 6 7 6 . 7 4 . 5 1 exportsn agen malen Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 6 / 145 Vectors A vector is just a matrix with only one row or one column. A row vector is a vector with only one row, sometimes called a 1 × K vector: α = α1 α2 α3 ··· αK A column vector is a vector with one column and more than one row. Here is a n × 1 vector: 2 3 y1 6 y2 7 y = 6 7 6 . 7 4 . 5 yn Convention: we'll assume that a vector is column vector and vectors will be written with lowercase bold lettering (b) Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 7 / 145 Vector Examples One common vector that we will work with are individual variables, such as the dependent variable, which we will represent as y: 2 3 y1 6 y2 7 y = 6 7 6 . 7 4 . 5 yn Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 8 / 145 Transpose There are many operations we'll do on vectors and matrices, but one is very fundamental: the transpose. The transpose of a matrix A is the matrix created by switching the rows and columns of the data and is denoted A0. That is, the kth column becomes the kth row. 2 3 q11 q12 0 q11 q21 q31 Q = 4 q21 q22 5 Q = q12 q22 q32 q31 q32 If A is j × k, then A0 will be k × j. Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 9 / 145 Transposing Vectors Transposing will turn a k × 1 column vector into a 1 × k row vector and vice versa: 2 1 3 6 3 7 0 ! = 6 7 ! = 1 3 2 −5 4 2 5 −5 Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 10 / 145 Addition and Subtraction To perform addition/subtraction the matrices/vectors need to be conformable, meaning that the dimensions have to be the same Let A and B both be 2 × 2 matrices. Then, let C = A + B, where we add each cell together: a a b b A + B = 11 12 + 11 12 a21 a22 b21 b22 a + b a + b = 11 11 12 12 a21 + b21 a22 + b22 c c = 11 12 c21 c22 = C Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 11 / 145 Scalar Multiplication A scalar is just a single number: you can think of it sort of like a 1 by 1 matrix. When we multiply a scalar by a matrix, we just multiply each element/cell by that scalar: a a α × a α × a αA = α 11 12 = 11 12 a21 a22 α × a21 α × a22 Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 12 / 145 The Linear Model with New Notation Remember that we wrote the linear model as the following for all i 2 [1;:::; n]: yi = β0 + xi β1 + zi β2 + ui Imagine we had an n of 4. We could write out each formula: y1 = β0 + x1β1 + z1β2 + u1 (unit 1) y2 = β0 + x2β1 + z2β2 + u2 (unit 2) y3 = β0 + x3β1 + z3β2 + u3 (unit 3) y4 = β0 + x4β1 + z4β2 + u4 (unit 4) Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 13 / 145 The Linear Model with New Notation y1 = β0 + x1β1 + z1β2 + u1 (unit 1) y2 = β0 + x2β1 + z2β2 + u2 (unit 2) y3 = β0 + x3β1 + z3β2 + u3 (unit 3) y4 = β0 + x4β1 + z4β2 + u4 (unit 4) We can write this as: 2 3 2 3 2 3 2 3 2 3 y1 1 x1 z1 u1 6 y2 7 6 1 7 6 x2 7 6 z2 7 6 u2 7 6 7 = 6 7 β0 + 6 7 β1 + 6 7 β2 + 6 7 4 y3 5 4 1 5 4 x3 5 4 z3 5 4 u3 5 y4 1 x4 z4 u4 Outcome is a linear combination of the the x, z, and u vectors Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 14 / 145 Grouping Things into Matrices Can we write this in a more compact form? Yes! Let X and β be the following: 2 3 1 x1 z1 2 3 β0 6 1 x2 z2 7 X = 6 7 β = 4 β1 5 (4×3) 4 1 x3 z3 5 (3×1) β2 1 x4 z4 Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 15 / 145 Matrix multiplication by a vector We can write this more compactly as a matrix (post-)multiplied by a vector: 2 3 2 3 2 3 1 x1 z1 6 1 7 6 x2 7 6 z2 7 6 7 β0 + 6 7 β1 + 6 7 β2 = Xβ 4 1 5 4 x3 5 4 z3 5 1 x4 z4 Multiplication of a matrix by a vector is just the linear combination of the columns of the matrix with the vector elements as weights/coefficients. And the left-hand side here only uses scalars times vectors, which is easy! Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 16 / 145 General Matrix by Vector Multiplication A is a n × K matrix b is a K × 1 column vector Columns of A have to match rows of b Let ak be the kth column of A. Then we can write: c = Ab = b1a1 + b2a2 + ··· + bK aK (j×1) c is linear combination of the columns of A Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 17 / 145 Back to Regression X is the n × (K + 1) design matrix of independent variables β be the (K + 1) × 1 column vector of coefficients. Xβ will be n × 1: Xβ = β0 + β1x1 + β2x2 + ··· + βK xK We can compactly write the linear model as the following: y = Xβ + u (n×1) (n×1) (n×1) 0 We can also write this at the individual level, where xi is the ith row of X: 0 yi = xi β + ui Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 18 / 145 Matrix Multiplication What if, instead of a column vector b, we have a matrix B with dimensions K × M. How do we do multiplication like so C = AB? Each column of the new matrix is just matrix by vector multiplication: C = [c1 c2 ··· cM ] ck = Abk Thus, each column of C is a linear combination of the columns of A. Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 19 / 145 Special Multiplications The inner product of a two column vectors a and b (of equal dimension, K × 1): 0 a b = a1b1 + a2b2 + ··· + aK bK Special case of above: a0 is a matrix with K columns and just 1 row, so the \columns" of a0 are just scalars. Stewart (Princeton) Week 7: Multiple Regression October 24, 26, 2016 20 / 145 Sum of the Squared Residuals Example: let's say that we have a vector of residuals, ub, then the inner product of the residuals is: 2 3 ub1 6 u2 7 ^u0^u = u u ··· u 6 b 7 b1 b2 bn 6 .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    147 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us