Testing The Regression Model I
So we have established that we are testing our hypothesis whether giving people more money leads to them liking us more.
Remember how we used lm()
and summary()
before to see the R squared of our model? Well we're going to use these functions again to find our t-value, and associated p-value. No manual calculations necessary - pretty great, right?
The lm()
function takes the format lm(response variable ~ predictor variable)
(however of course you would write your own variable names here).
The summary()
function takes the object you would like a summary of as its first argument. In this case it's going to be your regression model.
This exercise is part of the course
Inferential Statistics
Exercise instructions
- In your script, assign your regression model to the variable
mod1
using the functionlm()
. - In your script, use the
summary()
function to find the summary ofmod1
, and assing this tosum1
. - Hit 'Submit' and have a look at the output!
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Vector containing the amount of money you gave participants
money <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
# Vector containing the amount the participants liked you
liking <- c(2.2, 2.8, 4.5, 3.1, 8.7, 5.0, 4.5, 8.8, 9.0, 9.2)
# Assign regression model to variable "mod1"
mod1 <-
# Assign the summary of 'mod1' to 'sum1'
sum1 <-
# Print 'sum1'
sum1