Suppose I have a dataset like (forget about the distribution):
modData <- data.frame("A" = rnorm(20, 15, 3),
"B" = rnorm(20, 20, 3),
"C" = rnorm(20, 25, 3),
"X" = rnorm(20, 5, 1)
)
If I use X
as a predictor, A
, B
and C
as responses, respectively:
md1 <- lm(A ~ X, data = modData)
md2 <- lm(B ~ X, data = modData)
md3 <- lm(C ~ X, data = modData)
Then do a Shapiro test and a boxcox test to every model, e.g. :
shapiro.test(residuals(md1))
boxcox(md1, plotit = T)
Is there a convenient way to build and test multiple models without manually typing each of them?