Overview
psych350lab supports three types of 2×2 factorial ANOVA:
All three follow the same general workflow and return similarly structured results. This guide covers each design with examples.
Between-Groups Factorial (2×2 BG)
1. Run the Analysis
library ( psych350lab )
library ( psych350data )
library ( dplyr )
data ( superman , package = "psych350data" )
# 2×2 BG factorial: Height group × Tomatometer → Audience score
bg_factorial <- anova_factorial_answers (
data = superman ,
dv = "rt_audience_score" ,
iv1 = "clark_grp" ,
iv2 = "tomatometer" ,
iv1_labels = c ( "Under 6ft" , "6ft or taller" ) ,
iv2_labels = c ( "Rotten" , "Fresh" )
)
# Main effects and interaction
bg_factorial $ ANOVA
# Cell means
bg_factorial $ Descriptives
What anova_factorial_answers() returns
$ANOVA
List with iv1, iv2, and interaction sub-lists, each containing F, p_value, df_effect, df_error, mse
$Descriptives
Tibble with iv1_level, iv2_level, mean, sd, n for each cell
$Marginal_Means
Marginal means for each IV
4. APA Tables
# Factorial ANOVA statistics table
create_factbg_anova_stats_table (
rh_name = "RH1" ,
anova_results_list = bg_factorial ,
iv1_name = "Height Group" ,
iv2_name = "Tomatometer"
)
# Cell means table
create_apa_factbg_desc_table (
anova_results_list = bg_factorial ,
iv1_name = "Height Group" ,
iv2_name = "Tomatometer" ,
KEY = TRUE ,
table_title = "Cell Means for Audience Score"
)
5. Interaction and Main Effect Results
These functions generate formatted text describing the interaction and main effects, suitable for worksheets:
6. Write-Up
writeup <- apa_2x2_bg_factorial_writeup (
factorial_results_list = bg_factorial ,
dv_name = "audience score" ,
factor_a_name = "height group" ,
factor_b_name = "Tomatometer rating" ,
factor_a_labels = c ( "under 6ft" , "6ft or taller" ) ,
factor_b_labels = c ( "Rotten" , "Fresh" ) ,
hypothesis = list (
rh_text = "an interaction between height and rating on audience scores"
) ,
report_main_effects = TRUE
)
# cat(writeup)
Mixed Factorial (2×2 MG)
1. Run the Analysis
In a mixed design, one IV is between-subjects and one is within-subjects (repeated measures).
# Mixed factorial: Height group (BG) × Score type (WG)
mg_factorial <- anova_factmg_answers (
data = superman ,
dv = "rt_audience_score" , # placeholder - see function docs
iv1 = "clark_grp" , # between-subjects IV
iv2 = "score_type" , # within-subjects IV
iv1_labels = c ( "Under 6ft" , "6ft or taller" ) ,
iv2_labels = c ( "Critics Score" , "Audience Score" )
)
Within-Groups Factorial (2×2 WG)
1. Run the Analysis
In a fully within-subjects design, each participant is measured in all four cells. You provide the four DV column names directly.
# Four columns: one per cell (IV1_level1 × IV2_level1, etc.)
wg_factorial <- anova_factwg_answers (
data = superman ,
dv_a1b1 = "score_critics_fresh" ,
dv_a1b2 = "score_critics_rotten" ,
dv_a2b1 = "score_audience_fresh" ,
dv_a2b2 = "score_audience_rotten" ,
iv1_labels = c ( "Critics" , "Audience" ) ,
iv2_labels = c ( "Fresh" , "Rotten" )
)
3. Write-Up
writeup <- apa_2x2_wg_factorial_writeup (
wg_factorial_results_list = wg_factorial ,
dv_name = "rating score" ,
factor_a_name = "score type" ,
factor_b_name = "rating" ,
factor_a_labels = c ( "critics" , "audience" ) ,
factor_b_labels = c ( "Fresh" , "Rotten" ) ,
hypothesis = list (
rh_text = "an interaction between score type and rating"
)
)
# cat(writeup)
Shared Functions by Design
Each factorial design has its own checker and formatting functions:
Between-Groups Functions
# Factorial ANOVA checker (interactive HTML)
create_factbg_anova_checker (
rh_name = "RH1" ,
anova_results_list = bg_factorial ,
iv1_name = "Height Group" ,
iv2_name = "Tomatometer"
)
# Cell descriptives checker
create_factbg_desc_checker (
anova_results_list = bg_factorial ,
iv1_name = "Height Group" ,
iv2_name = "Tomatometer"
)
# Table with pairwise comparisons
create_factbg_comparisons_table (
anova_results_list = bg_factorial ,
iv1_name = "Height Group" ,
iv2_name = "Tomatometer"
)
Mixed Factorial Functions
# Mixed factorial ANOVA checker
create_factmg_anova_checker (
rh_name = "RH1" ,
anova_results_list = mg_factorial ,
bg_name = "Height Group" ,
wg_name = "Score Type"
)
# Cell descriptives checker
create_factmg_desc_checker (
anova_results_list = mg_factorial ,
bg_name = "Height Group" ,
wg_name = "Score Type"
)
Within-Groups Functions
# Within-groups factorial ANOVA checker
create_factwg_anova_checker (
rh_name = "RH1" ,
anova_results_list = wg_factorial ,
iv1_name = "Score Type" ,
iv2_name = "Rating"
)
# Cell descriptives checker
create_factwg_desc_checker (
anova_results_list = wg_factorial ,
iv1_name = "Score Type" ,
iv2_name = "Rating"
)
Key Functions Reference
Display Functions — Between-Groups
Display Functions — Mixed
Display Functions — Within-Groups