Regression output: example I
The following code provides two equivalent methods for calculating the most important pieces of the linear model output. Recall that the p-value is the probability of the observed data (or more extreme) given the null hypothesis is true. As with inference in other settings, you will need the sampling distribution for the statistic (here the slope) assuming the null hypothesis is true. You will generate the null sampling distribution in later chapters, but for now, assume that the null sampling distribution is correct. Additionally, notice that the standard error of the slope and intercept estimates describe the variability of those estimates.
This exercise is part of the course
Inference for Linear Regression in R
Exercise instructions
- Load the
mosaicData
package and load theRailTrail
data. TheRailTrail
data contains information about the number of users of a trail in Florence, MA and the weather for each day. - Using the
lm()
function, run a linear model regressing thevolume
of riders on thehightemp
for the day. Assign the output of thelm()
function to the objectride_lm
. - Use the
summary()
function on the linear model output to see the inferential analysis (including the p-value for the slope). - Additionally,
tidy()
the linear model output to make it easier to use later.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load the mosaicData package and the RailTrail data
library(mosaicData)
data(RailTrail)
# Fit a linear model
ride_lm <- ___
# View the summary of your model
___
# Print the tidy model output
___