lindeloev / tests-as-linear

Common statistical tests are linear models (or: how to teach stats)
https://lindeloev.github.io/tests-as-linear/
487 stars 92 forks source link

correlation vs linear model #27

Open jerlich opened 3 years ago

jerlich commented 3 years ago

First, just want to say that i love this! So thanks for the work.

Maybe you can add a little note for the section on correlations: There is a difference between corr(x,y) and lm(y ~ 1 + x). Correlation is commutative corr(x,y) = corr(y,x) but lm(y ~ 1 + x) ≠ lm(x ~ 1 + y). It's especially relevant when both x and y contain measurement error.

A good reference for this is here: https://elifesciences.org/articles/00638 The tls package in R provides one option for computing this.