Loading [MathJax]/jax/output/CommonHTML/jax.js
+ - 0:00:00
Notes for current slide
Notes for next slide

Multiple Predictor Variables in Linear Models

1 / 47

Models with Multiple Predictors

  1. What is multiple regression?

  2. Fitting multiple regression to data.

  3. Multicollinearity.

  4. Inference with fit models

2 / 47

Our Model for Simple Linear Regression

yi=β0+β1xi+ϵi ϵiN(0,σ)

3 / 47

Our Model for Simple Linear Regression

yi=β0+β1xi+ϵi ϵiN(0,σ)

This corresponds to

3 / 47

But what if...

4 / 47

But what if...

yi=β0+β1x1i+β2x2i+ϵi ϵiN(0,σ)

4 / 47

A Small Problem: We don't know how X's relate to one another

5 / 47

Assumption of Exogeneity and Low Collinearity

6 / 47

Assumption of Exogeneity and Low Collinearity

  • Exogeneity: Xs are not correlated with e.

  • Low collinearity rx1x2 less that ~ 0.7 or 0.8

6 / 47

The Mechanics: Correlation and Partial Correlation

We can always calculate correlations.

rxy=σxyσxσy

7 / 47

The Mechanics: Correlation and Partial Correlation

We can always calculate correlations.

rxy=σxyσxσy

Now we can look at a correlation matrix

ρXi,Y=YX1X2Y10.20.5X110.3X21

7 / 47

The Mechanics: Correlation and Partial Correlation

We can always calculate correlations.

rxy=σxyσxσy

Now we can look at a correlation matrix

ρXi,Y=YX1X2Y10.20.5X110.3X21

From this, we can calculate partial correlations

7 / 47

Partial Correlations

Answers, what is the correlation between Xi and Y if we remove the portion of X1 correlated with X2

8 / 47

Partial Correlations

Answers, what is the correlation between Xi and Y if we remove the portion of X1 correlated with X2

ryx1,x2=ryx1ryx2rx1x2(1r2x1x2)(1r2yx2)

8 / 47

Partial Correlations

Answers, what is the correlation between Xi and Y if we remove the portion of X1 correlated with X2

ryx1,x2=ryx1ryx2rx1x2(1r2x1x2)(1r2yx2)

  • Subtract out the correlation of X2 on Y controlling for the correlation between X1 and X2
8 / 47

Partial Correlations

Answers, what is the correlation between Xi and Y if we remove the portion of X1 correlated with X2

ryx1,x2=ryx1ryx2rx1x2(1r2x1x2)(1r2yx2)

  • Subtract out the correlation of X2 on Y controlling for the correlation between X1 and X2

  • Scale by variability left over after accounting for the same

8 / 47

Partial Correlations

Answers, what is the correlation between Xi and Y if we remove the portion of X1 correlated with X2

ryx1,x2=ryx1ryx2rx1x2(1r2x1x2)(1r2yx2)

  • Subtract out the correlation of X2 on Y controlling for the correlation between X1 and X2

  • Scale by variability left over after accounting for the same

βyx1,x2=ρyx1,x2σx1σy

8 / 47

Sums of Squares and Partioning

SStotal=SSmodel+SSerror

9 / 47

Sums of Squares and Partioning

SStotal=SSmodel+SSerror

(YiˉY)2=(^YiˉY)2+(Yi^Yi)2

9 / 47

Sums of Squares and Partioning

SStotal=SSmodel+SSerror

(YiˉY)2=(^YiˉY)2+(Yi^Yi)2

We are trying to minimize SSerror and partition SSmodel between X1 and X2

9 / 47

Paritioning Variation

Each area is a sums of squares (i.e., amount of variability)

10 / 47

Paritioning Variation

The variation in X2 associated with Y

11 / 47

You can see how collinearity would be a problem

How can we partition this? What is unique?

12 / 47

Generalizing 2 Predictors to N Predictors

How do we represent our models that go beyond 2 predictors...

yi=β0+β1x1i+β2x2i+ϵi ϵiN(0,σ)

13 / 47

Generalizing 2 Predictors to N Predictors

How do we represent our models that go beyond 2 predictors...

yi=β0+β1x1i+β2x2i+ϵi ϵiN(0,σ)

With n predictors

yi=β0+Kj=1β1xij+ϵi ϵiN(0,σ)

13 / 47

Translating to Matrices: The General Linear Model

For a simple linear regression: [y1y2y3y4y5y6y7]=[1x11x21x31x41x51x61x7][β0β1]+[ε1ε2ε3ε4ε5ε6ε7]

14 / 47

Multiple Regression in Matrix Form

