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_TerminologyRecognition.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  "recognition1" "recognition2" "recognition3" "recognition4" ...
##  $ Tracing_type   : chr  "yes" "yes" "yes" "yes" ...
##  $ Cueing_type    : chr  "yes" "yes" "yes" "yes" ...
##  $ Score          : int  0 1 1 1 1 1 1 1 0 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.000   Min.   : 4.00   Min.   : 0.000  
##  1st Qu.:0.000   1st Qu.: 8.00   1st Qu.: 5.000  
##  Median :1.000   Median :12.00   Median : 8.000  
##  Mean   :0.635   Mean   :10.73   Mean   : 8.613  
##  3rd Qu.:1.000   3rd Qu.:14.00   3rd Qu.:12.000  
##  Max.   :1.000   Max.   :16.00   Max.   :20.000
head(dat)
##   Participant         Item Tracing_type Cueing_type Score Prior_knowledge
## 1       A1003 recognition1          yes         yes     0              16
## 2       A1003 recognition2          yes         yes     1              16
## 3       A1003 recognition3          yes         yes     1              16
## 4       A1003 recognition4          yes         yes     1              16
## 5       A1003 recognition5          yes         yes     1              16
## 6       A1003 recognition6          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 12.500 (3.899) 18
##             no               low  12.409 (3.112) 22
##             yes              high 15.353 (2.957) 17
##             yes              low  12.826 (3.284) 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                    50.350 11.161   1  75 4.511  .037 *     .057 [.002, .160] .057
## Spatial_ability                 35.623 11.161   1  75 3.192  .078 .     .041 [.000, .136] .041
## Prior_knowledge                  1.918 11.161   1  75 0.172  .680       .002 [.000, .050] .002
## Tracing_type * Spatial_ability  29.868 11.161   1  75 2.676  .106       .034 [.000, .126] .034
## ──────────────────────────────────────────────────────────────────────────────────────────────
## 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       0.382   3  76  .766    
## ───────────────────────────────────────────
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 6.314  .014 *     .078 [.009, .189]
##  Tracing_type                 low    1  75 0.138  .711       .002 [.000, .047]
##  Prior_knowledge              high   1  75 0.172  .680       .002 [.000, .050]
##  Prior_knowledge              low    1  75 0.172  .680       .002 [.000, .050]
## ──────────────────────────────────────────────────────────────────────────────
## 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 12.548 [10.963, 14.134] (0.796)
##             yes              high 15.388 [13.765, 17.012] (0.815)
##             no               low  12.399 [10.979, 13.819] (0.713)
##             yes              low  12.772 [11.360, 14.184] (0.709)
## ─────────────────────────────────────────────────────────────────
## 
## Pairwise Comparisons of "Tracing_type":
## ───────────────────────────────────────────────────────────────────────────────────────
##  Contrast "Spatial_ability" Estimate    S.E. df     t     p     Cohen’s d [95% CI of d]
## ───────────────────────────────────────────────────────────────────────────────────────
##  yes - no              high    2.840 (1.130) 75 2.513  .014 *     0.850 [ 0.176, 1.524]
##  yes - no              low     0.373 (1.002) 75 0.372  .711       0.112 [-0.486, 0.709]
## ───────────────────────────────────────────────────────────────────────────────────────
## Pooled SD for computing Cohen’s d: 3.341
## 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.019  .890       .000 [.000, .021]
##  Spatial_ability            yes   1  75 5.760  .019 *     .071 [.007, .181]
##  Prior_knowledge            no    1  75 0.172  .680       .002 [.000, .050]
##  Prior_knowledge            yes   1  75 0.172  .680       .002 [.000, .050]
## ───────────────────────────────────────────────────────────────────────────
## 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  12.548 [10.963, 14.134] (0.796)
##               low             no  12.399 [10.979, 13.819] (0.713)
##               high            yes 15.388 [13.765, 17.012] (0.815)
##               low             yes 12.772 [11.360, 14.184] (0.709)
## ─────────────────────────────────────────────────────────────────
## 
## 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.149 (1.071) 75 -0.139  .890     -0.045 [-0.683,  0.594]
##  low - high            yes   -2.617 (1.090) 75 -2.400  .019 *   -0.783 [-1.433, -0.133]
## ───────────────────────────────────────────────────────────────────────────────────────
## Pooled SD for computing Cohen’s d: 3.341
## 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.