Preparations in R

Install the packages if they are not already installed.

rm(list = ls())
options(scipen = 999)
if (!("pacman" %in% installed.packages())) install.packages("pacman")

Load the R packages.

pacman::p_load(tidyverse, bruceR)

Load and name the dataset.

dat <- bruceR::import("E1_TerminologyRecall.csv")

Check the data frame and for missings.

dim(dat)
## [1] 3200    7
colnames(dat)
## [1] "Participant"     "Item"            "Tracing_type"    "Cueing_type"    
## [5] "Score"           "Prior_knowledge" "Spatial_ability"
str(dat)
## 'data.frame':    3200 obs. of  7 variables:
##  $ Participant    : chr  "A1003" "A1003" "A1003" "A1003" ...
##  $ Item           : chr  "recall1" "recall2" "recall3" "recall4" ...
##  $ Tracing_type   : chr  "yes" "yes" "yes" "yes" ...
##  $ Cueing_type    : chr  "yes" "yes" "yes" "yes" ...
##  $ Score          : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ Prior_knowledge: int  16 16 16 16 16 16 16 16 16 16 ...
##  $ Spatial_ability: int  6 6 6 6 6 6 6 6 6 6 ...
summary(dat)
##  Participant            Item           Tracing_type       Cueing_type       
##  Length:3200        Length:3200        Length:3200        Length:3200       
##  Class :character   Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character   Mode  :character  
##                                                                             
##                                                                             
##                                                                             
##      Score        Prior_knowledge Spatial_ability 
##  Min.   :0.0000   Min.   : 4.00   Min.   : 0.000  
##  1st Qu.:0.0000   1st Qu.: 8.00   1st Qu.: 5.000  
##  Median :1.0000   Median :12.00   Median : 8.000  
##  Mean   :0.6228   Mean   :10.73   Mean   : 8.613  
##  3rd Qu.:1.0000   3rd Qu.:14.00   3rd Qu.:12.000  
##  Max.   :1.0000   Max.   :16.00   Max.   :20.000
head(dat)
##   Participant    Item Tracing_type Cueing_type Score Prior_knowledge
## 1       A1003 recall1          yes         yes     1              16
## 2       A1003 recall2          yes         yes     1              16
## 3       A1003 recall3          yes         yes     1              16
## 4       A1003 recall4          yes         yes     1              16
## 5       A1003 recall5          yes         yes     1              16
## 6       A1003 recall6          yes         yes     1              16
##   Spatial_ability
## 1               6
## 2               6
## 3               6
## 4               6
## 5               6
## 6               6

Dataset for ANCOVA

dat_ANCOVA <- dat %>%
  dplyr::filter(Cueing_type == "no") %>% 
  dplyr::group_by(Participant, Tracing_type) %>%
  dplyr::summarise(Sum_score = sum(Score, na.rm = TRUE),
                   Prior_knowledge = mean(Prior_knowledge, na.rm = TRUE),
                   Spatial_ability = mean(Spatial_ability, na.rm = TRUE)) %>% 
  dplyr::ungroup() %>% 
  dplyr::mutate(
    Spatial_ability = case_when(
      Spatial_ability < mean(Spatial_ability, na.rm = TRUE)  ~ "low",
      Spatial_ability >= mean(Spatial_ability, na.rm = TRUE) ~ "high"
    )
  )
## `summarise()` has grouped output by 'Participant'. You can override using the
## `.groups` argument.
dat_ANCOVA %>% 
  dplyr::group_by(Tracing_type, Spatial_ability) %>% 
  dplyr::summarise(n = n()) %>% 
  bruceR::print_table(digits = 0)
## `summarise()` has grouped output by 'Tracing_type'. You can override using the
## `.groups` argument.
## ──────────────────────────────────
##    Tracing_type Spatial_ability  n
## ──────────────────────────────────
## 1           no             high 18
## 2           no             low  22
## 3           yes            high 17
## 4           yes            low  23
## ──────────────────────────────────

ANCOVA

m <- bruceR::MANOVA(dat_ANCOVA, dv = "Sum_score", between = c("Tracing_type", "Spatial_ability"), covariate = "Prior_knowledge")
## Warning: Numerical variables NOT centered on 0 (matters if variable in interaction):
##    Prior_knowledge
## 
## ====== ANOVA (Between-Subjects Design) ======
## 
## Descriptives:
## ───────────────────────────────────────────────────
##  "Tracing_type" "Spatial_ability"   Mean    S.D.  n
## ───────────────────────────────────────────────────
##             no               high  9.444 (4.693) 18
##             no               low  10.182 (3.275) 22
##             yes              high 17.353 (3.061) 17
##             yes              low  13.957 (4.866) 23
## ───────────────────────────────────────────────────
## Total sample size: N = 80
## 
## ANOVA Table:
## Dependent variable(s):      Sum_score
## Between-subjects factor(s): Tracing_type, Spatial_ability
## Within-subjects factor(s):  –
## Covariate(s):               Prior_knowledge
## ────────────────────────────────────────────────────────────────────────────────────────────────
##                                      MS    MSE df1 df2      F     p     η²p [90% CI of η²p]  η²G
## ────────────────────────────────────────────────────────────────────────────────────────────────
## Tracing_type                    645.424 16.686   1  75 38.680 <.001 ***   .340 [.202, .463] .340
## Spatial_ability                  45.524 16.686   1  75  2.728  .103       .035 [.000, .127] .035
## Prior_knowledge                  19.097 16.686   1  75  1.144  .288       .015 [.000, .090] .015
## Tracing_type * Spatial_ability   87.908 16.686   1  75  5.268  .025 *     .066 [.005, .173] .066
## ────────────────────────────────────────────────────────────────────────────────────────────────
## MSE = mean square error (the residual variance of the linear model)
## η²p = partial eta-squared = SS / (SS + SSE) = F * df1 / (F * df1 + df2)
## ω²p = partial omega-squared = (F - 1) * df1 / (F * df1 + df2 + 1)
## η²G = generalized eta-squared (see Olejnik & Algina, 2003)
## Cohen’s f² = η²p / (1 - η²p)
## 
## Levene’s Test for Homogeneity of Variance:
## ───────────────────────────────────────────
##                Levene’s F df1 df2     p    
## ───────────────────────────────────────────
## DV: Sum_score       1.578   3  76  .202    
## ───────────────────────────────────────────
emmeans::emmip(m, Tracing_type ~ Spatial_ability, CIs = TRUE)

