2025-10-19

Slide 1

Hello my name is Stephen, and this is my slides for hw3. I used mtcars to analyze the date for these slides.

Slide 2

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"))

Slide 3

ggplot(mtcars, aes(x = hp, y = mpg)) + geom_point() + geom_smooth(method = "lm",
    se = FALSE) + labs(title = "Horsepower vs. MPG", x = "Horsepower",
    y = "MPG")

Slide 4

ggplot(mtcars, aes(x = mpg)) + geom_histogram(binwidth = 2, fill = "blue",
    color = "black") + labs(title = "Distribution of MPG", x = "MPG",
    y = "Count")

Slide 5

\[ \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.

Slide 6

\[ 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.

Slide 7

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"))

Slide 8

Thanks again for watching!