LEC 5 Multivariate Regression: Concepts and Application

PUBPOL 5310: Applied Stats - Multivariate Regression

Overview of Regression Analysis

  • First Part: Focused on univariate and bivariate analysis (one or two variables).

  • Remainder (Current Topic): Focuses on multivariate analysis.

    • Multivariate Data: Involves three or more variables.

    • (Earlier material can be considered a special case of multivariate analysis).

Outline and Goals

  • Goal: To achieve "Controlling for other variables" in regression analysis.

    • This means isolating the effect of one independent variable on the dependent variable while holding other relevant factors constant.

  • Notation: Understanding the symbols used for multivariate data analysis.

  • Summary of Multivariate Data:

    • Graphical summary (with limitations).

    • Least squares regression method for multivariate data.

    • Interpretation of multivariate regression coefficients.

    • Measures of goodness of fit.

"Controlling for Other Variables"

  • Bivariate Regression Slope (b2b_2): Indicates the change in predicted Y for a one-unit change in X, on average.

    • Example: Relationship between health and income.

  • Confounding Factors: Often, the observed change in Y due to X also includes effects from other factors (e.g., age).

    • Example: Age might influence both income and health, making a simple health-income relationship misleading.

  • Desired Outcome: To understand the relationship between income and health for individuals of the same age (i.e., "for two folks of the same age, how are income and health related?").

  • Terminology for Control:

    • "Control for age."

    • "Hold age constant."

    • "Hold age fixed."

    • "Condition on age."

  • One Approach (Stata's if modifier):

    • Using regress health income if age == 47 to analyze data only for individuals aged 47.

    • Using regress health income if (age >= 45 & age <= 49) to analyze data within an age range.

    • Limitations of the if approach:

      • Difficulty in choosing specific ages or age ranges.

      • Risk of insufficient data within narrow subsets.

      • Potentially many regressions to run for different age groups.

      • Hard to get an "overall answer" across all ages.

  • Multivariate Regression as an Alternative: Provides a statistical model to control for age (or other variables) without subsetting the data.

Motivation #2: Optimal Predictions

  • Utilizing several predictor variables (independent variables) to make the best possible predictions for the dependent variable (Y).

Notation for Multivariate Regression

  • Variables: Y, and X<em>2ext,ext…X</em>KX<em>2 ext{, } ext{…} X</em>K

    • X<em>2ext,ext…X</em>KX<em>2 ext{, } ext{…} X</em>K: Covariates, explanatory variables, independent variables, Right-Hand-Side (RHS) variables, or regressors.

    • Y: Dependent variable, outcome, regressand, or Left-Hand-Side (LHS) variable.

  • KK: Represents the total number of variables being analyzed, where Kext>=2K ext{ >= } 2.

    • This includes 11 Y variable and (K−1)(K-1) X variables.

    • KK also signifies the total number of regression parameters (coefficients).

      • This includes 11 intercept (constant term) and (K−1)(K-1) "slopes" (coefficients for the X variables).

Graphical Description of Multivariate Data

  • Difficulty: Generally, it is challenging to visualize multivariate data graphically due to its high dimensionality.

  • One Exception: When there are three variables and one of the X variables is a dummy variable.

  • "Best practice" examples:

    • Edward Tufte: Known for "The Visual Display of Quantitative Information," emphasizing clarity and efficiency in data graphics (e.g., Minard's map of Napoleon's Russian campaign).

    • Hans Rosling (animated): Famous for using animated bubble charts to visualize complex socioeconomic data (e.g., Gapminder videos).

The Best-Fit "Line" with Multivariate Data: Definitions and Interpretation

  • Multivariate Best-Fit "Line" (Equation):

    • y^<em>i=b</em>1+b<em>2x</em>2i+b<em>3x</em>3i+…+b<em>Kx</em>Ki\hat{y}<em>i = b</em>1 + b<em>2x</em>{2i} + b<em>3x</em>{3i} + \text{…} + b<em>Kx</em>{Ki}

    • y^i\hat{y}_i: The predicted value for Y for individual ii.

    • b1b_1: The intercept (predicted Y when all X variables are zero).

    • b<em>kb<em>k (for k=2,…,Kk = 2, \text{…}, K): Represents the change in predicted Y for a one-unit increase in X</em>kX</em>k, holding constant all other X variables. This is akin to a partial derivative: ∂y^∂x<em>k=b</em>k\frac{\partial \hat{y}}{\partial x<em>k} = b</em>k. (The character in the slide \text{\raise.17em\hbox{\$ }} appears to be a typo for ∂\partial).

  • The Fundamental Difference in Interpretation: The key phrase is "holding the other X's constant."

Example: Wage, Education, and Gender
  • Set-Up:

    • Y: Hourly wages (WAGE)

    • X2X_2: Education in years (EDUC)

    • X3X_3: Dummy variable for female (FEMALE, where 1=female,0=male)1=\text{female}, 0=\text{male}).

  • Best-Fit Line: wage^<em>i=b</em>1+b<em>2educ</em>i+b<em>3female</em>i\hat{wage}<em>i = b</em>1 + b<em>2educ</em>i + b<em>3female</em>i

  • Interpretation of Coefficients:

    • wage^i\hat{wage}_i: The predicted wage for person ii.

    • educ<em>ieduc<em>i and female</em>ifemale</em>i: The specific values of education and female status for person ii.

    • b1b_1: The predicted wage of someone with EDUC=0EDUC=0 and FEMALE=0FEMALE=0 (i.e., a male with zero years of education).

    • b2b_2: The average change in WAGE for a one-year increase in EDUC, holding constant FEMALE (i.e., for both males and females, separately).

    • b3b_3: The average change in WAGE when FEMALE changes from 00 to 11 (i.e., for females compared to males), holding constant EDUC (i.e., for individuals with the same level of education).

  • Graphical Interpretation (with FEMALE as a dummy variable):

    • Since FEMALE is a dummy, the model generates two parallel lines (assuming no interaction term):

      • For males (FEMALE = 0): wage^<em>i=b</em>1+b<em>2educ</em>i\hat{wage}<em>i = b</em>1 + b<em>2educ</em>i

      • For females (FEMALE = 1): wage^<em>i=b</em>1+b<em>2educ</em>i+b<em>3(1)=(b</em>1+b<em>3)+b</em>2educi\hat{wage}<em>i = b</em>1 + b<em>2educ</em>i + b<em>3(1) = (b</em>1 + b<em>3) + b</em>2educ_i

    • Visualizing the effect of b<em>2b<em>2: Holding FEMALE constant (staying on one line), an increase of one unit in EDUC (e.g., from educ</em>0educ</em>0 to educ<em>0+1educ<em>0 + 1) results in a b</em>2b</em>2 unit change in wage.

    • Visualizing the effect of b<em>3b<em>3: Holding EDUC constant (moving vertically at a given educ</em>0educ</em>0), changing from FEMALE=0 to FEMALE=1 results in a b<em>3b<em>3 unit change in wage. If b</em>3<0b</em>3 < 0, the female line would be below the male line, indicating lower wages for females with the same education.

