Download as pdf or txt
Download as pdf or txt
You are on page 1of 46

Quantifying the

strength of bivariate
relationships
C O R R E L AT I O N A N D R E G R E S S I O N I N R

Ben Baumer
Assistant Professor at Smith College
Correlation
Correlation coe cient between -1 and 1

Sign —> direction

Magnitude —> strength

CORRELATION AND REGRESSION IN R


Near perfect correlation

CORRELATION AND REGRESSION IN R


Strong

CORRELATION AND REGRESSION IN R


Moderate

CORRELATION AND REGRESSION IN R


Weak

CORRELATION AND REGRESSION IN R


Zero

CORRELATION AND REGRESSION IN R


Negative

CORRELATION AND REGRESSION IN R


Non-linear

CORRELATION AND REGRESSION IN R


Non-linear correlation
run10 %>%
filter(divPlace <= 10) %>%
ggplot(aes(x = age, y = pace, color = gender)) +
geom_point()

CORRELATION AND REGRESSION IN R


Pearson product-moment correlation

CORRELATION AND REGRESSION IN R


Pearson product-moment correlation

∑i=1 (xi − x̄) (yi − ȳ)


n
r(x, y) =
2
√∑i=1 (xi − x̄) ⋅ ∑i=1 (yi −
n n ȳ )2

CORRELATION AND REGRESSION IN R


Let's practice!
C O R R E L AT I O N A N D R E G R E S S I O N I N R
The Anscombe
dataset
C O R R E L AT I O N A N D R E G R E S S I O N I N R

Ben Baumer
Assistant Professor at Smith College
Anscombe
ggplot(data = Anscombe, aes(x = x, y = y)) +
geom_point() +
facet_wrap(~ set)

CORRELATION AND REGRESSION IN R


Anscombe 1
Anscombe %>%
filter(set == 1) %>%
ggplot(aes(x = x, y = y)) +
geom_point()

CORRELATION AND REGRESSION IN R


Anscombe 2
Anscombe %>%
filter(set == 2) %>%
ggplot(aes(x = x, y = y)) +
geom_point()

CORRELATION AND REGRESSION IN R


Anscombe 3
Anscombe %>%
filter(set == 3) %>%
ggplot(aes(x = x, y = y)) +
geom_point()

CORRELATION AND REGRESSION IN R


Anscombe 4
Anscombe %>%
filter(set == 4) %>%
ggplot(aes(x = x, y = y)) +
geom_point()

CORRELATION AND REGRESSION IN R


Let's practice!
C O R R E L AT I O N A N D R E G R E S S I O N I N R
Interpretation of
Correlation
C O R R E L AT I O N A N D R E G R E S S I O N I N R

Ben Baumer
Assistant Professor at Smith College
Exercise and beer

1Source: h p://well.blogs.nytimes.com/2015/12/02/the-close-ties-between-
exercise-and-beer/

CORRELATION AND REGRESSION IN R


Exercise and beer

1Source: h p://well.blogs.nytimes.com/2015/12/02/the-close-ties-between-
exercise-and-beer/

CORRELATION AND REGRESSION IN R


Exercise and beer

1Source: h p://well.blogs.nytimes.com/2015/12/02/the-close-ties-between-
exercise-and-beer/

CORRELATION AND REGRESSION IN R


Exercise and beer

1Source: h p://well.blogs.nytimes.com/2015/12/02/the-close-ties-between-
exercise-and-beer/

CORRELATION AND REGRESSION IN R


Exercise and beer

1Source: h p://well.blogs.nytimes.com/2015/12/02/the-close-ties-between-
exercise-and-beer/

CORRELATION AND REGRESSION IN R


Exercise and beer

1Source: h p://well.blogs.nytimes.com/2015/12/02/the-close-ties-between-
exercise-and-beer/

CORRELATION AND REGRESSION IN R


Exercise and beer

CORRELATION AND REGRESSION IN R


Exercise and beer

CORRELATION AND REGRESSION IN R


Exercise and beer

CORRELATION AND REGRESSION IN R


Exercise and beer

CORRELATION AND REGRESSION IN R


NFL arrests

1Source: h ps://www.nytimes.com/2014/09/13/upshot/what-the-numbers-
show-about-n -player-arrests.html

CORRELATION AND REGRESSION IN R


NFL arrests

CORRELATION AND REGRESSION IN R


NFL arrests

CORRELATION AND REGRESSION IN R


NFL arrests

CORRELATION AND REGRESSION IN R


Correlation vs. regression

1Source: h p://www.nytimes.com/2012/11/02/business/questions-raised-on-
withdrawal-of-congressional-research-services-report-on-tax-rates.html

CORRELATION AND REGRESSION IN R


Correlation vs. regression

1Source: h p://www.nytimes.com/2012/11/02/business/questions-raised-on-
withdrawal-of-congressional-research-services-report-on-tax-rates.html

CORRELATION AND REGRESSION IN R


Correlation vs. regression

1Source: h p://www.nytimes.com/2012/11/02/business/questions-raised-on-
withdrawal-of-congressional-research-services-report-on-tax-rates.html

CORRELATION AND REGRESSION IN R


Can you plot a correlation?

1Source: h p://heatst.com/world/no-correlation-between-voting-for-brexit-
and-racism-study- nds/

CORRELATION AND REGRESSION IN R


Let's practice!
C O R R E L AT I O N A N D R E G R E S S I O N I N R
Spurious
correlations
C O R R E L AT I O N A N D R E G R E S S I O N I N R

Ben Baumer
Assistant Professor at Smith College
Spurious over time

CORRELATION AND REGRESSION IN R


Spurious over time

CORRELATION AND REGRESSION IN R


Spurious over space

CORRELATION AND REGRESSION IN R


Spurious for whatever reason

CORRELATION AND REGRESSION IN R


Let's practice!
C O R R E L AT I O N A N D R E G R E S S I O N I N R

You might also like