Day 8 Applied examples
June 18th, 2025
8.1 Announcements
- Homework due this Friday
- Project proposal due this Friday
- Next week will be on Zoom
- Your moment to ask the questions about mean estimation/multiple comparison you’ve always wanted to know but were too afraid to ask. [Note: I will try to include these in class, but many might be covered in STAT 870]
- From yesterday: ANOVA SS demo [R script]
url <- "https://raw.githubusercontent.com/stat720/summer2025/refs/heads/main/data/blood_study_pigs.csv"
df_pigs <- read.csv(url)
## Type I
m_intercept.only <- lm(Serum_haptoglobin_mg.dL ~ 1, data = df_pigs)
m_Trt.only <- lm(Serum_haptoglobin_mg.dL ~ Trt, data = df_pigs)
m_Trt.Day <- lm(Serum_haptoglobin_mg.dL ~ Trt+factor(Day), data = df_pigs)
m_Trt.Day.TxD <- lm(Serum_haptoglobin_mg.dL ~ Trt*factor(Day), data = df_pigs)
sum(m_intercept.only$residuals^2)
## [1] 212318.2
## [1] 81720.2
## [1] 69494.52
## [1] 24352.12
## [1] 36751.37
## Analysis of Variance Table
##
## Response: Serum_haptoglobin_mg.dL
## Df Sum Sq Mean Sq F value Pr(>F)
## Trt 5 81720 16344 80.049 < 2.2e-16 ***
## factor(Day) 1 69495 69495 340.369 < 2.2e-16 ***
## Trt:factor(Day) 5 24352 4870 23.854 < 2.2e-16 ***
## Residuals 180 36751 204
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Type II
m_intercept.only <- lm(Serum_haptoglobin_mg.dL ~ 1, data = df_pigs)
m_Day.only <- lm(Serum_haptoglobin_mg.dL ~ factor(Day), data = df_pigs)
m_Trt.only <- lm(Serum_haptoglobin_mg.dL ~ Trt , data = df_pigs)
m_Trt.Day <- lm(Serum_haptoglobin_mg.dL ~ Trt + factor(Day), data = df_pigs)
m_Trt.Day.TxD <- lm(Serum_haptoglobin_mg.dL ~ Trt*factor(Day), data = df_pigs)
sum(m_intercept.only$residuals^2)
## [1] 212318.2
## [1] 81720.2
## [1] 69494.52
## [1] 24352.12
## [1] 36751.37
## Anova Table (Type II tests)
##
## Response: Serum_haptoglobin_mg.dL
## Sum Sq Df F value Pr(>F)
## Trt 81720 5 80.049 < 2.2e-16 ***
## factor(Day) 69495 1 340.369 < 2.2e-16 ***
## Trt:factor(Day) 24352 5 23.854 < 2.2e-16 ***
## Residuals 36751 180
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1