Session Ready
Exercise

Finding the Slope and Intercept Using lm()

So you conducted your experiment when you gave people money and measured how much they like you. You calculated the slope and the intercept manually, so that you have the equation \(liking = 1.501 + 0.778 * money\).

Another way of calculating the intercept and slope is through the R function lm(). When you tell lm() your regression model, it produces your intercept and slope coefficients. You give lm() your model by first specifying the y (or response) variable, followed by a ~ symbol, then your x (or predictor variable). For example: lm(y~x). Try it for yourself in your script!

Instructions
100 XP
  • In your script, add a line of code that calculates the intercept and slope using lm()
  • Hit 'submit' and look at the answer!