Hello my name is Stephen, and this is my slides for hw3. I used mtcars to analyze the date for these slides.
2025-10-19
Hello my name is Stephen, and this is my slides for hw3. I used mtcars to analyze the date for these slides.
plot_ly(data = mtcars, x = ~wt, y = ~mpg, color = ~factor(cyl),
type = "scatter", mode = "markers") %>%
layout(title = "Car Weight vs. MPG by Cylinders", xaxis = list(title = "Weight (1000 lbs)"),
yaxis = list(title = "MPG"))
ggplot(mtcars, aes(x = hp, y = mpg)) + geom_point() + geom_smooth(method = "lm",
se = FALSE) + labs(title = "Horsepower vs. MPG", x = "Horsepower",
y = "MPG")
ggplot(mtcars, aes(x = mpg)) + geom_histogram(binwidth = 2, fill = "blue",
color = "black") + labs(title = "Distribution of MPG", x = "MPG",
y = "Count")
\[ \hat{y} = \beta_0 + \beta_1 x \] where \(\hat{y}\) is predicted MPG, \(x\) is horsepower, \(\beta_0\) is the intercept, and \(\beta_1\) is the slope.
\[ r = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum (x_i - \bar{x})^2 \sum (y_i - \bar{y})^2}} \] where \(x_i\) is weight, \(y_i\) is MPG, \(\bar{x}\) and \(\bar{y}\) are means.
plot_ly(data = mtcars, x = ~wt, y = ~mpg, color = ~factor(cyl),
type = "scatter", mode = "markers") %>%
layout(title = "Car Weight vs. MPG by Cylinders", xaxis = list(title = "Weight (1000 lbs)"),
yaxis = list(title = "MPG"))
Thanks again for watching!