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_GlobalComprehension.csv")
Check the data frame and for missings.
dim(dat)
## [1] 4480 7
colnames(dat)
## [1] "Participant" "Item" "Tracing_type" "Cueing_type"
## [5] "Score" "Prior_knowledge" "Spatial_ability"
str(dat)
## 'data.frame': 4480 obs. of 7 variables:
## $ Participant : chr "A1003" "A1003" "A1003" "A1003" ...
## $ Item : chr "global1" "global2" "global3" "global4" ...
## $ Tracing_type : chr "yes" "yes" "yes" "yes" ...
## $ Cueing_type : chr "yes" "yes" "yes" "yes" ...
## $ Score : int 1 1 0 1 0 1 0 1 1 0 ...
## $ 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:4480 Length:4480 Length:4480 Length:4480
## 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 :0.0000 Median :12.00 Median : 8.000
## Mean :0.4116 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 global1 yes yes 1 16
## 2 A1003 global2 yes yes 1 16
## 3 A1003 global3 yes yes 0 16
## 4 A1003 global4 yes yes 1 16
## 5 A1003 global5 yes yes 0 16
## 6 A1003 global6 yes yes 1 16
## Spatial_ability
## 1 6
## 2 6
## 3 6
## 4 6
## 5 6
## 6 6
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
## ──────────────────────────────────
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.000 (4.887) 18
## no low 9.182 (4.532) 22
## yes high 17.176 (5.548) 17
## yes low 12.565 (5.790) 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 652.159 27.565 1 75 23.659 <.001 *** .240 [.112, .369] .240
## Spatial_ability 91.029 27.565 1 75 3.302 .073 . .042 [.000, .139] .042
## Prior_knowledge 0.005 27.565 1 75 0.000 .989 .000 [.000, .000] .000
## Tracing_type * Spatial_ability 112.633 27.565 1 75 4.086 .047 * .052 [.000, .153] .052
## ────────────────────────────────────────────────────────────────────────────────────────────────
## 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.658 3 76 .581
## ───────────────────────────────────────────
emmeans::emmip(m, Tracing_type ~ Spatial_ability, CIs = TRUE)
emmeans::emmip(m, Spatial_ability ~ Tracing_type, CIs = TRUE)
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 21.192 <.001 *** .220 [.097, .349]
## Tracing_type low 1 75 4.623 .035 * .058 [.002, .162]
## Prior_knowledge high 1 75 0.000 .989 .000 [.000, .000]
## Prior_knowledge low 1 75 0.000 .989 .000 [.000, .000]
## ───────────────────────────────────────────────────────────────────────────────
## 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 8.997 [ 6.505, 11.490] (1.251)
## yes high 17.175 [14.624, 19.725] (1.280)
## no low 9.182 [ 6.951, 11.414] (1.120)
## yes low 12.568 [10.349, 14.787] (1.114)
## ─────────────────────────────────────────────────────────────────
##
## Pairwise Comparisons of "Tracing_type":
## ───────────────────────────────────────────────────────────────────────────────────────
## Contrast "Spatial_ability" Estimate S.E. df t p Cohen’s d [95% CI of d]
## ───────────────────────────────────────────────────────────────────────────────────────
## yes - no high 8.177 (1.776) 75 4.603 <.001 *** 1.557 [0.883, 2.231]
## yes - no low 3.386 (1.575) 75 2.150 .035 * 0.645 [0.047, 1.242]
## ───────────────────────────────────────────────────────────────────────────────────────
## Pooled SD for computing Cohen’s d: 5.250
## 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.012 .913 .000 [.000, .015]
## Spatial_ability yes 1 75 7.228 .009 ** .088 [.013, .202]
## Prior_knowledge no 1 75 0.000 .989 .000 [.000, .000]
## Prior_knowledge yes 1 75 0.000 .989 .000 [.000, .000]
## ───────────────────────────────────────────────────────────────────────────
## 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 8.997 [ 6.505, 11.490] (1.251)
## low no 9.182 [ 6.951, 11.414] (1.120)
## high yes 17.175 [14.624, 19.725] (1.280)
## low yes 12.568 [10.349, 14.787] (1.114)
## ─────────────────────────────────────────────────────────────────
##
## 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.185 (1.683) 75 0.110 .913 0.035 [-0.603, 0.674]
## low - high yes -4.607 (1.713) 75 -2.688 .009 ** -0.877 [-1.528, -0.227]
## ───────────────────────────────────────────────────────────────────────────────────────
## Pooled SD for computing Cohen’s d: 5.250
## 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.