2024-09-23
In your groups of three, check the last 4 ANOVA assumptions: The SINZ.
Dataset 1: SandwichAnts
BreadAntsDataset 2: Meniscus
MethodDisplacementC. Constant effects – think about whether it is reasonable.
A. Additive effects – think about whether it is reasonable.
S. Same standard deviations – is the biggest SD less than two times as large as the smallest?
I. Independent residuals – think about whether it is reasonable.
N. Normally distributed residuals – construct a histogram or normal probability plot of residuals.
Z. Zero mean residuals – construct a histogram or normal probability plot of residuals.
Diamonds %>%
group_by(Color) %>%
summarise(n = n(),
m = mean(TotalPrice, na.rm = TRUE),
sd = sd(TotalPrice, na.rm = TRUE))# A tibble: 7 × 4
Color n m sd
<fct> <int> <dbl> <dbl>
1 D 52 5569. 4764.
2 E 82 4359. 3696.
3 F 87 9160. 10937.
4 G 86 9559. 7993.
5 H 29 8669. 6379.
6 I 12 7640. 5461.
7 J 3 1936. 737.
[1] 14.86005
For the response (Y)…
Look for:
See page 236 Diagnostic Plot for Equalizing Spreads and example 5.21 for a general tool for finding an appropriate transformation.
We can do the transformation directly in the visualization code:
OR, we can create a new variable in the dataset
Let’s transformation the Weight variable to help the heterogeneity of variance issues for y = Weight and x = Species
Hawks %>%
group_by(Species) %>%
summarise(m = mean(Weight, na.rm = TRUE),
sd = sd(Weight, na.rm = TRUE))
189.21/80.65 #check S assumption
Hawks <- Hawks %>%
mutate(Weight_new = (Weight)^.43) #transform
Hawks %>%
group_by(Species) %>%
summarise(m = mean(Weight_new, na.rm = TRUE),
sd = sd(Weight_new, na.rm = TRUE))
2.19/1.43 # check S assumption with transformed data
ggplot(Hawks, aes(x = Species, y = Weight_new)) +
geom_boxplot()
mod <- lm(Weight_new ~ Species, data = Hawks) #fitting anova model
anova(mod)See Mini Project 1 instructions