[Y1Y2Yn]=[1X11X12X1,p11X21X22X2,p11Xn1Xn2Xn,p1]×[β0β1βp1]+[ϵ1ϵ2ϵn]

15 / 47

Multiple Regression in Matrix Form

[Y1Y2Yn]=[1X11X12X1,p11X21X22X2,p11Xn1Xn2Xn,p1]×[β0β1βp1]+[ϵ1ϵ2ϵn]


ˆY=Xβ YN(ˆY,Σ)

15 / 47

The Expansiveness of the General Linear Model

ˆY=Xβ YN(ˆY,Σ)

  • This equation is huge. X can be anything - categorical, continuous, squared, sine, etc.

  • There can be straight additivity, or interactions

16 / 47

Why Multiple Predictors?

17 / 47

Models with Multiple Predictors

  1. What is multiple regression?

  2. Fitting multiple regression to data

  3. Multicollinearity

  4. Inference with fit models

18 / 47

Five year study of wildfires & recovery in Southern California shurblands in 1993. 90 plots (20 x 50m)

(data from Jon Keeley et al.)

19 / 47

What causes species richness?

  • Distance from fire patch
  • Elevation
  • Abiotic index
  • Patch age
  • Patch heterogeneity
  • Severity of last fire
  • Plant cover
20 / 47

Many Things may Influence Species Richness

21 / 47

Our Model

Richnessi=β0+β1coveri+β2firesevi+β3heteroi+ϵi

ϵiN(0,σ2)

22 / 47

Our Model

Richnessi=β0+β1coveri+β2firesevi+β3heteroi+ϵi

ϵiN(0,σ2) In R code:

klm <- lm(rich ~ cover + firesev + hetero, data=keeley)
22 / 47

Testing Assumptions

  • Data Generating Process: Linearity
23 / 47

Testing Assumptions

  • Data Generating Process: Linearity

  • Error Generating Process: Normality & homoscedasticity of residuals

23 / 47

Testing Assumptions

  • Data Generating Process: Linearity

  • Error Generating Process: Normality & homoscedasticity of residuals

  • Data: Outliers not influencing residuals

23 / 47

Testing Assumptions

  • Data Generating Process: Linearity

  • Error Generating Process: Normality & homoscedasticity of residuals

  • Data: Outliers not influencing residuals

  • Predictors: Minimal multicollinearity

23 / 47

Did We Match our Data?

24 / 47

How About That Linearity?

25 / 47

OK, Normality of Residuals?

26 / 47

OK, Normality of qResiduals?

27 / 47

No Heteroskedasticity?

28 / 47

Outliers?

29 / 47

30 / 47

Models with Multiple Predictors

  1. What is multiple regression?

  2. Fitting multiple regression to data.

  3. Multicollinearity

  4. Inference with fit models

31 / 47

Why Worry about Multicollinearity?

  • Adding more predictors decreases precision of estimates
32 / 47

Why Worry about Multicollinearity?

  • Adding more predictors decreases precision of estimates

  • If predictors are too collinear, can lead to difficulty fitting model

32 / 47

Why Worry about Multicollinearity?

  • Adding more predictors decreases precision of estimates

  • If predictors are too collinear, can lead to difficulty fitting model

  • If predictors are too collinear, can inflate SE of estimates further

32 / 47

Why Worry about Multicollinearity?

  • Adding more predictors decreases precision of estimates

  • If predictors are too collinear, can lead to difficulty fitting model

  • If predictors are too collinear, can inflate SE of estimates further

  • If predictors are too collinear, are we really getting unique information

32 / 47

Checking for Multicollinearity: Correlation Matrices

cover firesev hetero
cover 1.0000000 -0.43713460 -0.16837784
firesev -0.4371346 1.00000000 -0.05235518
hetero -0.1683778 -0.05235518 1.00000000
  • Correlations over 0.4 can be problematic, but, meh, they may be OK even as high as 0.8.

  • To be sure, we should look at how badly they change the SE around predictors.

    • How much do they inflate variance and harm our precision
33 / 47

Checking for Multicollinearity: Variance Inflation Factor

Consider our model:

y=β0+β1x1+β2x2+ϵ

34 / 47

Checking for Multicollinearity: Variance Inflation Factor

Consider our model:

y=β0+β1x1+β2x2+ϵ

We can also model:

X1=α0+α2x2+ϵj

The variance of X1 associated with other predictors is R21

34 / 47

Checking for Multicollinearity: Variance Inflation Factor

Consider our model:

y=β0+β1x1+β2x2+ϵ

We can also model:

X1=α0+α2x2+ϵj

The variance of X1 associated with other predictors is R21

In MLR, the variance around our parameter estimate (square of SE) is:

var(β1)=σ2(n1)σ2X111R21

34 / 47

