# how to run this test:
# devtools::test(filter="repeated_measures_anova")
context("Repeated Measures ANOVA test")
test_that("exp_anova with repeated measures", {
df <- afex::obk.long %>% tidyr::pivot_wider(names_from="hour",values_from = "value")
# 2-way mixed repeated-measures ANOVA case
model_df <- df %>% exp_anova("value", list("treatment", Measurements=c("1","2","3","4","5")), with_repeated_measures = TRUE)
res <- model_df %>% tidy_rowwise(model, type="between")
expect_equal(res$`F Value`, c(409.021729, 5.578327, NA), tolerance=1e-4)
expect_equal(colnames(res),c("Variable","Sum of Squares","SS Ratio","DF","Mean Square","F Value","P Value","Eta Squared","Partial Eta Squared","Cohen's F","Omega Squared"))
res <- model_df %>% tidy_rowwise(model, type="within")
expect_equal(colnames(res),c("Variable","Correction","Sum of Squares","SS Ratio","DF","Mean Square","F Value","Epsilon","P Value","Eta Squared","Partial Eta Squared","Cohen's F","Omega Squared"))
res <- model_df %>% tidy_rowwise(model, type="pairs")
expect_equal(colnames(res),c("Group 1","Group 2","Difference","Conf Low","Conf High","Standard Error","DF","t Value","P Value","Method"))
res <- model_df %>% tidy_rowwise(model, type="pairs_per_variable")
expect_equal(colnames(res),c("Variable","Group 1","Group 2","Difference","Conf Low","Conf High","Standard Error","DF","t Value","P Value","Method"))
res <- model_df %>% tidy_rowwise(model, type="emmeans", pairs_adjust="tukey")
res <- model_df %>% tidy_rowwise(model, type="prob_dist")
res <- model_df %>% tidy_rowwise(model, type="levene")
res <- model_df %>% tidy_rowwise(model, type="sphericity")
expect_equal(colnames(res),c("Variable","W Value","P Value","Method","Result"))
res <- model_df %>% tidy_rowwise(model, type="shapiro")
expect_equal(colnames(res),c("W Value","P Value","Method","Rows","Result"))
res <- model_df %>% tidy_rowwise(model, type="levene", levene_test_center="mean")
expect_equal(colnames(res),c("F Value","P Value","DF","Residual DF","Method","Result"))
res <- model_df %>% tidy_rowwise(model, type="data")
res <- model_df %>% tidy_rowwise(model, type="data_summary")
# 1-way repeated-measures ANOVA case
model_df <- df %>% exp_anova("value", list(Measurements=c("1","2","3","4","5")), with_repeated_measures = TRUE)
res <- model_df %>% tidy_rowwise(model, type="between")
expect_equal(colnames(res),c("Variable","Sum of Squares","SS Ratio","DF","Mean Square","F Value","P Value","Eta Squared","Partial Eta Squared","Cohen's F","Omega Squared"))
res <- model_df %>% tidy_rowwise(model, type="within")
expect_equal(colnames(res),c("Variable","Correction","Sum of Squares","SS Ratio","DF","Mean Square","F Value","Epsilon","P Value","Eta Squared","Partial Eta Squared","Cohen's F","Omega Squared"))
res <- model_df %>% tidy_rowwise(model, type="pairs")
res <- model_df %>% tidy_rowwise(model, type="emmeans", pairs_adjust="tukey")
res <- model_df %>% tidy_rowwise(model, type="prob_dist")
res <- model_df %>% tidy_rowwise(model, type="levene")
res <- model_df %>% tidy_rowwise(model, type="sphericity")
res <- model_df %>% tidy_rowwise(model, type="shapiro")
res <- model_df %>% tidy_rowwise(model, type="levene", levene_test_center="mean")
res <- model_df %>% tidy_rowwise(model, type="data")
res <- model_df %>% tidy_rowwise(model, type="data_summary")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.