Get startedGet started for free

R Squared I

These are the two lines you plotted in the last assignment. One line shows the mean, and one shows the regression line. Clearly, there is less error when we use the regression line compared to the mean line. This reduction in error from using the regression line compared to the mean line tells us how well the independent variable (money) predicts the dependent variable (prosocial behaviour).

Conveniently, the R squared is equivalent to squaring the Pearson R correlation coefficient. We're going to calculate the R squared for prosocial and money.

This exercise is part of the course

Basic Statistics

View Course

Exercise instructions

  • In your script, calculate the R squared of the relationship between money and prosocial (saved in your console).
  • Use the cor() function to find the correlation.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Calculate the R squared of prosocial and money
Edit and Run Code