model: \(\text{Volume} = \beta_0+\beta_1\cdot\text{Girth} + \varepsilon; \hspace{1 cm} \varepsilon \sim N(0; \sigma^2)\)
fitted: \(\text{Volume} = \hat{\beta}_0 + \hat{\beta}_1 \cdot \text{Girth}\) \(\hat{\beta}_0 = b_0 - \text{estimate of}\beta_0\); \(\hat{\beta}_1 = b_1 - \text{estimate of}\beta_1\)
# Display T-Test Results
cat("Test Statistic:", t_test_result$statistic, "\n")
## Test Statistic: -6.271668
cat("P-Value:", t_test_result$p.value, "\n")
## P-Value: 1.373725e-06
cat("Conclusion:", ifelse(t_test_result$p.value < 0.05, "Reject the null hypothesis.", "Fail to reject the null hypothesis."))
## Conclusion: Reject the null hypothesis.
Histogram of mpg
model: \(\text{Volume} = \beta_0+\beta_1\cdot\text{Girth} + \varepsilon; \hspace{1 cm} \varepsilon \sim N(0; \sigma^2)\)
fitted: \(\text{Volume} = \hat{\beta}_0 + \hat{\beta}_1 \cdot \text{Girth}\) \(\hat{\beta}_0 = b_0 - \text{estimate of}\beta_0\); \(\hat{\beta}_1 = b_1 - \text{estimate of}\beta_1\)
# Generate histogram of mpg for high and low horsepower cars
library(ggplot2)
ggplot(mtcars, aes(x = mpg, fill = factor(ifelse(hp > median(hp), "High HP", "Low HP")))) +
geom_histogram(binwidth = 3, alpha = 0.7, position = "identity") +
labs(x = "Miles per Gallon (mpg)", y = "Frequency", title = "Histogram of mpg for High and Low HP Cars")

Boxplot of mpg
model: \(\text{Volume} = \beta_0+\beta_1\cdot\text{Girth} + \varepsilon; \hspace{1 cm} \varepsilon \sim N(0; \sigma^2)\)
fitted: \(\text{Volume} = \hat{\beta}_0 + \hat{\beta}_1 \cdot \text{Girth}\) \(\hat{\beta}_0 = b_0 - \text{estimate of}\beta_0\); \(\hat{\beta}_1 = b_1 - \text{estimate of}\beta_1\)
# Generate boxplot of mpg for high and low horsepower cars
ggplot(mtcars, aes(x = factor(ifelse(hp > median(hp), "High HP", "Low HP")), y = mpg, fill = factor(ifelse(hp > median(hp), "High HP", "Low HP")))) +
geom_boxplot() +
labs(x = "Horsepower Category", y = "Miles per Gallon (mpg)", title = "Boxplot of mpg for High and Low HP Cars")

Scatterplot of mpg vs. hp
model: \(\text{Volume} = \beta_0+\beta_1\cdot\text{Girth} + \varepsilon; \hspace{1 cm} \varepsilon \sim N(0; \sigma^2)\)
fitted: \(\text{Volume} = \hat{\beta}_0 + \hat{\beta}_1 \cdot \text{Girth}\) \(\hat{\beta}_0 = b_0 - \text{estimate of}\beta_0\); \(\hat{\beta}_1 = b_1 - \text{estimate of}\beta_1\)
# Generate scatter plot of mpg vs. hp
ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point(color = "blue") +
geom_smooth(method = "lm", se = FALSE, color = "red") +
labs(x = "Horsepower (hp)", y = "Miles per Gallon (mpg)", title = "Scatter Plot of mpg vs. hp")
## `geom_smooth()` using formula = 'y ~ x'

Latex Slide
## Hypothesis Testing Equations:
## Null Hypothesis (H_0): μ_1 = μ_2
## Alternative Hypothesis (H_1): μ_1 ≠ μ_2
## t = \frac{(\bar{x}_1 - \bar{x}_2)}{\sqrt{(s_1^2/n_1) + (s_2^2/n_2)}}
## Degrees of Freedom (df) = n_1 + n_2 - 2
## P-Value (p) = P(|T| > |t|)