
Regression Algebra and Fit in Econometrics with Professor William Greene
Explore the intricacies of regression algebra and fit in Econometrics with insights from Professor William Greene at Stern School of Business. Learn about Stata, R-squared, FE models, total sum of squares, minimizing squared residuals, and more vital concepts.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Econometrics I Professor William Greene Stern School of Business Department of Economics 5-1/36 Part 5: Regression Algebra and Fit
A Caution About Stata and R2 Residual Sum of Squares Total Sum of Squares R squared = 1 - For the FE model above, Or is it? What is the total sum of squares? ( ) N T 2 Conventional: Total Sum of Squares = y y i = R2 = 0.90542 it = 1 1 i t ( ) N T 2 R2 = 0.65142 "Within Sum of Squares" = y y i = it i = 1 1 i t 2 Which should appear in the denominator of R The coefficient estimates and standard errors are the same. The calculation of the R2 is different. In the areg procedure, you are estimating coefficients for each of your covariates plus each dummy variable for your groups. In the xtreg, fe procedure the R2 reported is obtained by only fitting a mean deviated model where the effects of the groups (all of the dummy variables) are assumed to be fixed quantities. So, all of the effects for the groups are simply subtracted out of the model and no attempt is made to quantify their overall effect on the fit of the model. Since the SSE is the same, the R2=1 SSE/SST is very different. The difference is real in that we are making different assumptions with the two approaches. In the xtreg, fe approach, the effects of the groups are fixed and unestimated quantities are subtracted out of the model before the fit is performed. In the areg approach, the group effects are estimated and affect the total sum of squares of the model under consideration. 5-2/36 Part 5: Regression Algebra and Fit
Econometrics I Part 5 Regression Algebra and Fit; Restricted Least Squares 5-3/36 Part 5: Regression Algebra and Fit
Minimizing e e b minimizes e e = (y - Xb) (y - Xb). Any other coefficient vector has a larger sum of squared residuals. Proof: d = the vector, not equal to b; u = Xd u = y Xd = y Xb + Xb Xd = e - X(d - b). Then, u u = (y - Xd) (y-Xd) = sum of squares using d = [(y Xb) - X(d - b)] [(y Xb) - X(d - b)] = [e - X(d - b)] [e - X(d - b)] Expand to find u u = e e + (d-b) X X(d-b) (The cross product term is 2e X(d-b)=0 as X e = 0.) = e e + v v> e e 5-4/36 Part 5: Regression Algebra and Fit
Dropping a Variable An important special case. Suppose bX,z = [b,c] = the regression coefficients in a regression of y on [X,z] bX = [d,0] = is the same, but computed to force the coefficient on z to equal 0. This removes z from the regression. We are comparing the results that we get with and without the variable z in the equation. Results which we can show: Dropping a variable(s) cannot improve the fit - that is, it cannot reduce the sum of squared residuals. Adding a variable(s) cannot degrade the fit - that is, it cannot increase the sum of squared residuals. 5-5/36 Part 5: Regression Algebra and Fit
Adding a Variable Never Increases the Sum of Squares Theorem 3.5 on text page 40. u = the residual in the regression of y on [X,z] e = the residual in the regression of y on X alone, u u = e e c2(z* z*) e e where z* = MXz and c is the coefficient on z in the regression of y on [X,z]. 5-6/36 Part 5: Regression Algebra and Fit
The Fit of the Regression Variation: In the context of the model we speak of covariation of a variable as movement of the variable, usually associated with (not necessarily caused by) movement of another variable. Total variation = = y M0y. M0 = I i(i i)-1i = the M matrix for X = a column of ones. n i=1 2 (y -y) i 5-7/36 Part 5: Regression Algebra and Fit
Decomposing the Variation x b + x b + i i = y y = ( e i i x b - x b + x b - x b + i i x - x x - x ) +e b = y e i i i i i (Sum of cross products is zero.) Total variation = regression variation + residual variation n n n - - 2 2 2 i = + (y y) [( x ) ] x b e i i i = i 1 = i 1 = i 1 Recall the decomposition: Var[y] = Var [E[y|x]] + E[Var [ y | x ]] = Variation of the conditional mean around the overall mean + Variation around the conditional mean function. 5-8/36 Part 5: Regression Algebra and Fit
Decomposing the Variation of Vector y Decomposition: (This all assumes the model contains a constant term. one of the columns in X is i.) y = Xb + e so M0y = M0Xb + M0e = M0Xb + e. (Deviations from means.) y M0y = b (X M0)(M0X)b + e e = b X M0Xb + e e. (M0 is idempotent and e M0X = e X = 0.) Total sum of squares = Regression Sum of Squares (SSR)+ Residual Sum of Squares (SSE) 5-9/36 Part 5: Regression Algebra and Fit
A Fit Measure R2 = b X M0Xb/y M0y = e'e Regression Variation Total Variation = 1 n 2 (y y) i = i 1 (Very Important Result.) R2 is bounded by zero and one only if: (a) There is a constant term in X and (b) The line is computed by linear least squares. 5-10/36 Part 5: Regression Algebra and Fit
Adding Variables R2 never falls when a variable z is added to the regression. A useful general result for adding a variable 2 2 with both and variable equals X X X z R Xz 2 X z R with only plus the increase in fit due to after is accounted for: R R (1 R )r = + Xz 2 2 2 X 2 X *2 yz|X Useful practical wisdom: It is not possible meaningfully to accumulate R2 by adding variables in sequence. The incremental fit added by each variable depends on the order. The increase in R2 that occurs from x3 in (x1 then x2 then x3) is different from that in (x1 then x3 then x2). 5-11/36 Part 5: Regression Algebra and Fit
Adding Variables to a Model What is the effect of adding PN, PD, PS? 5-12/36 Part 5: Regression Algebra and Fit
A Useful Result Squared partial correlation of an x in X with y is squared t - ratio squared t - ratio + degrees of freedom We will define the 't-ratio' and 'degrees of freedom' later. Note how it enters: 2 2 2 *2 Xz X X yz R R (1 R )r r = + = ( ) ( / 1 R ) 2* yz 2 Xz 2 X 2 X = R R 5-13/36 Part 5: Regression Algebra and Fit
Partial Correlation Partial correlation is a difference in R2s. For PS in the example above, R2 without PS = .9861, R2 with PS = .9907 (.9907 - .9861) / (1 - .9861) = .331 3.922 / (3.922 + (36-5)) = .331 5-14/36 Part 5: Regression Algebra and Fit
Comparing fits of regressions Make sure the denominator in R2 is the same - i.e., same left hand side variable. Example, linear vs. loglinear. Loglinear will almost always appear to fit better because taking logs reduces variation. 5-15/36 Part 5: Regression Algebra and Fit
5-16/36 Part 5: Regression Algebra and Fit
(Linearly) Transformed Data How does linear transformation affect the results of least squares? Z = XP for K K nonsingular P Based on X, b = (X X)-1X y. Based on Z, c = (Z Z)-1Z y = (P X XP)-1P X y = P-1(X X)-1P -1P X y = P-1b Fitted value is Zc = (XP)(P-1b) = Xb. The same!! Residuals from using Z are y - Zc = y - Xb (we just proved this.). The same!! Sum of squared residuals must be identical, as y-Xb = e = y-Zc. R2 must also be identical, as R2 = 1 - e e/y M0y (!!). 5-17/36 Part 5: Regression Algebra and Fit
Linear Transformation What are the practical implications of this result? (1) Transformation does not affect the fit of a model to a body of data. (2) Transformation doesaffect the estimates. If b is an estimate of something ( ), then c cannot be an estimate of - it must be an estimate of P-1 , which might have no meaning at all. Xb is the projection of y into the column space of X. Zc is the projection of y into the column space of Z. But, since the columns of Z are just linear combinations of those of X, the column space of Z must be identical to that of X. Therefore, the projection of y into the former must be the same as the latter, which now produces the other results.) 5-18/36 Part 5: Regression Algebra and Fit
Principal Components Z = XC Fewer columns than X Includes as much variation of X as possible Columns of Z are orthogonal Why do we do this? Collinearity Combine variables of ambiguous identity such as test scores as measures of ability 5-19/36 Part 5: Regression Algebra and Fit
What is a Principal Component? X = a data matrix (deviations from means) z = Xp = a linear combination of the columns of X. Choose p to maximize the variation of z. How? p = eigenvector that corresponds to the largest eigenvalue of X X. (Notes 7:41-44.) 5-20/36 Part 5: Regression Algebra and Fit
5-21/36 Part 5: Regression Algebra and Fit
+----------------------------------------------------+ | Movie Regression. Opening Week Box for 62 Films | | Ordinary least squares regression | | LHS=LOGBOX Mean = 16.47993 | | Standard deviation = .9429722 | | Number of observs. = 62 | | Residuals Sum of squares = 20.54972 | | Standard error of e = .6475971 | | Fit R-squared = .6211405 | | Adjusted R-squared = .5283586 | +----------------------------------------------------+ +--------+--------------+----------------+--------+--------+----------+ |Variable| Coefficient | Standard Error |t-ratio |P[|T|>t]| Mean of X| +--------+--------------+----------------+--------+--------+----------+ |Constant| 12.5388*** .98766 12.695 .0000 | |LOGBUDGT| .23193 .18346 1.264 .2122 3.71468| |STARPOWR| .00175 .01303 .135 .8935 18.0316| |SEQUEL | .43480 .29668 1.466 .1492 .14516| |MPRATING| -.26265* .14179 -1.852 .0700 2.96774| |ACTION | -.83091*** .29297 -2.836 .0066 .22581| |COMEDY | -.03344 .23626 -.142 .8880 .32258| |ANIMATED| -.82655** .38407 -2.152 .0363 .09677| |HORROR | .33094 .36318 .911 .3666 .09677| |4 INTERNET BUZZ VARIABLES |LOGADCT | .29451** .13146 2.240 .0296 8.16947| |LOGCMSON| .05950 .12633 .471 .6397 3.60648| |LOGFNDGO| .02322 .11460 .203 .8403 5.95764| |CNTWAIT3| 2.59489*** .90981 2.852 .0063 .48242| +--------+------------------------------------------------------------+ 5-22/36 Part 5: Regression Algebra and Fit
The fit goes down when the 4 buzz variables are reduced to a single linear combination of the 4. +----------------------------------------------------+ | Ordinary least squares regression | LHS=LOGBOX Mean = 16.47993 | | Standard deviation = .9429722 | | Number of observs. = 62 | | Residuals Sum of squares = 25.36721 | | Standard error of e = .6984489 | | Fit R-squared = .5323241 | | Adjusted R-squared = .4513802 | +----------------------------------------------------+ +--------+--------------+----------------+--------+--------+----------+ |Variable| Coefficient | Standard Error |t-ratio |P[|T|>t]| Mean of X| +--------+--------------+----------------+--------+--------+----------+ |Constant| 11.9602*** .91818 13.026 .0000 | |LOGBUDGT| .38159** .18711 2.039 .0465 3.71468| |STARPOWR| .01303 .01315 .991 .3263 18.0316| |SEQUEL | .33147 .28492 1.163 .2500 .14516| |MPRATING| -.21185 .13975 -1.516 .1356 2.96774| |ACTION | -.81404** .30760 -2.646 .0107 .22581| |COMEDY | .04048 .25367 .160 .8738 .32258| |ANIMATED| -.80183* .40776 -1.966 .0546 .09677| |HORROR | .47454 .38629 1.228 .2248 .09677| |PCBUZZ | .39704*** .08575 4.630 .0000 9.19362| +--------+------------------------------------------------------------+ 0 0 0 0 0 0 0 0 0 0 0 0 p p p p | 11 21 P = 31 41 5-23/36 Part 5: Regression Algebra and Fit
5-24/36 Part 5: Regression Algebra and Fit
Adjusted R Squared Adjusted R2 (adjusted for degrees of freedom) = n K ( ) n 1 2 2 R 1 1 R Degrees of freedom adjustment. includes a penalty for variables that don t add much fit. Can fall when a variable is added to the equation. 2 R 5-25/36 Part 5: Regression Algebra and Fit
62 1 62 9 = (1 .34) .24 1 5-26/36 Part 5: Regression Algebra and Fit
Adjusted R2 What is being adjusted? The penalty for using up degrees of freedom. 2 = 1 - [e e/(n K)]/[y M0y/(n-1)] R = 1 [(n-1)/(n-K)(1 R2)] Will rise when a variable is added to the regression? is higher with z than without z if and only if the t ratio on z is in the regression when it is added is larger than one in absolute value. (See p. 46 in text.) 2 R R 2 5-27/36 Part 5: Regression Algebra and Fit
Full Regression (Without PD) ---------------------------------------------------------------------- Ordinary least squares regression ............ LHS=G Mean = 226.09444 Standard deviation = 50.59182 Number of observs. = 36 Model size Parameters = 9 Degrees of freedom = 27 Residuals Sum of squares = 596.68995 Standard error of e = 4.70102 Fit R-squared = .99334 <********** Adjusted R-squared = .99137 <********** Info criter. LogAmemiya Prd. Crt. = 3.31870 <********** Akaike Info. Criter. = 3.30788 <********** Model test F[ 8, 27] (prob) = 503.3(.0000) --------+------------------------------------------------------------- Variable| Coefficient Standard Error t-ratio P[|T|>t] Mean of X --------+------------------------------------------------------------- Constant| -8220.38** 3629.309 -2.265 .0317 PG| -26.8313*** 5.76403 -4.655 .0001 2.31661 Y| .02214*** .00711 3.116 .0043 9232.86 PNC| 36.2027 21.54563 1.680 .1044 1.67078 PUC| -6.23235 5.01098 -1.244 .2243 2.34364 PPT| 9.35681 8.94549 1.046 .3048 2.74486 PN| 53.5879* 30.61384 1.750 .0914 2.08511 PS| -65.4897*** 23.58819 -2.776 .0099 2.36898 YEAR| 4.18510** 1.87283 2.235 .0339 1977.50 --------+------------------------------------------------------------- 5-28/36 Part 5: Regression Algebra and Fit
PD added to the model. R2 rises, Adjusted R2 falls ---------------------------------------------------------------------- Ordinary least squares regression ............ LHS=G Mean = 226.09444 Standard deviation = 50.59182 Number of observs. = 36 Model size Parameters = 10 Degrees of freedom = 26 Residuals Sum of squares = 594.54206 Standard error of e = 4.78195 Fit R-squared = .99336 Was 0.99334 Adjusted R-squared = .99107 Was 0.99137 --------+------------------------------------------------------------- Variable| Coefficient Standard Error t-ratio P[|T|>t] Mean of X --------+------------------------------------------------------------- Constant| -7916.51** 3822.602 -2.071 .0484 PG| -26.8077*** 5.86376 -4.572 .0001 2.31661 Y| .02231*** .00725 3.077 .0049 9232.86 PNC| 30.0618 29.69543 1.012 .3207 1.67078 PUC| -7.44699 6.45668 -1.153 .2592 2.34364 PPT| 9.05542 9.15246 .989 .3316 2.74486 PD| 11.8023 38.50913 .306 .7617 1.65056 (NOTE LOW t ratio) PN| 47.3306 37.23680 1.271 .2150 2.08511 PS| -60.6202** 28.77798 -2.106 .0450 2.36898 YEAR| 4.02861* 1.97231 2.043 .0514 1977.50 --------+------------------------------------------------------------- 5-29/36 Part 5: Regression Algebra and Fit
Linear Least Squares Subject to Restrictions Restrictions: Theory imposes certain restrictions on parameters. Some common applications Dropping variables from the equation = certain coefficients in b forced to equal 0. (Probably the most common testing situation. Is a certain variable significant? ) Adding up conditions: Sums of certain coefficients must equal fixed values. Adding up conditions in demand systems. Constant returns to scale in production functions. Equality restrictions: Certain coefficients must equal other coefficients. Using real vs. nominal variables in equations. General formulation for linear restrictions: Minimize the sum of squares, e e, subject to the linear constraint Rb = q. 5-30/36 Part 5: Regression Algebra and Fit
Restricted Least Squares In practice, restrictions can usually be imposed by solving them out. zero Force a coefficient to equal 1. Drop the variable from the equation . n = 2 Problem: Minimize for , , (y x x x ) subject to 0 1 2 3 i 1 i1 2 i2 3 i 3 3 i 1 = n 2 Solution: Minimize for , (y x x ) 1 2 i 1 i1 = 1. Strategy: 2 i2 i 1 = 2. Adding up restri ct ion Impose + . + =1 . 1 2 3 3 1 2 n 2 Solution: Minimize for , ( y x x (1 )x ) 1 2 i 1 i1 2 i2 1 2 i3 = i 1 n 2 = [(y x ) (x x ) (x x )] i i3 1 i1 i3 2 i2 i3 i 1 = = 3. Equality restriction. Impose 3 2 n = 2 Minimize for , , (y x x x ) subject to 1 2 3 i 1 i1 2 i2 3 i3 3 2 i 1 = n + 2 Solution: Minimize for , [y x (x x )] 1 2 i 1 i1 2 i2 i3 i 1 = In each case, least squares using transformations of the data. 5-31/36 Part 5: Regression Algebra and Fit
Restricted Least Squares Solution General Approach: Programming Problem Minimize for L = (y - X ) (y - X ) subject to R = q Each row of R is the K coefficients in a restriction. There are J restrictions: J rows 3 = 0: R= [0,0,1,0, ] 2 = 3: R = [0,1,-1,0, ]q = (0). J=1 2 = 0, 3 = 0: R= 0,1,0,0, 0,0,1,0, q = (0). J=1 q = 0 J=2 0 5-32/36 Part 5: Regression Algebra and Fit
Solution Strategy Quadratic program: Minimize quadratic criterion subject to linear restrictions All restrictions are binding Solve using Lagrangean formulation Minimize over ( , ) L* = (y - X ) (y - X ) + 2 (R -q) (The 2 is for convenience see below.) 5-33/36 Part 5: Regression Algebra and Fit
Restricted LS Solution Necessary Conditions L* 2 = = + = X y X R 0 ( ) 2 L* = R q 0 2( ) Divide everything by 2. Collect in a matrix form = R 0 q t rely on full rank of . Relies on column rank of = K XX R Xy 1 A w. A w or = Solution = X Does no + A J. 5-34/36 Part 5: Regression Algebra and Fit
Restricted Least Squares X If has full rank, there is a partitioned solution for * and * = - ( ) [ ( ) * [ ( ) ]( ) where the simple least squares coefficients, = ( Note = * b and * if = 0 Rb q ]( 1 1 ) * b R XX b XX R R XX R Rb q R Rb q = 1 = 1 b XX Xy ) . = . 0 5-35/36 Part 5: Regression Algebra and Fit
Aspects of Restricted LS 1. b* = b - Cm where m= the discrepancy vector Rb - q. Note what happens if m = 0. What does m = 0 mean? 2. =[R(X X)-1R ]-1(Rb - q) = [R(X X)-1R ]-1m. When does = 0. What does this mean? 3. Combining results: b* = b - (X X)-1R . How could b* = b? 5-36/36 Part 5: Regression Algebra and Fit
Restrictions and the Criterion Function Assume full rank case. (The usual case.) = ( ) uniquely minimizes ( - ( - ) ( - ) < ( - Imposing restri ctions cannot improve the criterion value. It follows that R * < R . Restrictions must degrade the fit. X ) (y- b 1 b XX Xy y X X ) = . b . *) ( - b*) for any * y Xb y X y Xb y Xb 2 2 5-37/36 Part 5: Regression Algebra and Fit