2026-03-04

Background

  • Data set examines effect of different does of Vitamin C on tooth length in Guinea Pigs
  • Orange Juice (OJ) and Vitamin C as Ascorbic Acid (VC) were used as the supplement types
  • A Regression Model and Hypothesis Test were conducted

Scatter Plot (Plotly)

Linear Regression (ggplot)

Mean Tooth Length with Error Bars

Linear Regression

We model the Linear relationship between tooth length and dose as

\[ y_i = \beta_0 + \beta_1 x_i + \epsilon_i \]

where

\[ \epsilon_i \sim N(0, \sigma^2). \]

The ordinary least squares (OLS) estimator is

\[ \hat{\beta} = (X^T X)^{-1} X^T y. \]

Hypothesis Testing

To test whether dose significantly affects tooth length, we test

\[ H_0 : \beta_1 = 0 \] versus \[ H_A : \beta_1 \ne 0. \]

The test statistic is

\[ t = \frac{\hat{\beta}_1}{SE(\hat{\beta}_1)} \]

which follows a \(t_{n-p}\) distribution under \(H_0\).

Confidence Interval

A 95% confidence interval for the slope is

\[ \hat{\beta}_1 \pm t_{n-p,\,0.975}\, SE(\hat{\beta}_1). \] If the interval does not include 0, we reject \(H_0\)

R Code for Regression Model

library(ggplot2)
ggplot(ToothGrowth, aes(x = dose, y = len, color = supp)) + 
  geom_point() + 
  geom_smooth(method = 'lm', level = .99, se = TRUE) + 
  labs(title = "Linear Regression: Dose vs Tooth Length",
       x = "Dose (mg)",
       y = "Tooth Length (mm)")