ANOVA is a method used to determine if there are significant differences between the means of three or more groups. In optometry, this helps compare treatment effects like visual acuity or reading speed across different interventions.
Type | Use Case | R Function |
---|---|---|
One-Way ANOVA | One factor (e.g., Aid Type) | aov() |
Two-Way ANOVA | Two factors (e.g., Aid Type and Lighting) | aov() , lm() |
Repeated Measures | Same subject, different conditions | aov() with Error() , ezANOVA() |
Mixed Models | Fixed + Random effects (e.g., subject ID) | lmer() from lme4 |
Compare contrast sensitivity (CS) across three lens brands:
# Simulated Data
lens_data <- data.frame(
CS = c(1.8, 1.7, 1.9, 2.1, 2.2, 2.3, 1.6, 1.5, 1.7),
Brand = factor(rep(c("BrandA", "BrandB", "BrandC"), each = 3))
)
# Run ANOVA
model <- aov(CS ~ Brand, data = lens_data)
summary(model)
TukeyHSD(model)
shapiro.test(residuals(model))
bartlett.test(CS ~ Brand, data = lens_data)
library(ggplot2)
ggplot(lens_data, aes(x = Brand, y = CS)) +
geom_boxplot() +
labs(title = "Contrast Sensitivity by Lens Brand")
Goal: Test if reading speeds differ between three types of low vision aids.
Click here to download reading_speeds.csv
# Load data
data <- read.csv("reading_speeds.csv")
# One-way ANOVA
model <- aov(ReadingSpeed ~ AidType, data = data)
summary(model)
# Post-hoc test
TukeyHSD(model)
# Assumptions
shapiro.test(residuals(model))
bartlett.test(ReadingSpeed ~ AidType, data = data)
# Plot
library(ggplot2)
ggplot(data, aes(x = AidType, y = ReadingSpeed)) +
geom_boxplot() +
labs(title = "Reading Speed by Low Vision Aid")
Analyze responsibly. Trust your model, not your gut.