emmeans::emmip(m, Spatial_ability ~ Tracing_type, CIs = TRUE)

Simple-effect analyses

bruceR::EMMEANS(m, effect = "Tracing_type", by = "Spatial_ability")
## ------ EMMEANS (effect = "Tracing_type") ------
## 
## Joint Tests of "Tracing_type":
## ───────────────────────────────────────────────────────────────────────────────
##           Effect "Spatial_ability" df1 df2      F     p     η²p [90% CI of η²p]
## ───────────────────────────────────────────────────────────────────────────────
##  Tracing_type                 high   1  75 32.412 <.001 ***   .302 [.166, .428]
##  Tracing_type                 low    1  75  8.803  .004 **    .105 [.021, .224]
##  Prior_knowledge              high   1  75  1.144  .288       .015 [.000, .090]
##  Prior_knowledge              low    1  75  1.144  .288       .015 [.000, .090]
## ───────────────────────────────────────────────────────────────────────────────
## Note. Simple effects of repeated measures with 3 or more levels
## are different from the results obtained with SPSS MANOVA syntax.
## 
## Estimated Marginal Means of "Tracing_type":
## ─────────────────────────────────────────────────────────────────
##  "Tracing_type" "Spatial_ability"   Mean [95% CI of Mean]    S.E.
## ─────────────────────────────────────────────────────────────────
##             no               high  9.597 [ 7.658, 11.536] (0.973)
##             yes              high 17.465 [15.480, 19.449] (0.996)
##             no               low  10.150 [ 8.414, 11.886] (0.871)
##             yes              low  13.785 [12.058, 15.512] (0.867)
## ─────────────────────────────────────────────────────────────────
## 
## Pairwise Comparisons of "Tracing_type":
## ───────────────────────────────────────────────────────────────────────────────────────
##  Contrast "Spatial_ability" Estimate    S.E. df     t     p     Cohen’s d [95% CI of d]
## ───────────────────────────────────────────────────────────────────────────────────────
##  yes - no              high    7.868 (1.382) 75 5.693 <.001 ***    1.926 [1.252, 2.600]
##  yes - no              low     3.635 (1.225) 75 2.967  .004 **     0.890 [0.292, 1.487]
## ───────────────────────────────────────────────────────────────────────────────────────
## Pooled SD for computing Cohen’s d: 4.085
## No need to adjust p values.
## 
## Disclaimer:
## By default, pooled SD is Root Mean Square Error (RMSE).
## There is much disagreement on how to compute Cohen’s d.
## You are completely responsible for setting `sd.pooled`.
## You might also use `effectsize::t_to_d()` to compute d.
bruceR::EMMEANS(m, effect = "Spatial_ability", by = "Tracing_type")
## ------ EMMEANS (effect = "Spatial_ability") ------
## 
## Joint Tests of "Spatial_ability":
## ───────────────────────────────────────────────────────────────────────────
##           Effect "Tracing_type" df1 df2     F     p     η²p [90% CI of η²p]
## ───────────────────────────────────────────────────────────────────────────
##  Spatial_ability            no    1  75 0.178  .674       .002 [.000, .050]
##  Spatial_ability            yes   1  75 7.620  .007 **    .092 [.015, .208]
##  Prior_knowledge            no    1  75 1.144  .288       .015 [.000, .090]
##  Prior_knowledge            yes   1  75 1.144  .288       .015 [.000, .090]
## ───────────────────────────────────────────────────────────────────────────
## Note. Simple effects of repeated measures with 3 or more levels
## are different from the results obtained with SPSS MANOVA syntax.
## 
## Estimated Marginal Means of "Spatial_ability":
## ─────────────────────────────────────────────────────────────────
##  "Spatial_ability" "Tracing_type"   Mean [95% CI of Mean]    S.E.
## ─────────────────────────────────────────────────────────────────
##               high            no   9.597 [ 7.658, 11.536] (0.973)
##               low             no  10.150 [ 8.414, 11.886] (0.871)
##               high            yes 17.465 [15.480, 19.449] (0.996)
##               low             yes 13.785 [12.058, 15.512] (0.867)
## ─────────────────────────────────────────────────────────────────
## 
## Pairwise Comparisons of "Spatial_ability":
## ───────────────────────────────────────────────────────────────────────────────────────
##    Contrast "Tracing_type" Estimate    S.E. df      t     p     Cohen’s d [95% CI of d]
## ───────────────────────────────────────────────────────────────────────────────────────
##  low - high            no     0.553 (1.310) 75  0.422  .674      0.135 [-0.503,  0.774]
##  low - high            yes   -3.680 (1.333) 75 -2.760  .007 **  -0.901 [-1.551, -0.251]
## ───────────────────────────────────────────────────────────────────────────────────────
## Pooled SD for computing Cohen’s d: 4.085
## No need to adjust p values.
## 
## Disclaimer:
## By default, pooled SD is Root Mean Square Error (RMSE).
## There is much disagreement on how to compute Cohen’s d.
## You are completely responsible for setting `sd.pooled`.
## You might also use `effectsize::t_to_d()` to compute d.