0
0
R Programmingprogramming~20 mins

ANOVA in R Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ANOVA Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of one-way ANOVA summary
What is the output of the following R code snippet that performs a one-way ANOVA on the given data?
R Programming
group <- factor(c('A','A','B','B','C','C'))
values <- c(5,7,8,9,6,7)
model <- aov(values ~ group)
summary(model)
A
Df Sum Sq Mean Sq F value Pr(&gt;F)
group 2 8.67 4.33 1.3 0.35
Residuals 3 10 3.33
B
Df Sum Sq Mean Sq F value Pr(&gt;F)
group 2 10 5 2 0.2
Residuals 3 7.5 2.5
C
Df Sum Sq Mean Sq F value Pr(&gt;F)
group 2 12 6 3 0.1
Residuals 3 6 2
DError in aov(values ~ group): object 'values' not found
Attempts:
2 left
💡 Hint
Check the degrees of freedom and sums of squares calculated by the aov function.
🧠 Conceptual
intermediate
1:30remaining
Understanding assumptions of ANOVA
Which of the following is NOT an assumption required for a valid one-way ANOVA test?
AThe residuals are normally distributed within each group.
BThe observations are independent of each other.
CThe dependent variable is measured on a nominal scale.
DThe groups have equal variances (homogeneity of variance).
Attempts:
2 left
💡 Hint
Think about the type of data ANOVA analyzes.
🔧 Debug
advanced
2:00remaining
Identify the error in two-way ANOVA code
What error will the following R code produce when run, and why?
R Programming
factor1 <- factor(c('Low','Low','High','High'))
factor2 <- factor(c('A','B','A','B'))
response <- c(10,15,20,25)
model <- aov(response ~ factor1 + factor2 + factor1:factor3)
summary(model)
AError: object 'factor3' not found
BError: response variable must be numeric
CError: factors must have the same length
DNo error, model runs successfully
Attempts:
2 left
💡 Hint
Check the variables used in the formula.
Predict Output
advanced
2:30remaining
Output of Tukey HSD post-hoc test
What is the output of the following R code performing Tukey's Honest Significant Difference test after ANOVA?
R Programming
group <- factor(c('X','X','Y','Y','Z','Z'))
values <- c(4,5,7,8,6,7)
model <- aov(values ~ group)
tukey <- TukeyHSD(model)
print(tukey)
AError in TukeyHSD(model): model must be a fitted aov object
B
  Tukey multiple comparisons of means
    95% family-wise confidence level

Fit: aov(formula = values ~ group)

$group
       diff        lwr       upr     p adj
Y-X 2.5 0.1 4.9 0.04
Z-X 1.0 -1.4 3.4 0.5
Z-Y -1.5 -3.9 0.9 0.2
C
  Tukey multiple comparisons of means
    95% family-wise confidence level

Fit: aov(formula = values ~ group)

$group
       diff        lwr       upr     p adj
Y-X 3.0 1.0 5.0 0.01
Z-X 1.5 -0.5 3.5 0.3
Z-Y -1.5 -3.5 0.5 0.2
DNo significant differences found between groups
Attempts:
2 left
💡 Hint
Check the differences and confidence intervals in the TukeyHSD output.
🧠 Conceptual
expert
1:30remaining
Interpreting interaction effects in two-way ANOVA
In a two-way ANOVA, what does a significant interaction effect between two factors imply?
ABoth factors independently affect the response variable with no influence on each other.
BNeither factor has any effect on the response variable.
CThe response variable is not normally distributed.
DThe effect of one factor on the response variable depends on the level of the other factor.
Attempts:
2 left
💡 Hint
Think about how factors influence each other in interaction.