---
title: "Assignment 3"
subtitle: "STAT3373"
author: "Isaac Shoebottom"
date: "Oct 2nd, 2025"
output:
  pdf_document: default
  html_document:
    df_print: paged
---
```{r message=FALSE, warning=FALSE}
library(tidyverse)
library(broom)
library(car)
library(effectsize)
library(knitr)
library(kableExtra)
```

```{r}
# Create the fertilizer dataset
fertilizer_data <- data.frame(
  yield = c(4.2, 4.5, 4.1, 4.8, 4.3,  # Fertilizer A
            5.1, 5.3, 4.9, 5.2, 5.0,  # Fertilizer B
            3.8, 4.0, 3.6, 4.2, 3.9,  # Fertilizer C
            5.5, 5.8, 5.4, 5.7, 5.6), # Fertilizer D
  fertilizer = factor(rep(c("A", "B", "C", "D"), each = 5))
)

kable(fertilizer_data, caption = "Tomato Yield Data") %>%
  kable_styling(bootstrap_options = c("striped", "hover"))

fertilizer_data %>%
  group_by(fertilizer) %>%
  summarise(
    mean = mean(yield),
    sd = sd(yield),
    n = n()
  )
```

# Question 1

## a)

```{r}
ggplot(fertilizer_data, aes(x = fertilizer, y = yield)) +
  geom_boxplot(fill = "lightblue") +
  geom_jitter(width = 0.1) +
  labs(title = "Tomato Yield by Fertilizer",
       y = "Yield (kg)",
       x = "Fertilizer")
```

Analysis:

-   Fertilizer D appears to produce the highest yields.

-   Fertilizer C appears lowest.

-   Variability is similar across groups.

## b)

```{r}
fertilizer_aov <- aov(yield ~ fertilizer, data = fertilizer_data)
summary(fertilizer_aov)
```

p-value \< 0.05, reject H_0. There is a statistically significant difference in mean yield among fertilizers

# Question 2

## a)

```{r}
teaching_data <- tibble(
  score = c(78,82,75,80,77,83,79,
            85,88,84,87,86,90,83,
            81,79,83,85,82,78,80),
  method = factor(rep(c("Traditional", "Interactive", "Online"), each = 7))
)
```

## b)

```{r}
teaching_aov <- aov(score ~ method, data = teaching_data)
summary(teaching_aov)
```

p-value \< 0.05, reject H_0, significant differences exist.

# Question 3

```{r}
supplier_data <- tibble(
  strength = c(245,250,248,252,249,247,
               240,238,242,241,239,243,
               255,258,254,257,256,253,
               248,246,250,249,247,251),
  supplier = factor(rep(paste("Supplier", 1:4), each = 6))
)

supplier_aov <- aov(strength ~ supplier, data = supplier_data)
summary(supplier_aov)
```

p-value \< 0.01, reject H_0, significant differences exist