Checking for Multicollinearity: Variance Inflation Factor

Consider our model:

y=β0+β1x1+β2x2+ϵ

We can also model:

X1=α0+α2x2+ϵj

The variance of X1 associated with other predictors is R21

In MLR, the variance around our parameter estimate (square of SE) is:

var(β1)=σ2(n1)σ2X111R21

The second term in that equation is the Variance Inflation Parameter

VIF=11R21

34 / 47

Checking for Multicollinearity: Variance Inflation Factor

VIF1=11R21

VIF > 5 or 10 can be problematic and indicate an unstable solution.

35 / 47

What Do We Do with High Collinearity?

  • Cry.
36 / 47

What Do We Do with High Collinearity?

  • Cry.

  • Evaluate why

36 / 47

What Do We Do with High Collinearity?

  • Cry.

  • Evaluate why

  • Can drop a predictor if information is redundant
36 / 47

What Do We Do with High Collinearity?

  • Cry.

  • Evaluate why

  • Can drop a predictor if information is redundant

  • Can combine predictors into an index

    • Add them? Or other combination.

    • PCA for orthogonal axes

    • Factor analysis to compress into one variable

36 / 47

Models with Multiple Predictors

  1. What is multiple regression?

  2. Fitting multiple regression to data.

  3. Multicollinearity.

  4. Inference with fit models

37 / 47

What does it all mean: the coefficients

Richnessi=β0+β1coveri+β2firesevi+β3heteroi+ϵi

term estimate std.error
(Intercept) 1.68 10.67
cover 15.56 4.49
firesev -1.82 0.85
hetero 65.99 11.17
  • β0 - the intercept - is the # of species when all other predictors are 0
    • Note the very large SE
38 / 47

What does it all mean: the coefficients

Richnessi=β0+β1coveri+β2firesevi+β3heteroi+ϵi

term estimate std.error
(Intercept) 1.68 10.67
cover 15.56 4.49
firesev -1.82 0.85
hetero 65.99 11.17
  • β0 - the intercept - is the # of species when all other predictors are 0

    • Note the very large SE
  • All other βs are the effect of a 1 unit increase on # of species

    • They are not on the same scale
    • They are each in the scale of species per unit of individual x
38 / 47

Comparing Coefficients on the Same Scale

rxy=bxysdxsdy

# Standardization method: basic
Parameter | Std. Coef. | 95% CI
-----------------------------------------
(Intercept) | 0.00 | [ 0.00, 0.00]
cover | 0.33 | [ 0.14, 0.51]
firesev | -0.20 | [-0.38, -0.01]
hetero | 0.50 | [ 0.33, 0.67]
39 / 47

Comparing Coefficients on the Same Scale

rxy=bxysdxsdy

# Standardization method: basic
Parameter | Std. Coef. | 95% CI
-----------------------------------------
(Intercept) | 0.00 | [ 0.00, 0.00]
cover | 0.33 | [ 0.14, 0.51]
firesev | -0.20 | [-0.38, -0.01]
hetero | 0.50 | [ 0.33, 0.67]
  • For linear model, makes intuitive sense to compare strength of association
  • Note, this is Pearson's correlation, so, it's in units of sdy/sdx
39 / 47

How Much Variation is Associated with the Predictors

r.squared adj.r.squared
0.41 0.39
  • 41% of the variation in # of species is associated with the predictors
40 / 47

How Much Variation is Associated with the Predictors

r.squared adj.r.squared
0.41 0.39
  • 41% of the variation in # of species is associated with the predictors

  • Note that this is all model, not individual predictors

40 / 47

How Much Variation is Associated with the Predictors

r.squared adj.r.squared
0.41 0.39
  • 41% of the variation in # of species is associated with the predictors

  • Note that this is all model, not individual predictors

  • R2adj=1(1R2)(n1)nk1
    • Scales fit by model complexity
    • If we add more terms, but don't increase R2, it can go down
40 / 47

So, Uh, How Do We Visualize This?

41 / 47

Visualization Strategies for Multivariate Models

  • Plot the effect of each variable holding the other variables constant
    • Mean, Median, 0
    • Or your choice!
  • Plot counterfactual scenarios from model
    • Can match data (and be shown as such)
    • Can bexplore the response surface
42 / 47

Added Variable Plot to Show Unique Contributions when Holding Others at 0

43 / 47

Plots at Median of Other Variables

44 / 47

Counterfactual Predictions Overlaid on Data

45 / 47

Counterfactual Surfaces at Means of Other Variables

46 / 47

47 / 47

Models with Multiple Predictors

  1. What is multiple regression?

  2. Fitting multiple regression to data.

  3. Multicollinearity.

  4. Inference with fit models

2 / 47
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow