Exercise

Calculating the Intercept

In your experiment where you gave participants money and measured how much they liked you, you found that the slope was 0.778. So for every single unit increase in money, the participant likes you 0.778 more! But how much do they like you when you don't give them any money (i.e. when money = 0)? To find this out we can calculate the intercept, using the equation $$intercept = \bar y - (slope * \bar x)$$ - pretty straight forward, right?

To calculate this equation you'll need to use the function mean(), which takes the name as your variable as it's argument. For example: mean(variable1) would give you the mean of variable 1.

Instructions

100 XP
  • In your script, add a line that calculates the intercept and assign this to the variable intercept.
  • In your script, print the value of intercept.
  • Remember to use brackets when necessary!