Wednesday, April 29, 2015

Relationship between Pearson correlation coefficient and the r-squared from linear regression

Simply put, if you take the square root of the r-squared value, which can be easily obtained in Excel, the outcome equals to the Pearson correlation coefficient.

Here's my R code to test this:


x<-rnorm c="" font="" nbsp="">
y<-rnorm c="" font="">
mdl <- font="" lm="" x="" y=""># linear regression model
r = summary(mdl)$r.squared # the r-squared value from linear regression
rp = cor.test(x,y, method='pearson')$estimate # rp is the Pearson correlation coefficient
sqrt(r) == rp

No comments:

Post a Comment

Any comments?

my-alpine and docker-compose.yml

 ``` version: '1' services:     man:       build: .       image: my-alpine:latest   ```  Dockerfile: ``` FROM alpine:latest ENV PYTH...