{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE)
```{r cars} # Load required libraries install.packages(“tidymodels”) library(tidymodels)
data(“Auto”)
model <- lm(mpg ~ horsepower, data = Auto)
summary(model)
#i. There is a relationship between horsepower (predictor) and mpg (response) because the p-value is extremely below 0.05, which means that chances that this relationship occurred, when there is no relationship at all , is extremely slim, therefore there has to be a relationship #ii. The relationship is strong, about 60%, because the R^2 = .6059. This statistic measures the proportion of variability in response that can be explained using the predictor. #iii. The relationship between mpg and horsepower has a negative relationship because the coefficient of horsepower (predictor) is negative
predict(model, data.frame(horsepower=c(98)), interval=“prediction”)
attach(Auto) plot(horsepower, mpg) # Plot points abline(model) # Add Least Squares Regression Line
par(mfrow = c(2,2)) # 4 plots in same picture plot(model)
summary(cars) ```