# All functions in this script are Core R (no package needed).

# Example - Two Hybrid Seeds - Difference in Mean Plant Heights
########################################################################################

# Hybrid 1 Sample
n1 <- 40
x1 <- 75.21
s1 <- .89
# Hybrid 2 Sample
n2 <- 40
x2 <- 74.89
s2 <- .95

# Sampling Error
pooled_sd <- sqrt(((n1-1)*s1*s1 + (n2-1)*s2*s2)/(n1+n2-2))
SE <- pooled_sd * sqrt(1/n1 + 1/n2)

# Multiplier for 95% CI
t_alpha2 <- qt(.975, df=78)   # 78 = 40 + 40 - 2

# CI
c((x1-x2) - t_alpha2*SE , (x1-x2) + t_alpha2*SE)
