07 Multiple Regression
07 Multiple Regression
Multiple Regression
Day 7
Multiple explanatory variables · Regression coefficients · Linear regression ·
Normality · Transformation · Additive effect · Intercept · Interaction · Parallel lines
· Response curves · Lognormal · Exponentiation · Ecological optimum · Gaussian
curve · Parabola · Back-transformation · Width of response · Hump-shaped
response · Multiple logistic regression ·Adjusted R square · Explained variation ·
Multiple regression: more
Collinearity · Variance inflation factor · Correlation matrix · Loglinear regression than 1 independent variable
1 2
Introduction Correlation Regression Calculations Assumptions Comparisons Introduction Multiple regression Collinearity Interaction Different responses
Regression Important!
1. Correlation and introduction regression
General model
2. Different distributions
Different response curves
Interaction ≠ Collinearity
3. Multiple regression
More than 1 independent variable
4. Zero-inflated models
Lots of zeros
3 4
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
5 6
EM Multiple Regression 2025
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Multiple regression
Linear regression
Regression with more than 1 independent variable
Normality test on residuals
Linear regression:
y b0 b1 x1 b2 x2 b3 x3 ...
If not: transform dependent
variable (ln, sqrt, etc.)
1 dependent variable y
Then: calculate residuals again
2 or more independent variables xi
Possible interactions between the independent variables
7 8
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
8 8
y=2.4733 +y0.5867 nutrients
= 0.5867x2 + 2.4733
R2 = 0.9219
7 y=-0.48y + 0.5836 -water
= 0.5836x1 0.48 7
Plantybiomass
Plantybiomass
6 R2 = 0.9299 6
5 5
4 4
3 3
2 2
1 1
0 0
0 2 4 6 8 10 0 2 4 6 8 10
Waterx1 Nutrients
x2
9 10
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
water
11 12
EM Multiple Regression 2025
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Biomass
Red: nutrients = 2
Nutrients=2
biomass
nutrients
water Water
y = 0.1 + 0.5 water + 0.6 nutrients y = 0.1 + 0.5 water + 0.6 nutrients
13 14
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Red: nutrients = 2
Nutrients=4
Nutrients=2
biomass
nutrients
water Water
y = 0.1 + 0.5 water + 0.6 nutrients y = 0.1 + 0.5 water + 0.6 nutrients
15 16
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Green: water = 3
Biomass
Red: water = 1
17 18
EM Multiple Regression 2025
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Today’s topics
model.water <- lm(biomass ~ water, data = biomass)
summary(model.water)
19 20
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
21 22
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
water nutrients
23 24
EM Multiple Regression 2025
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
However:
2 independent variables might be highly correlated
High correlation: they have the same effect on Y
Substitution between the independent variables
No need for both variables in the model
Problem of collinearity
25 26
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Regression Regression
27 28
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Collinearity
Regression
High collinearity when two independent variables are strongly
correlated
growth = b0 + ?
High level of collinearity: type II error (not rejecting H0, so not
including coefficient in the model)
Affects adjusted R2
29 30
EM Multiple Regression 2025
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Collinearity
Linear regression (normal distribution)
Correlation matrix:
Loglinear regression (Poisson distribution)
Correlation coefficient r
Logistic regression (binomial distriobution)
31 32
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
model.water.nutrients <- lm(biomass ~ water +
nutrients, data = biomass)
summary(model.water.nutrients )
33 34
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Today’s topics
35 36
EM Multiple Regression 2025
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Biomass
Red: water = 1
Nutrients
37 38
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Green: nutrients = 4
Red: nutrients = 2 Green: water = 3
Red: water = 1
Nutrients=4
biomass
water
39 40
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
41 42
EM Multiple Regression 2025
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
model <- lm(biomass ~ water + nutrients +
water:nutrients, data = biomass)
summary(model)
Soil water and soil nutrients have both a positive effect on the biomass of
trees and they show an interactive effect where the effect of soil water
increases with increasing nutrients and vice versa (linear regression, n=131,
water: t=36.557, p<0.001; nutrients: t=5.923, p<0.001; interaction: t=2.826,
p=0.005)
43 44
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Effect size
Large effect Small effect
Abundance species
Abundance species
Water Nutrients
45 46
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
47 48
EM Multiple Regression 2025
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Real Madrid
National team
Correlations between
Real Madrid and National team &
Barcelona and National team
49 50
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Use scale()
51 52
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Today’s topics
model.interaction.scale <- lm(biomass ~ scale(water)
+ scale(nutrients) + scale(water):scale(nutrients),
data = biomass)
summary(model.interaction.scale)
readxl Model interaction using scale()
tidyverse 1. Multiple regression
car vif(model.interaction.scale)
53 54
EM Multiple Regression 2025
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Distribution of y Transformation
Exponential curve Lognormal Ln(y) or Ln(y+1)
Biomass (g/m2)
optimum
80
Biomass (g/m2)
0
pH
0
pH
55 56
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
additional
This case: ln(y+1)=b0+b1pH+b2pH2 term
Ln(y+1)
ln or log10 to
avoid
predicting
values < 0
pH
57 58
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
Multiple regression
Gaussian.curve <- lm(log(biomass) ~ scale(pH) +
I(scale(pH)^2), data = gaussian)
summary(Gaussian.curve)
vif(Gaussian.curve)
Check multicollinearity
0
pH
Ln(y+1)=b0+b1x+b2x2
59 60
EM Multiple Regression 2025
Introduction Multiple regression Collinearity Interaction Different responses Introduction Multiple regression Collinearity Interaction Different responses
e(b0+b1x+b2x^2)
Pr =
1+e(b0+b1x+b2x^2)
61 62
Model selection
63 64