Least Squares Regression with Multivariate Data

  • Choosing the "Line": Involves selecting the optimal values for all coefficients: b<em>1,b</em>2,…,bKb<em>1, b</em>2, \text{…}, b_K.

  • Objective: To find b<em>1,b</em>2,…,b<em>Kb<em>1, b</em>2, \text{…}, b<em>K such that the average observed Y is as close as possible to its prediction (y^</em>i\hat{y}</em>i).

  • Minimization: Minimize the average squared deviation of Y from y^\hat{y} (the predicted value).

    • Deviation (Residual): e<em>i=y</em>i−y^ie<em>i = y</em>i - \hat{y}_i

    • Squared Deviation: ei2e_i^2

    • Average Squared Deviation (Mean Squared Error - MSE): 1n∑<em>i=1ne</em>i2\frac{1}{n} \sum<em>{i=1}^{n} e</em>i^2

  • The Problem (Sum of Squared Residuals - SSR): Minimize ∑<em>i=1n(y</em>i−y^<em>i)2=∑</em>i=1n(y<em>i−(b</em>1+b<em>2x</em>2i+…+b<em>Kx</em>Ki))2\sum<em>{i=1}^{n} (y</em>i - \hat{y}<em>i)^2 = \sum</em>{i=1}^{n} (y<em>i - (b</em>1 + b<em>2x</em>{2i} + \text{…} + b<em>Kx</em>{Ki}))^2

  • Solving with Calculus (First-Order Conditions): To find the minimum, we take the partial derivative of the SSR with respect to each coefficient (b<em>1,b</em>2,…,bKb<em>1, b</em>2, \text{…}, b_K) and set them to zero. This results in a system of K linear equations.

    • ∂∂b<em>1(1n∑</em>i=1n(y<em>i−b</em>1−b<em>2x</em>2i−…−b<em>Kx</em>Ki)2)=0\frac{\partial}{\partial b<em>1} \left( \frac{1}{n} \sum</em>{i=1}^{n} (y<em>i - b</em>1 - b<em>2x</em>{2i} - \text{…} - b<em>Kx</em>{Ki})^2 \right) = 0

    • ∂∂b<em>2(1n∑</em>i=1n(y<em>i−b</em>1−b<em>2x</em>2i−…−b<em>Kx</em>Ki)2)=0\frac{\partial}{\partial b<em>2} \left( \frac{1}{n} \sum</em>{i=1}^{n} (y<em>i - b</em>1 - b<em>2x</em>{2i} - \text{…} - b<em>Kx</em>{Ki})^2 \right) = 0

    • … (and so on for all b<em>kb<em>k terms up to b</em>Kb</em>K)

  • The Solution: Similar to the bivariate case, there are solution formulas for b<em>1,…,b</em>Kb<em>1, \text{…}, b</em>K, which are complex functions of the data. In practice, statistical software like Stata is used to compute these coefficients.

Measures of Goodness of Fit

1. Standard Error of the Regression (SER)
  • Definition: Measures the magnitude of the typical deviation of the observed Y from the predicted Y (y^\hat{y}).

  • Calculation: Similar to a standard deviation.

    • s<em>e2=1n−K∑</em>i=1ne<em>i2=1n−K∑</em>i=1n(y<em>i−y^</em>i)2s<em>e^2 = \frac{1}{n-K} \sum</em>{i=1}^{n} e<em>i^2 = \frac{1}{n-K} \sum</em>{i=1}^{n} (y<em>i - \hat{y}</em>i)^2

    • The Standard Error of the Regression is the square root: ses_e

      • (Note: n−Kn-K in the denominator accounts for the degrees of freedom lost in estimating K coefficients).

  • In Stata Output: Labeled as "Root MSE."

  • Interpretation:

    • Sensitive to the unit of measurement of Y, so it's best interpreted by comparing it across similar regressions.

    • A lower Standard Error of the Regression indicates a better fit of the regression model to the data.

2. R-squared (R2R^2)
  • Definition: The fraction of the total variation in Y that is "explained by" the variation in the X variables included in the model.

  • Formal Formulas:

    • ESS (Explained Sum of Squares): ESS=∑<em>i=1n(y^</em>i−yˉ)2\text{ESS} = \sum<em>{i=1}^{n} (\hat{y}</em>i - \bar{y})^2

    • TSS (Total Sum of Squares): TSS=∑<em>i=1n(y</em>i−yˉ)2\text{TSS} = \sum<em>{i=1}^{n} (y</em>i - \bar{y})^2

    • SSR (Sum of Squared Residuals): SSR=∑<em>i=1n(y</em>i−y^i)2\text{SSR} = \sum<em>{i=1}^{n} (y</em>i - \hat{y}_i)^2

    • R2=ESSTSS=1−SSRTSSR^2 = \frac{\text{ESS}}{\text{TSS}} = 1 - \frac{\text{SSR}}{\text{TSS}}

  • In Excel Output: Labeled as "R square" in the "Regression Statistics" table.

  • Interpretation:

    • R2 = 1R^2 \text{ = } 1: A perfect fit; all data points lie exactly on the regression line/plane.

    • 0<R2<10 < R^2 < 1: The usual case. A higher R2R^2 indicates a better fit of the regression model.

    • R2 = 0R^2 \text{ = } 0: No fit; the model explains none of the variation in Y.

  • Problem with R2R^2:

    • Adding more explanatory variables (X's) to the model will always increase R2R^2 or leave it unchanged.

    • This happens because TSS remains constant, and ESS will either stay the same or go up (SSR will either stay the same or go down).

    • Therefore, an increase in R2R^2 might not truly represent an improvement in the model's predictive power or fit, but merely an increase in the number of regressors (KK).

3. Adjusted R-squared (Re2xtadjR^2_ ext{adj})
  • Purpose: An alternative goodness-of-fit measure that "penalizes" models for including too many covariates, addressing the problem of R2R^2 artificially increasing with more variables.

  • Formula: Rˉ2=1−(1−R2)(n−1)n−K−1\bar{R}^2 = 1 - \frac{(1 - R^2)(n-1)}{n-K-1} (The slide presented this as Rˉ2=1−(1−R2)(n−1)n−K\bar{R}^2 = 1 - \frac{(1 - R^2)(n-1)}{n-K} which is a common variant or simplification, assuming K−1K-1 slopes. Using the slide's initial notation of KK total parameters: Rˉ2=1−(1−R2)n−1n−K\bar{R}^2 = 1 - (1-R^2) \frac{n-1}{n-K} where KK is number of total parameters)

    • More precisely from the slide: Rˉ2=1−(n−1n−K)(1−R2)\bar{R}^2 = 1 - \left( \frac{n-1}{n-K} \right) (1-R^2)

  • Comparison to R2R^2: Generally, Re2xtadj<R2R^2_ ext{adj} < R^2.

  • Difference between measures is larger when:

    • KK (the number of parameters/variables) is larger.

    • nn (the sample size) is smaller.

  • Behavior: Unlike R2R^2, Adjusted R2R^2 can either increase or decrease when a new variable is added to the model. It will only increase if the new variable significantly improves the model's fit, outweighing the penalty for adding a new parameter.

Dummy Variables and Multivariate Regression

  • Recap (Bivariate Dummy Model):

    • Model: Y=b<em>1+b</em>2D+ϵY = b<em>1 + b</em>2D + \epsilon

    • YY: Wages; DD: Female (dummy, 1=female,0=male)1=\text{female}, 0=\text{male}).

    • Interpretation: b<em>2b<em>2 is the expected change in hourly wages for a respondent who is female, compared to males (b</em>2=E[Y∣D=1]−E[Y∣D=0]b</em>2 = E[Y|D=1] - E[Y|D=0]).

  • Categorical Variables with Many Categories:

    • To use a categorical variable (e.g., region, occupation type) with multiple categories in multivariate regression, it must be recoded as a set of dummy variables.

    • Create one dummy variable for each category.

    • Rule: Include (number of categories−1)( \text{number of categories} - 1) dummy variables in the regression model.

    • Omitted Group: The category for which no dummy variable is explicitly included becomes the "reference group."

    • Interpretation: The coefficients for the included dummy variables represent the shift in the intercept relative to the omitted (reference) group, holding other variables constant.

  • Revisiting the Example: Wage, Education, Female:

    • wage^<em>i=b</em>1+b<em>2educ</em>i+b<em>3female</em>i\hat{wage}<em>i = b</em>1 + b<em>2educ</em>i + b<em>3female</em>i

    • If FEMALE=0 (omitted group for males), then predicted wage is b<em>1+b</em>2educib<em>1 + b</em>2educ_i.

    • If FEMALE=1 (included dummy for females), then predicted wage is (b<em>1+b</em>3)+b<em>2educ</em>i(b<em>1 + b</em>3) + b<em>2educ</em>i.

Dummy Variable Trap
  • Problem: If you include a dummy variable for every category of a categorical variable (e.g., both male and female dummies, plus an intercept), perfect multicollinearity will occur. This makes the model inestimable.

    • Suppose there are MM categories for a categorical variable.

  • Solution: To ensure the model is estimable, always use (M−1)(M-1) dummy variables.

    • The omitted group serves as the baseline, and its line is the one to which the lines for all other groups are compared.

    • For the omitted group, all included dummy variables will take a value of zero, making its intercept equivalent to b1b_1.

    • For an included dummy, say for group X<em>kX<em>k compared to the omitted group, its line would be (b</em>1+b<em>k)+b</em>other variablesX(b</em>1 + b<em>k) + b</em>{\text{other variables}}X (if there were other variables). Otherwise, if just using dummy and intercept (b<em>1+b</em>3X<em>dummy)(b<em>1 + b</em>3X<em>{dummy}). For instance, if original equation Y=b</em>1+b<em>3DY = b</em>1 + b<em>3D, for the omitted group it's b</em>1b</em>1, and for the dummy group it's b<em>1+b</em>3b<em>1+b</em>3. (b<em>1+b</em>3Xb<em>1 + b</em>3X as shown in the slide with XX as the dummy would be the intercept for the dummy group).