Three Way Anova With R

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Three-way Anova with R Y : numeric continuous variable

Goal: Find which factors influence a quantitative


continuous variable, taking into account their possible
stats package - No install required A, B, C, … : factor (categorical) variables
interactions

Graphical exploration Write a formula in R

Full model
Plot the mean of Y for the different factors levels
Y ~ A * B * C
plot.design(Y ~ ., data = data) same as
Y ~ A + B + C + A:B + A:C + B:C + A:B:C
Plot the mean of Y for two-way combinations of factors Update a formula
interaction.plot(data$A, data$B, data$Y)
update(oldformula, newformula)
ex update(Y ~ A + B, . ~ . + C) #> Y ~ A + B + C
update( Y ~ A + B + C, . ~ . - C) #> Y ~ A + B
Model building

Generate the full model Diagnostics & Prediction


m1 <- aov(Y ~ A * B * C, data = data)
Update an Anova model Residual plots
m2 <- update(m1, . ~ . - A:B:C) #Remove interaction plot(m2)

Analysis of variance table Predict new values


summary(m1) predict(object = m2, newdata = newdata)

Comparison between nested models


anova(m1, m2)

[These are just the


first two rows!]

This cheat sheet part of Raccoon - Statistical models with R | CC by Quantide | Learn more at http://www.quantide.com/web-books-overview/ | info@quantide.com | Updated: 02/17

You might also like