knitr::opts_chunk$set(eval = FALSE)
Is there an association between the weight and the fuel efficiency of cars? To find out, we use the mtcars dataset from the datasets package. The mtcars data originally came from the 1974 Motor Trend US magazine, and it contains design and performance data on 32 models of automobile.
# ?mtcars # more info head(mtcars)
Here, wt is weight in tons, and mpg is fuel efficiency in miles per gallon. We want to figure out if there is an association between wt and mpg. The mtcars dataset itself only has 32 rows, so we generated two larger bootstrapped datasets. We called them small and large.
Then, we fit a couple regression models to the small and large to try to detect an association between wt and mpg. Here are the coefficients and p-values from one of the model fits.
readd(coef_regression2_small)
Since the p-value on x2 is so small, there may be an association between weight and fuel efficiency after all.