Creates an ANOVA table in APA style based output of ezANOVA command from ez package

apa.ezANOVA.table(ez.output, correction = "GG", table.title = "", filename,
  table.number = NA)

Arguments

ez.output

Output object from ezANOVA command from ez package

correction

Type of sphercity correction: "none", "GG", or "HF" corresponding to none, Greenhouse-Geisser and Huynh-Feldt, respectively.

table.title

String containing text for table title

filename

(optional) Output filename document filename (must end in .rtf or .doc only)

table.number

Integer to use in table number output line

Value

APA table object

Examples

# # ** Example 1: Between Participant Predictors # library(apaTables) library(ez) # See format where one row represents one PERSON # Note that participant, gender, and alcohol are factors print(goggles)
#> participant gender alcohol attractiveness #> 1 1 Female None 65 #> 2 2 Female None 70 #> 3 3 Female None 60 #> 4 4 Female None 60 #> 5 5 Female None 60 #> 6 6 Female None 55 #> 7 7 Female None 60 #> 8 8 Female None 55 #> 9 9 Female 2 Pints 70 #> 10 10 Female 2 Pints 65 #> 11 11 Female 2 Pints 60 #> 12 12 Female 2 Pints 70 #> 13 13 Female 2 Pints 65 #> 14 14 Female 2 Pints 60 #> 15 15 Female 2 Pints 60 #> 16 16 Female 2 Pints 50 #> 17 17 Female 4 Pints 55 #> 18 18 Female 4 Pints 65 #> 19 19 Female 4 Pints 70 #> 20 20 Female 4 Pints 55 #> 21 21 Female 4 Pints 55 #> 22 22 Female 4 Pints 60 #> 23 23 Female 4 Pints 50 #> 24 24 Female 4 Pints 50 #> 25 25 Male None 50 #> 26 26 Male None 55 #> 27 27 Male None 80 #> 28 28 Male None 65 #> 29 29 Male None 70 #> 30 30 Male None 75 #> 31 31 Male None 75 #> 32 32 Male None 65 #> 33 33 Male 2 Pints 45 #> 34 34 Male 2 Pints 60 #> 35 35 Male 2 Pints 85 #> 36 36 Male 2 Pints 65 #> 37 37 Male 2 Pints 70 #> 38 38 Male 2 Pints 70 #> 39 39 Male 2 Pints 80 #> 40 40 Male 2 Pints 60 #> 41 41 Male 4 Pints 30 #> 42 42 Male 4 Pints 30 #> 43 43 Male 4 Pints 30 #> 44 44 Male 4 Pints 55 #> 45 45 Male 4 Pints 35 #> 46 46 Male 4 Pints 20 #> 47 47 Male 4 Pints 45 #> 48 48 Male 4 Pints 40
# Use ezANOVA # Be sure use the options command, as below, to ensure sufficient digits options(digits = 10) goggles_results <- ezANOVA(data = goggles, dv = attractiveness, between = .(gender, alcohol), participant , detailed = TRUE)
#> Coefficient covariances computed by hccm()
# Make APA table goggles_table <- apa.ezANOVA.table(goggles_results, filename="ex1_ez_independent.doc") print(goggles_table)
#> #> #> ANOVA results #> #> #> Predictor df_num df_den SS_num SS_den F p ges #> gender 1 42 168.75 3487.50 2.03 .161 .05 #> alcohol 2 42 3332.29 3487.50 20.07 .000 .49 #> gender x alcohol 2 42 1978.12 3487.50 11.91 .000 .36 #> #> Note. df_num indicates degrees of freedom numerator. df_den indicates degrees of freedom denominator. #> SS_num indicates sum of squares numerator. SS_den indicates sum of squares denominator. #> ges indicates generalized eta-squared. #> #>
# # ** Example 2: Within Participant Predictors # library(apaTables) library(tidyr) library(forcats) library(ez) # See initial wide format where one row represents one PERSON print(drink_attitude_wide)
#> # A tibble: 20 x 10 #> participant beer_positive beer_negative beer_neutral wine_positive #> <fct> <int> <int> <int> <int> #> 1 P1 1 6 5 38 #> 2 P2 43 30 8 20 #> 3 P3 15 15 12 20 #> 4 P4 40 30 19 28 #> 5 P5 8 12 8 11 #> 6 P6 17 17 15 17 #> 7 P7 30 21 21 15 #> 8 P8 34 23 28 27 #> 9 P9 34 20 26 24 #> 10 P10 26 27 27 23 #> 11 P11 1 -19 -10 28 #> 12 P12 7 -18 6 26 #> 13 P13 22 -8 4 34 #> 14 P14 30 -6 3 32 #> 15 P15 40 -6 0 24 #> 16 P16 15 -9 4 29 #> 17 P17 20 -17 9 30 #> 18 P18 9 -12 -5 24 #> 19 P19 14 -11 7 34 #> 20 P20 15 -6 13 23 #> # ... with 5 more variables: wine_negative <int>, wine_neutral <int>, #> # water_positive <int>, water_negative <int>, water_neutral <int>
# Convert data from wide format to long format where one row represents one OBSERVATION. # Wide format column names MUST represent levels of each variable separated by an underscore. # See vignette for further details. drink_attitude_long <- gather(data = drink_attitude_wide, key = cell, value = attitude, beer_positive:water_neutral, factor_key=TRUE) drink_attitude_long <- separate(data = drink_attitude_long, col = cell, into = c("drink","imagery"), sep = "_", remove = TRUE) drink_attitude_long$drink <- as_factor(drink_attitude_long$drink) drink_attitude_long$imagery <- as_factor(drink_attitude_long$imagery) # See new long format of data, where one row is one OBSERVATION. # As well, notice that we have two columns (drink, imagery) # drink, imagery, and participant are factors print(drink_attitude_long)
#> # A tibble: 180 x 4 #> participant drink imagery attitude #> <fct> <fct> <fct> <int> #> 1 P1 beer positive 1 #> 2 P2 beer positive 43 #> 3 P3 beer positive 15 #> 4 P4 beer positive 40 #> 5 P5 beer positive 8 #> 6 P6 beer positive 17 #> 7 P7 beer positive 30 #> 8 P8 beer positive 34 #> 9 P9 beer positive 34 #> 10 P10 beer positive 26 #> # ... with 170 more rows
# Set contrasts to match Field et al. (2012) textbook output alcohol_vs_water <- c(1, 1, -2) beer_vs_wine <- c(-1, 1, 0) negative_vs_other <- c(1, -2, 1) positive_vs_neutral <- c(-1, 0, 1) contrasts(drink_attitude_long$drink) <- cbind(alcohol_vs_water, beer_vs_wine) contrasts(drink_attitude_long$imagery) <- cbind(negative_vs_other, positive_vs_neutral) # Use ezANOVA # Be sure use the options command, as below, to ensure sufficient digits options(digits = 10) drink_attitude_results <- ezANOVA(data = drink_attitude_long, dv = .(attitude), wid = .(participant), within = .(drink, imagery), type = 3, detailed = TRUE) # Make APA table drink_table <- apa.ezANOVA.table(drink_attitude_results, filename="ex2_repeated_table.doc") print(drink_table)
#> #> #> ANOVA results #> #> #> Predictor df_num df_den Epsilon SS_num SS_den F p ges #> (Intercept) 1.00 19.00 11218.01 1920.11 111.01 .000 .41 #> drink 1.15 21.93 0.58 2092.34 7785.88 5.11 .030 .12 #> imagery 1.49 28.40 0.75 21628.68 3352.88 122.56 .000 .58 #> drink x imagery 3.19 60.68 0.80 2624.42 2906.69 17.15 .000 .14 #> #> Note. df_num indicates degrees of freedom numerator. df_den indicates degrees of freedom denominator. #> Epsilon indicates Greenhouse-Geisser multiplier for degrees of freedom, #> p-values and degrees of freedom in the table incorporate this correction. #> SS_num indicates sum of squares numerator. SS_den indicates sum of squares denominator. #> ges indicates generalized eta-squared. #> #>
# # ** Example 3: Between and Within Participant Predictors # library(apaTables) library(tidyr) library(forcats) library(ez) # See initial wide format where one row represents one PERSON print(dating_wide)
#> # A tibble: 20 x 11 #> participant gender attractive_high average_high ugly_high attractive_some #> <fct> <fct> <int> <int> <int> <int> #> 1 P01 Male 86 84 67 88 #> 2 P02 Male 91 83 53 83 #> 3 P03 Male 89 88 48 99 #> 4 P04 Male 89 69 58 86 #> 5 P05 Male 80 81 57 88 #> 6 P06 Male 80 84 51 96 #> 7 P07 Male 89 85 61 87 #> 8 P08 Male 100 94 56 86 #> 9 P09 Male 90 74 54 92 #> 10 P10 Male 89 86 63 80 #> 11 P11 Female 89 91 93 88 #> 12 P12 Female 84 90 85 95 #> 13 P13 Female 99 100 89 80 #> 14 P14 Female 86 89 83 86 #> 15 P15 Female 89 87 80 83 #> 16 P16 Female 80 81 79 86 #> 17 P17 Female 82 92 85 81 #> 18 P18 Female 97 69 87 95 #> 19 P19 Female 95 92 90 98 #> 20 P20 Female 95 93 96 79 #> # ... with 5 more variables: average_some <int>, ugly_some <int>, #> # attractive_none <int>, average_none <int>, ugly_none <int>
# Convert data from wide format to long format where one row represents one OBSERVATION. # Wide format column names MUST represent levels of each variable separated by an underscore. # See vignette for further details. dating_long <- gather(data = dating_wide, key = cell, value = date_rating, attractive_high:ugly_none, factor_key = TRUE) dating_long <- separate(data = dating_long, col = cell, into = c("looks","personality"), sep = "_", remove = TRUE) dating_long$looks <- as_factor(dating_long$looks) dating_long$personality <- as_factor(dating_long$personality) # See new long format of data, where one row is one OBSERVATION. # As well, notice that we have two columns (looks, personality) # looks, personality, and participant are factors print(dating_long)
#> # A tibble: 180 x 5 #> participant gender looks personality date_rating #> <fct> <fct> <fct> <fct> <int> #> 1 P01 Male attractive high 86 #> 2 P02 Male attractive high 91 #> 3 P03 Male attractive high 89 #> 4 P04 Male attractive high 89 #> 5 P05 Male attractive high 80 #> 6 P06 Male attractive high 80 #> 7 P07 Male attractive high 89 #> 8 P08 Male attractive high 100 #> 9 P09 Male attractive high 90 #> 10 P10 Male attractive high 89 #> # ... with 170 more rows
# Set contrasts to match Field et al. (2012) textbook output some_vs_none <- c(1, 1, -2) hi_vs_av <- c(1, -1, 0) attractive_vs_ugly <- c(1, 1, -2) attractive_vs_average <- c(1, -1, 0) contrasts(dating_long$personality) <- cbind(some_vs_none, hi_vs_av) contrasts(dating_long$looks) <- cbind(attractive_vs_ugly, attractive_vs_average) # Use ezANOVA library(ez) options(digits = 10) dating_results <-ezANOVA(data = dating_long, dv = .(date_rating), wid = .(participant), between = .(gender), within = .(looks, personality), type = 3, detailed = TRUE) # Make APA table dating_table <- apa.ezANOVA.table(dating_results, filename = "ex3_mixed_table.doc") print(dating_table)
#> #> #> ANOVA results #> #> #> Predictor df_num df_den Epsilon SS_num SS_den F #> (Intercept) 1.00 18.00 846249.80 760.22 20036.90 #> gender 1.00 18.00 0.20 760.22 0.00 #> looks 1.92 34.62 0.96 20779.63 882.71 423.73 #> personality 1.87 33.62 0.93 23233.60 1274.04 328.25 #> gender x looks 1.92 34.62 0.96 3944.10 882.71 80.43 #> gender x personality 1.87 33.62 0.93 4420.13 1274.04 62.45 #> looks x personality 3.20 57.55 0.80 4055.27 1992.62 36.63 #> gender x looks x personality 3.20 57.55 0.80 2669.67 1992.62 24.12 #> p ges #> .000 .99 #> .946 .00 #> .000 .81 #> .000 .83 #> .000 .45 #> .000 .47 #> .000 .45 #> .000 .35 #> #> Note. df_num indicates degrees of freedom numerator. df_den indicates degrees of freedom denominator. #> Epsilon indicates Greenhouse-Geisser multiplier for degrees of freedom, #> p-values and degrees of freedom in the table incorporate this correction. #> SS_num indicates sum of squares numerator. SS_den indicates sum of squares denominator. #> ges indicates generalized eta-squared. #> #>