Semantic Learning Task

Data Manipulations

# Load data (1 data frame)
slid_data <- read.csv(here("Semantic Learning & ID Data","Semantic Learning & ID Data","Semantic learning and recognition data.csv"),stringsAsFactors=TRUE) # sentence length data

slid_data %<>%
  mutate(Participant.ID = factor(Participant.ID), 
         Group = factor(Child.or.adult), 
         SL.Meaning.Condition = factor(SL.Meaning.Condition), 
         SL.Correct.Response = factor(SL.Correct.Response),
         SL.Triplet.Number = as.numeric(SL.Triplet.Number),
         SL.Trial.Order.by.Task = as.numeric(SL.Trial.Order.by.Task),
         SL.Response = factor(SL.Response),
         SL.Response.Type = factor(SL.Response.Type),
         SL.Correct.Based.on.Only.SL. = as.numeric(SL.Correct.Based.on.Only.SL.),
         SL.Correct.Enough.for.IT. = as.numeric(SL.Correct.Enough.for.IT.),
         IT.Trial.Number = as.numeric(IT.Trial.Number),
         IT.Trial.Order.by.Task = as.numeric(IT.Trial.Order.by.Task),
         IT.Correct.Response = as.numeric(IT.Correct.Response),
         IT.Response = as.numeric(IT.Response),
         IT.Correct. = as.numeric(IT.Correct.),
         Exclude. = as.numeric(Exclude.),
         SL.Nonword = factor(SL.Nonword),
         SL.meaning.cond.c = as.numeric(SL.Meaning.Condition) - 1.5)
str(slid_data)
## 'data.frame':    4680 obs. of  36 variables:
##  $ Participant.ID                   : Factor w/ 156 levels "049b2dc2","070821_1f_10",..: 113 143 47 93 51 131 128 155 152 145 ...
##  $ Child.or.adult                   : Factor w/ 2 levels "A","C": 1 1 1 1 1 1 1 1 1 1 ...
##  $ SL.block.or.condition            : Factor w/ 31 levels "apple_block",..: 25 25 25 25 25 25 25 25 25 25 ...
##  $ Task                             : Factor w/ 1 level "SL": 1 1 1 1 1 1 1 1 1 1 ...
##  $ SL.Triplet.Number                : num  30 30 30 30 16 16 16 18 18 18 ...
##  $ SL.Trial.Order.by.Task           : num  4 22 24 27 3 11 19 4 8 13 ...
##  $ SL.Meaning.Condition             : Factor w/ 2 levels "M-","M+": 2 2 2 2 2 2 2 2 2 2 ...
##  $ SL.Nonword                       : Factor w/ 31 levels "bov","chaws",..: 21 21 21 21 18 18 18 15 15 15 ...
##  $ SL.Correct.Response              : Factor w/ 17 levels "apple","bed",..: 1 1 1 1 4 4 4 3 3 3 ...
##  $ SL.Response                      : Factor w/ 263 levels ""," ","  nice",..: 7 163 7 7 175 97 208 20 106 20 ...
##  $ SL.Response.Category             : Factor w/ 3 levels "correct word",..: 1 3 1 1 2 2 3 1 2 1 ...
##  $ SL.Correct.Based.on.Only.SL.     : num  1 1 1 1 0 0 0 1 0 1 ...
##  $ SL.Correct.Enough.for.IT.        : num  1 0 1 1 0 0 0 1 0 1 ...
##  $ SL.Response.Type                 : Factor w/ 6 levels "correct response (no meaning)",..: 2 6 2 2 4 4 6 2 4 2 ...
##  $ IT.Block                         : Factor w/ 31 levels "ID_apple","ID_bed",..: 31 31 31 31 31 31 31 31 31 31 ...
##  $ IT.Trial.Type                    : Factor w/ 30 levels "recog1","recog10",..: 1 1 1 1 12 12 12 23 23 23 ...
##  $ Task.1                           : Factor w/ 1 level "IT": 1 1 1 1 1 1 1 1 1 1 ...
##  $ IT.Trial.Number                  : num  1 1 1 1 2 2 2 3 3 3 ...
##  $ IT.Trial.Order.by.Task           : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ IT.Meaning.Condition             : Factor w/ 2 levels "M-","M+": 2 2 2 2 2 2 2 2 2 2 ...
##  $ IT.Nonword                       : Factor w/ 30 levels "bov","chaws",..: 20 20 20 20 17 17 17 15 15 15 ...
##  $ IT.Correct.Response              : num  1 1 1 1 3 3 3 2 2 2 ...
##  $ IT.Response                      : num  3 3 1 5 1 5 4 1 5 3 ...
##  $ IT.Correct.                      : num  0 0 1 0 0 0 0 0 0 0 ...
##  $ IT.Response.Type                 : Factor w/ 11 levels "#N/A","correct response (M+ target word)",..: 4 4 2 9 4 9 10 11 9 10 ...
##  $ Semantic.vs.Other                : Factor w/ 3 levels "#N/A","other foil",..: 2 2 NA NA 2 NA 3 2 NA 3 ...
##  $ Familiar.vs.Unrelated            : Factor w/ 3 levels "#N/A","familiar foil",..: 2 2 NA NA 2 NA NA 3 NA NA ...
##  $ Language.Status                  : Factor w/ 8 levels "","bilingual (English, Chinese)",..: 7 7 7 7 7 6 2 7 7 5 ...
##  $ Exclude.                         : num  0 0 0 1 1 0 0 0 0 0 ...
##  $ Exclusion.Reason                 : Factor w/ 18 levels "","Completed portion of SL task before restarting and completing whole study",..: 1 1 1 12 4 1 1 1 1 1 ...
##  $ Age                              : num  26 24 26 29 25 27 25 25 28 24 ...
##  $ Gender                           : Factor w/ 6 levels "","3","5","female",..: 4 5 4 5 5 4 4 5 5 5 ...
##  $ Highest.Completed.Education.Level: Factor w/ 8 levels "","associate's degree",..: 7 2 2 2 4 3 3 5 5 7 ...
##  $ Highest.Degree.Earned            : Factor w/ 24 levels "","B.A","B.A.",..: 1 1 1 1 20 2 3 15 15 1 ...
##  $ Group                            : Factor w/ 2 levels "A","C": 1 1 1 1 1 1 1 1 1 1 ...
##  $ SL.meaning.cond.c                : num  0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 ...
# Create some data subsets
incl_slid_data <- subset(slid_data, Exclude. != 1 & !grepl("bilingual", Language.Status, ignore.case = TRUE)) # only included, monolingual participants
incl_slid_data %<>%
  mutate(Age = as.numeric(Age),
         age.c = as.numeric(scale(Age, center = TRUE, scale = FALSE)),
         Gender = factor(Gender),
         gender.c = as.numeric(Gender) - 1.5)
str(incl_slid_data)
## 'data.frame':    3150 obs. of  38 variables:
##  $ Participant.ID                   : Factor w/ 156 levels "049b2dc2","070821_1f_10",..: 113 143 47 155 152 153 140 81 114 57 ...
##  $ Child.or.adult                   : Factor w/ 2 levels "A","C": 1 1 1 1 1 1 1 1 1 1 ...
##  $ SL.block.or.condition            : Factor w/ 31 levels "apple_block",..: 25 25 25 25 25 25 25 25 25 25 ...
##  $ Task                             : Factor w/ 1 level "SL": 1 1 1 1 1 1 1 1 1 1 ...
##  $ SL.Triplet.Number                : num  30 30 30 18 18 17 19 19 19 20 ...
##  $ SL.Trial.Order.by.Task           : num  4 22 24 4 8 11 3 13 24 21 ...
##  $ SL.Meaning.Condition             : Factor w/ 2 levels "M-","M+": 2 2 2 2 2 2 2 2 2 2 ...
##  $ SL.Nonword                       : Factor w/ 31 levels "bov","chaws",..: 21 21 21 15 15 6 16 16 16 14 ...
##  $ SL.Correct.Response              : Factor w/ 17 levels "apple","bed",..: 1 1 1 3 3 14 17 17 17 15 ...
##  $ SL.Response                      : Factor w/ 263 levels ""," ","  nice",..: 7 163 7 20 106 221 225 251 225 243 ...
##  $ SL.Response.Category             : Factor w/ 3 levels "correct word",..: 1 3 1 1 2 1 1 1 1 1 ...
##  $ SL.Correct.Based.on.Only.SL.     : num  1 1 1 1 0 1 1 1 1 1 ...
##  $ SL.Correct.Enough.for.IT.        : num  1 0 1 1 0 1 1 1 1 1 ...
##  $ SL.Response.Type                 : Factor w/ 6 levels "correct response (no meaning)",..: 2 6 2 2 4 2 2 2 2 2 ...
##  $ IT.Block                         : Factor w/ 31 levels "ID_apple","ID_bed",..: 31 31 31 31 31 31 31 31 31 31 ...
##  $ IT.Trial.Type                    : Factor w/ 30 levels "recog1","recog10",..: 1 1 1 23 23 25 26 26 26 27 ...
##  $ Task.1                           : Factor w/ 1 level "IT": 1 1 1 1 1 1 1 1 1 1 ...
##  $ IT.Trial.Number                  : num  1 1 1 3 3 4 5 5 5 6 ...
##  $ IT.Trial.Order.by.Task           : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ IT.Meaning.Condition             : Factor w/ 2 levels "M-","M+": 2 2 2 2 2 2 2 2 2 2 ...
##  $ IT.Nonword                       : Factor w/ 30 levels "bov","chaws",..: 20 20 20 15 15 6 16 16 16 14 ...
##  $ IT.Correct.Response              : num  1 1 1 2 2 4 1 1 1 2 ...
##  $ IT.Response                      : num  3 3 1 1 5 4 1 1 1 2 ...
##  $ IT.Correct.                      : num  0 0 1 0 0 1 1 1 1 1 ...
##  $ IT.Response.Type                 : Factor w/ 11 levels "#N/A","correct response (M+ target word)",..: 4 4 2 11 9 2 2 2 2 2 ...
##  $ Semantic.vs.Other                : Factor w/ 3 levels "#N/A","other foil",..: 2 2 NA 2 NA NA NA NA NA NA ...
##  $ Familiar.vs.Unrelated            : Factor w/ 3 levels "#N/A","familiar foil",..: 2 2 NA 3 NA NA NA NA NA NA ...
##  $ Language.Status                  : Factor w/ 8 levels "","bilingual (English, Chinese)",..: 7 7 7 7 7 7 7 7 7 7 ...
##  $ Exclude.                         : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ Exclusion.Reason                 : Factor w/ 18 levels "","Completed portion of SL task before restarting and completing whole study",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Age                              : num  26 24 26 25 28 23 25 24 25 27 ...
##  $ Gender                           : Factor w/ 2 levels "female","male": 1 2 1 2 2 2 1 2 1 1 ...
##  $ Highest.Completed.Education.Level: Factor w/ 8 levels "","associate's degree",..: 7 2 2 5 5 7 3 3 3 3 ...
##  $ Highest.Degree.Earned            : Factor w/ 24 levels "","B.A","B.A.",..: 1 1 1 15 15 1 3 9 7 13 ...
##  $ Group                            : Factor w/ 2 levels "A","C": 1 1 1 1 1 1 1 1 1 1 ...
##  $ SL.meaning.cond.c                : num  0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 ...
##  $ age.c                            : num  6.71 4.71 6.71 5.71 8.71 ...
##  $ gender.c                         : num  -0.5 0.5 -0.5 0.5 0.5 0.5 -0.5 0.5 -0.5 -0.5 ...
mp_slid_data <- subset(incl_slid_data, SL.Meaning.Condition == "M+") # only M+ trials


# Calculate the proportions of responses in the Semantic Learning task for each participant
# Step 1: Define valid response types per condition
valid_responses <- tribble(
  ~SL.Meaning.Condition, ~SL.Response.Type,
  "M+", "correct response (target word)",
  "M+", "incorrect response (no meaning)",
  "M+", "incorrect response (no response)",
  "M+", "incorrect response (wrong word)",
  "M-", "correct response (no meaning)",
  "M-", "incorrect response (any meaning)",
  "M-", "incorrect response (no response)"
)

# Step 2: Summarise participant-level counts
participant_counts <- incl_slid_data %>%
  group_by(Participant.ID, Group, SL.Meaning.Condition, SL.Response.Type) %>%
  summarise(n = n(), .groups = "drop")

# Step 3: Get unique Participant × Condition combos from actual data
participant_conditions <- incl_slid_data %>%
  distinct(Participant.ID, Group, SL.Meaning.Condition)

# Step 4: Create complete grid of valid combinations per participant
full_grid <- participant_conditions %>%
  inner_join(valid_responses, by = "SL.Meaning.Condition")
## Warning in inner_join(., valid_responses, by = "SL.Meaning.Condition"): Detected an unexpected many-to-many relationship between `x` and `y`.
## ℹ Row 1 of `x` matches multiple rows in `y`.
## ℹ Row 1 of `y` matches multiple rows in `x`.
## ℹ If a many-to-many relationship is expected, set `relationship =
##   "many-to-many"` to silence this warning.
# Step 5: Left join actual counts onto full grid (so missing = 0)
propsl_data <- full_grid %>%
  left_join(participant_counts,
            by = c("Participant.ID", "Group", "SL.Meaning.Condition", "SL.Response.Type")) %>%
  mutate(n = replace_na(n, 0)) %>%
  group_by(Participant.ID, Group, SL.Meaning.Condition) %>%
  mutate(
    total_responses = sum(n),
    proportion = n / total_responses
  ) %>%
  ungroup()

# Notes:
# SL Meaning Condition = context condition (M- = unsupportive, M+ = supportive); default reference level = unsupportive/M-
# For SL Meaning Condition, M+ = -0.5 (after centering), M- = 0.5 (after centering)
# For Gender, female = -0.5 (after centering), male = 0.5 (after center)

Sanity checks

# Is each participant in only one group?
# Expected: TRUE (between-subjects design)
slid_data %>% group_by(Participant.ID) %>%
  summarise(Group = n_distinct(Group)) %>%
  as.data.frame() %>% 
  {.$Group == 1} %>%
  all()
## [1] TRUE
# Number of included participants per experimental condition
# Expected: Children = 45, Adults = 69
incl_slid_data %>% group_by(Participant.ID) %>%
  summarise(Group = first(Group)) %>%
  ungroup() %>%
  group_by(Group) %>%
  summarise(n = n())
## # A tibble: 2 × 2
##   Group     n
##   <fct> <int>
## 1 A        60
## 2 C        45
# Number of different target words (collapsed across participants) by group
# Expected: 15
mp_slid_data %>%  
  group_by(Group) %>%
  summarise(items = n_distinct(SL.Correct.Response))
## # A tibble: 2 × 2
##   Group items
##   <fct> <int>
## 1 A        15
## 2 C        15
  #summarise(items = n_distinct(Distinct.Target))

# Number of different psuedowords (collapsed across participants) by group
# Expected: 15
mp_slid_data %>%  
  group_by(Group) %>%  
  summarise(items = n_distinct(SL.Nonword))
## # A tibble: 2 × 2
##   Group items
##   <fct> <int>
## 1 A        15
## 2 C        15

Participants

Inclusions/exclusions

slid_data %>%
  distinct(Participant.ID, Group, Language.Status, Exclude., Exclusion.Reason)%>%
  group_by(Exclude.,Group, Language.Status, Exclusion.Reason)%>%
  summarise(n = n())%>%
  mutate(total.Exclusion.Reason.n = sum(n))%>%
  knitr::kable()
## `summarise()` has grouped output by 'Exclude.', 'Group', 'Language.Status'. You
## can override using the `.groups` argument.
Exclude. Group Language.Status Exclusion.Reason n total.Exclusion.Reason.n
0 A bilingual (English, Chinese) 2 2
0 A bilingual (English, Korean) 1 1
0 A bilingual (English, Spanish) 5 5
0 A bilingual (English, Vietnamese) 1 1
0 A monolingual 60 60
0 C 45 45
1 A bilingual (English, French) This participant provided the same 2 answers for almost all of the R/IT trials 1 1
1 A monolingual Participant didn’t seem to understand WLT (provided nonwords as responses) 1 29
1 A monolingual Repeated attempts by Mturk workers that should be excluded 9 29
1 A monolingual This participant did not complete the study 1 29
1 A monolingual This participant did not respond to almost any of the R/IT trials (let almost all of them time out) 1 29
1 A monolingual This participant did not respond to any of the R/IT trials (let them all time out) 1 29
1 A monolingual This participant selected “no meaning” for most of the R/IT trials 3 29
1 A monolingual This participant spent ten or less minutes 10 29
1 A monolingual This participant spent ten or less minutes and provided the same 2 answers for almost all of the answers in the WLT and most of the R/IT 1 29
1 A monolingual This participant spent ten or less minutes, didn’t seem to understand WLT (provided repeated, nonsensical responses), and selected “no meaning” for all of the R/IT trials 1 29
1 A monolingual This participant spent ten or less minutes, provided the same 2 answers for almost all of the answers in the WLT, and provided repeated answers for much of R/IT 1 29
1 A N/A Repeated attempts by Mturk workers that should be excluded 1 11
1 A N/A This participant did not fill out the demographics 4 11
1 A N/A This participant did not fill out the demographics and selected “no meaning” for all of the R/IT trials 1 11
1 A N/A This participant spent ten or less minutes 2 11
1 A N/A This participant spent ten or less minutes and did not fill out the demographics 1 11
1 A N/A This participant spent ten or less minutes, provided repeated answers for much of WLT, and selected “no meaning” for all of the R/IT trials 1 11
1 A N/A This was a practice run 1 11
1 C Completed portion of SL task before restarting and completing whole study 1 1

Age and gender demographics

# Age
incl_slid_data %>%
  distinct(Participant.ID, Group, Age)%>%
  group_by(Group)%>%
  summarise_at('Age', 
               list(~mean(., na.rm=T), 
                    ~sd(., na.rm=T),
                    ~median(., na.rm=T),
                    ~min(., na.rm=T),
                    ~max(., na.rm=T),
                    ~sum(!is.na(.))))%>%
  dplyr::rename("n" = "sum")%>%
  dplyr::select(Group, n, mean, sd, median, min, max)%>%
  mutate(total.n = sum(n))%>%
  knitr::kable()
Group n mean sd median min max total.n
A 60 25.38333 1.7083213 25 22 29 105
C 45 11.15556 0.7964568 11 10 12 105
# Gender
incl_slid_data %>%
  distinct(Participant.ID, Group, Gender)%>%
  group_by(Group, Gender)%>%
  summarise(n = n())%>%
  mutate(total.Gender.n = sum(n))%>%
  knitr::kable()
## `summarise()` has grouped output by 'Group'. You can override using the
## `.groups` argument.
Group Gender n total.Gender.n
A female 33 60
A male 27 60
C female 26 45
C male 19 45

Descriptives

# Semantic Learning task performance
incl_slid_data_partsum <- incl_slid_data %>%
  group_by(Participant.ID, Group,SL.Meaning.Condition) %>%
  summarise(SL_corr_partacc = mean(SL.Correct.Enough.for.IT., na.rm = TRUE), .groups = "drop")

sl_summary_df <- incl_slid_data_partsum %>%
  group_by(Group,SL.Meaning.Condition) %>%
  summarise(
    mean_accuracy = mean(SL_corr_partacc),
    sd_accuracy = sd(SL_corr_partacc),
    n = n(),
    .groups = "drop"
  ) %>%
  mutate(
    label_y = mean_accuracy + sd_accuracy + 0.02,  # Add small buffer
    total_n = sum(n)
  )
  knitr::kable(sl_summary_df)
Group SL.Meaning.Condition mean_accuracy sd_accuracy n label_y total_n
A M- 0.9611111 0.0697498 60 1.0508609 210
A M+ 0.7755556 0.1472749 60 0.9428304 210
C M- 0.9570370 0.0767464 45 1.0537834 210
C M+ 0.6459259 0.1757076 45 0.8416336 210
# Proportions of Semantic Learning task
propsl_data_partsum <- propsl_data %>%
  group_by(Participant.ID, Group,SL.Meaning.Condition, SL.Response.Type) %>%
  summarise(proportion_partacc = mean(proportion, na.rm = TRUE), .groups = "drop")

propsl_summary_df <- propsl_data_partsum %>%
  group_by(Group, SL.Meaning.Condition, SL.Response.Type) %>%
  summarise(
    mean_proportion = mean(proportion_partacc),
    sd_proportion = sd(proportion_partacc),
    n = n(),
    .groups = "drop"
  ) %>%
  mutate(
    label_y = mean_proportion + sd_proportion + 0.02,  # Add small buffer
    total_n = sum(n)
  )
  knitr::kable(propsl_summary_df)
Group SL.Meaning.Condition SL.Response.Type mean_proportion sd_proportion n label_y total_n
A M+ correct response (target word) 0.7755556 0.1472749 60 0.9428304 735
A M+ incorrect response (no meaning) 0.1388889 0.1395671 60 0.2984560 735
A M+ incorrect response (no response) 0.0000000 0.0000000 60 0.0200000 735
A M+ incorrect response (wrong word) 0.0855556 0.0650559 60 0.1706114 735
A M- correct response (no meaning) 0.9622222 0.0653735 60 1.0475957 735
A M- incorrect response (any meaning) 0.0377778 0.0653735 60 0.1231513 735
A M- incorrect response (no response) 0.0000000 0.0000000 60 0.0200000 735
C M+ correct response (target word) 0.7555556 0.1669694 45 0.9425250 735
C M+ incorrect response (no meaning) 0.1422222 0.1106455 45 0.2728677 735
C M+ incorrect response (no response) 0.0014815 0.0099381 45 0.0314196 735
C M+ incorrect response (wrong word) 0.1007407 0.1021212 45 0.2228619 735
C M- correct response (no meaning) 0.9570370 0.0767464 45 1.0537834 735
C M- incorrect response (any meaning) 0.0414815 0.0769217 45 0.1384032 735
C M- incorrect response (no response) 0.0014815 0.0099381 45 0.0314196 735

Visualizations

# Semantic Learning task performance
incl_slid_data_partsum %>%
  mutate(#SL.Meaning.Condition = factor(SL.Meaning.Condition, levels = c("M-", "M+"), 
                       #labels = c("Unsupportive Context", "Supportive Context"))),
     SL.Meaning.Condition = factor(SL.Meaning.Condition, levels = c("M+","M-"))  # Set the desired order of variables
)%>%
  ggplot(aes(x = SL.Meaning.Condition, y = SL_corr_partacc, fill = SL.Meaning.Condition, color = SL.Meaning.Condition)) + 
  stat_summary(fun = mean, position = position_dodge(width = .9),
               geom="bar", colour = "black") + 
  geom_hline(yintercept = .5, color = "grey", linetype = "dashed") + 
  facet_grid(~Group) + 
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1),
             geom = "errorbar", 
             position = position_dodge(width = 0.9), 
             size = 1, width = 0.25, color = "black") +  # Standard deviation bars
  geom_text(
  data = sl_summary_df,
  aes(
    x = SL.Meaning.Condition,
    y = label_y,
    label = sprintf("%.2f", mean_accuracy),
    group = Group
  ),
  position = position_dodge(width = 0.9),
  size = 4,
  color = "black") +  # Add formatted text on top of bars
  # scale_fill_brewer(palette = "Dark2") +
  #langcog::scale_fill_solarized()+
  labs(y = "Mean Accuracy of Target Meaning/Word Identification", 
       x = "Group", 
       fill = "Meaning Condition")  +
  theme(axis.text.x = element_text(hjust = 0.5, angle = 0, size = 12, color = "black"),  # Customize x-axis text
        axis.text.y = element_text(size = 12, color = "black"), 
        axis.title.x = element_text(size = 14, color = "black", face = "bold", margin = margin(t = 10)),  # x-axis title
        axis.title.y = element_text(size = 14, color = "black", face = "bold", margin = margin(r = 10)),  # y-axis title
        strip.text = element_text(size = 12, color = "black", face = "bold"),  # Facet labels
        legend.key.size = unit(.5, 'cm'), 
        legend.text = element_text(size = 10), 
        legend.title = element_text(size = 11), 
        legend.margin = margin(t = 0, unit = 'cm'), 
        plot.title = element_text(size = 12)) +
  guides(fill = FALSE, color = FALSE) +  # Remove both fill and color legends
  scale_y_continuous(breaks = seq(0, 1, .25))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as
## of ggplot2 3.3.4.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

# Proportions of Semantic Learning task
## M+
mp_resp_types <- c(
  "correct response (target word)",
  "incorrect response (no meaning)",
  "incorrect response (no response)",
  "incorrect response (wrong word)"
)
propsl_data_partsum %>%
  filter(
      SL.Meaning.Condition == "M+",
      SL.Response.Type %in% mp_resp_types
    ) %>%
    mutate(SL.Response.Type = factor(SL.Response.Type, levels = mp_resp_types)) %>%
    droplevels() %>%
  ggplot(aes(x = SL.Response.Type, y = proportion_partacc, fill = Group)) + 
  stat_summary(fun = mean, position = position_dodge(width = .9),
               geom="bar", colour = "black") + 
  geom_hline(yintercept = .5, color = "grey", linetype = "dashed") + 
  facet_wrap(~ Group, scales = "free_y", drop = TRUE) +  # Drop unused categories
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1),
               geom = "errorbar", 
               position = position_dodge(width = 0.9), 
               size = 1, width = 0.25, color = "black") +  # Standard deviation bars
  scale_x_discrete(limits = mp_resp_types) +  # <-- THIS IS KEY
  geom_text(
    data = propsl_summary_df,
    aes(
      x = SL.Response.Type,
      y = label_y,
      label = sprintf("%.2f", mean_proportion),
      group = Group
    ),
    position = position_dodge(width = 0.9),
    size = 4,
    color = "black"
  ) +  # Add formatted text on top of bars
  labs(title = "Proportions of M+ Semantic Learning Task Responses",
    x = "Response Type",
    y = "Mean Proportion of Responses",
    fill = "Group"
  ) +
  theme(
    axis.text.x = element_text(hjust = 1, angle = 45, size = 12, color = "black"),
    axis.text.y = element_text(size = 12, color = "black"), 
    axis.title.x = element_text(size = 14, color = "black", face = "bold", margin = margin(t = 10)),
    axis.title.y = element_text(size = 14, color = "black", face = "bold", margin = margin(r = 10)),
    strip.text = element_text(size = 12, color = "black", face = "bold"),
    legend.key.size = unit(.5, 'cm'), 
    legend.text = element_text(size = 11), 
    legend.title = element_text(size = 12, face = "bold"), 
    legend.margin = margin(t = 0, unit = 'cm'), 
    plot.title = element_text(size = 14,  face = "bold")
  ) +
  scale_y_continuous(breaks = seq(0, 1, .25))
## Warning: Removed 4 rows containing missing values or values outside the scale range
## (`geom_text()`).

## M-
mm_resp_types <- c(
  "correct response (no meaning)",
  "incorrect response (any meaning)",
  "incorrect response (no response)"
)
propsl_data_partsum %>%
  filter(
      SL.Meaning.Condition == "M-",
      SL.Response.Type %in% mm_resp_types
    ) %>%
    mutate(SL.Response.Type = factor(SL.Response.Type, levels = mm_resp_types)) %>%
    droplevels() %>%
  ggplot(aes(x = SL.Response.Type, y = proportion_partacc, fill = Group)) + 
  stat_summary(fun = mean, position = position_dodge(width = .9),
               geom="bar", colour = "black") + 
  geom_hline(yintercept = .5, color = "grey", linetype = "dashed") + 
  facet_wrap(~ Group, scales = "free_y", drop = TRUE) +  # Drop unused categories
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1),
               geom = "errorbar", 
               position = position_dodge(width = 0.9), 
               size = 1, width = 0.25, color = "black") +  # Standard deviation bars
  scale_x_discrete(limits = mm_resp_types) +  # <-- THIS IS KEY
  geom_text(
    data = propsl_summary_df,
    aes(
      x = SL.Response.Type,
      y = label_y,
      label = sprintf("%.2f", mean_proportion),
      group = Group
    ),
    position = position_dodge(width = 0.9),
    size = 4,
    color = "black"
  ) +  # Add formatted text on top of bars
  labs(title = "Proportions of M- Semantic Learning Task Responses",
    x = "Response Type",
    y = "Mean Proportion of Responses",
    fill = "Group"
  ) +
  theme(
    axis.text.x = element_text(hjust = 1, angle = 45, size = 12, color = "black"),
    axis.text.y = element_text(size = 12, color = "black"), 
    axis.title.x = element_text(size = 14, color = "black", face = "bold", margin = margin(t = 10)),
    axis.title.y = element_text(size = 14, color = "black", face = "bold", margin = margin(r = 10)),
    strip.text = element_text(size = 12, color = "black", face = "bold"),
    legend.key.size = unit(.5, 'cm'), 
    legend.text = element_text(size = 11), 
    legend.title = element_text(size = 12, face = "bold"), 
    legend.margin = margin(t = 0, unit = 'cm'), 
    plot.title = element_text(size = 14,  face = "bold")
  ) +
  scale_y_continuous(breaks = seq(0, 1, .25))
## Warning: Removed 6 rows containing missing values or values outside the scale range
## (`geom_text()`).

Recognition Task

Data Manipulations

# Create some data subsets (from previously loaded dataset)
mp_slid_data <- subset(incl_slid_data, SL.Meaning.Condition == "M+") # only M+ trials 

learned_slid_data <- subset(mp_slid_data, SL.Correct.Enough.for.IT. == 1) # only M+ trials where nonsense words' target meanings were IDed

mp_foil_data <- subset(mp_slid_data, !is.na(Semantic.vs.Other)) # only M+ trials where semantically-related, unrelated, or familiar foils were selected

learned_foil_data <- subset(learned_slid_data, !is.na(Semantic.vs.Other)) # only M+ trials where nonsense words' target meanings were IDed AND then only either a semantically-related, unrelated, or familiar foil was selected

# Calculate the proportions of responses in the Semantic Recognition task for each participant (disregarding learned/not learned status in SL task)
# Step 1: Define valid response types for IT
valid_IT_responses <- tribble(
  ~IT.Response.Type,
  "correct response (M+ target word)",
  "familiar foil",
  "unrelated foil",
  "no meaning",
  "NA",
  "semantically-related foil"
)

# Step 2: Count IT responses per participant (no SL.Meaning.Condition involved)
it_participant_counts <- mp_slid_data %>%
  group_by(Participant.ID, Group, IT.Response.Type) %>%
  summarise(n = n(), .groups = "drop")

# Step 3: Get participant × valid IT response type combinations
it_full_grid <- mp_slid_data %>%
  distinct(Participant.ID, Group) %>%
  crossing(IT.Response.Type = valid_IT_responses$IT.Response.Type)  # Using predefined valid response types

# Step 4: Left join actual counts onto the grid to fill missing values
propit_data <- it_full_grid %>%
  left_join(it_participant_counts,
            by = c("Participant.ID", "Group", "IT.Response.Type")) %>%
  mutate(n = replace_na(n, 0)) %>%
  group_by(Participant.ID, Group) %>%
  mutate(
    total_responses = sum(n),
    proportion = n / total_responses
  ) %>%
  ungroup()



# Calculate the proportions of responses in the Semantic Recognition task for each participant for only *learned* words
# Step 1: Define valid response types for IT
valid_IT_responses <- tribble(
  ~IT.Response.Type,
  "correct response (M+ target word)",
  "familiar foil",
  "unrelated foil",
  "no meaning",
  "NA",
  "semantically-related foil"
)

# Step 2: Count IT responses per participant (no SL.Meaning.Condition involved)
learned_it_participant_counts <- learned_slid_data %>%
  group_by(Participant.ID, Group, IT.Response.Type) %>%
  summarise(n = n(), .groups = "drop")

# Step 3: Get participant × valid IT response type combinations
learned_it_full_grid <- learned_slid_data %>%
  distinct(Participant.ID, Group) %>%
  crossing(IT.Response.Type = valid_IT_responses$IT.Response.Type)  # Using predefined valid response types

# Step 4: Left join actual counts onto the grid to fill missing values
learned_propit_data <- learned_it_full_grid %>%
  left_join(learned_it_participant_counts,
            by = c("Participant.ID", "Group", "IT.Response.Type")) %>%
  mutate(n = replace_na(n, 0)) %>%
  group_by(Participant.ID, Group) %>%
  mutate(
    total_responses = sum(n),
    proportion = n / total_responses
  ) %>%
  ungroup()

# Notes:
# SL Meaning Condition = context condition (M- = unsupportive, M+ = supportive); default reference level = unsupportive/M-
# For SL Meaning Condition, M+ = -0.5 (after centering), M- = 0.5 (after centering)
# For Gender, female = -0.5 (after centering), male = 0.5 (after center)

Descriptives

# Semantic Recognition task performance (disregarding learned/not learned status in SL task)
mp_slid_data_partsum <- mp_slid_data %>%
  group_by(Participant.ID, Group) %>%
  summarise(IT_corr_partacc = mean(IT.Correct., na.rm = TRUE), .groups = "drop")

it_summary_df <- mp_slid_data_partsum %>%
  group_by(Group) %>%
  summarise(
    mean_accuracy = mean(IT_corr_partacc),
    sd_accuracy = sd(IT_corr_partacc),
    n = n(),
    .groups = "drop"
  ) %>%
  mutate(
    label_y = mean_accuracy + sd_accuracy + 0.02,  # Add small buffer
    total_n = sum(n)
  )
  knitr::kable(it_summary_df)
Group mean_accuracy sd_accuracy n label_y total_n
A 0.3688889 0.1593143 60 0.5482032 105
C 0.3718519 0.1636014 45 0.5554533 105
# Semantic Recognition task performance for *learned* words
learned_slid_data_partsum <- learned_slid_data %>%
  group_by(Participant.ID, Group) %>%
  summarise(IT_corr_partacc = mean(IT.Correct., na.rm = TRUE), .groups = "drop")

learned_it_summary_df <- learned_slid_data_partsum %>%
  group_by(Group) %>%
  summarise(
    mean_accuracy = mean(IT_corr_partacc),
    sd_accuracy = sd(IT_corr_partacc),
    n = n(),
    .groups = "drop"
  ) %>%
  mutate(
    label_y = mean_accuracy + sd_accuracy + 0.02,  # Add small buffer
    total_n = sum(n)
  )
  knitr::kable(learned_it_summary_df)
Group mean_accuracy sd_accuracy n label_y total_n
A 0.4271696 0.1734506 60 0.6206202 105
C 0.4393798 0.1939308 45 0.6533106 105
# Proportions of Semantic Recognition task (disregarding learned/not learned status in SL task)
propit_data_partsum <- propit_data %>%
  group_by(Participant.ID, Group,IT.Response.Type) %>%
  summarise(proportion_partacc = mean(proportion, na.rm = TRUE), .groups = "drop")
  
propit_summary_df <- propit_data_partsum %>%
  group_by(Group, IT.Response.Type) %>%
  summarise(
    mean_proportion = mean(proportion_partacc),
    sd_proportion = sd(proportion_partacc),
    n = n(),
    .groups = "drop"
  ) %>%
  mutate(
    label_y = mean_proportion + sd_proportion + 0.02,  # Add small buffer
    total_n = sum(n)
  )
  knitr::kable(propit_summary_df)
Group IT.Response.Type mean_proportion sd_proportion n label_y total_n
A NA 0.0000000 0.0000000 60 0.0200000 630
A correct response (M+ target word) 0.3703175 0.1581543 60 0.5484717 630
A familiar foil 0.2578571 0.1340458 60 0.4119029 630
A no meaning 0.2751587 0.1715924 60 0.4667511 630
A semantically-related foil 0.0633333 0.0992818 60 0.1826151 630
A unrelated foil 0.0333333 0.0527939 60 0.1061272 630
C NA 0.0000000 0.0000000 45 0.0200000 630
C correct response (M+ target word) 0.3718519 0.1636014 45 0.5554533 630
C familiar foil 0.2118519 0.1075803 45 0.3394321 630
C no meaning 0.3511111 0.1702049 45 0.5413160 630
C semantically-related foil 0.0296296 0.0523306 45 0.1019603 630
C unrelated foil 0.0355556 0.0612991 45 0.1168546 630
# Proportions of Semantic Recognition task for *learned* words
learned_propit_data_partsum <- learned_propit_data %>%
  group_by(Participant.ID, Group,IT.Response.Type) %>%
  summarise(proportion_partacc = mean(proportion, na.rm = TRUE), .groups = "drop")

learned_propit_summary_df <- learned_propit_data_partsum %>%
  group_by(Group, IT.Response.Type) %>%
  summarise(
    mean_proportion = mean(proportion_partacc),
    sd_proportion = sd(proportion_partacc),
    n = n(),
    .groups = "drop"
  ) %>%
  mutate(
    label_y = mean_proportion + sd_proportion + 0.02,  # Add small buffer
    total_n = sum(n)
  )
  knitr::kable(learned_propit_summary_df)
Group IT.Response.Type mean_proportion sd_proportion n label_y total_n
A NA 0.0000000 0.0000000 60 0.0200000 630
A correct response (M+ target word) 0.4287081 0.1719068 60 0.6206149 630
A familiar foil 0.2320241 0.1433781 60 0.3954022 630
A no meaning 0.2421080 0.1893168 60 0.4514248 630
A semantically-related foil 0.0608621 0.1009820 60 0.1818442 630
A unrelated foil 0.0362977 0.0628175 60 0.1191152 630
C NA 0.0000000 0.0000000 45 0.0200000 630
C correct response (M+ target word) 0.4393798 0.1939308 45 0.6533106 630
C familiar foil 0.1887736 0.1238211 45 0.3325947 630
C no meaning 0.3287325 0.1888939 45 0.5376264 630
C semantically-related foil 0.0262722 0.0600091 45 0.1062813 630
C unrelated foil 0.0168419 0.0515258 45 0.0883677 630
write.csv(mp_slid_data$IT.Correct., "check_sd.csv", row.names = FALSE)

Visualizations

# Semantic Recognition task performance (disregarding learned/not learned status in SL task)
mp_slid_data_partsum %>%
  #mutate(SL.Meaning.Condition = factor(SL.Meaning.Condition, levels = c("M+","M-"))  # Set the desired order of variables
#)%>%
  ggplot(aes(x = Group, y = IT_corr_partacc, fill = Group, color = Group)) + 
  stat_summary(fun = mean, position = position_dodge(width = .9),
               geom="bar", colour = "black") + 
  geom_hline(yintercept = .5, color = "grey", linetype = "dashed") + 
  #facet_grid(~Group) + 
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1),
             geom = "errorbar", 
             position = position_dodge(width = 0.9), 
             size = 1, width = 0.25, color = "black") +  # Standard deviation bars
  geom_text(
  data = it_summary_df,
  aes(
    x = Group,
    y = label_y,
    label = sprintf("%.2f", mean_accuracy),
    group = Group
  ),
  position = position_dodge(width = 0.9),
  size = 4,
  color = "black") +  # Add formatted text on top of bars
  # scale_fill_brewer(palette = "Dark2") +
  #langcog::scale_fill_solarized()+
  labs(y = "Mean Accuracy of Target Meaning/Word Identification", 
       x = "Group")+ 
       #fill = "Meaning Condition")  +
  theme(axis.text.x = element_text(hjust = 0.5, angle = 0, size = 12, color = "black"),  # Customize x-axis text
        axis.text.y = element_text(size = 12, color = "black"), 
        axis.title.x = element_text(size = 14, color = "black", face = "bold", margin = margin(t = 10)),  # x-axis title
        axis.title.y = element_text(size = 14, color = "black", face = "bold", margin = margin(r = 10)),  # y-axis title
        strip.text = element_text(size = 12, color = "black", face = "bold"),  # Facet labels
        legend.key.size = unit(.5, 'cm'), 
        legend.text = element_text(size = 10), 
        legend.title = element_text(size = 11), 
        legend.margin = margin(t = 0, unit = 'cm'), 
        plot.title = element_text(size = 12)) +
  guides(fill = FALSE, color = FALSE) +  # Remove both fill and color legends
  scale_y_continuous(breaks = seq(0, 1, .25))

# Semantic Recognition task performance for *learned* words
learned_slid_data_partsum %>%
  #mutate(SL.Meaning.Condition = factor(SL.Meaning.Condition, levels = c("M+","M-"))  # Set the desired order of variables
#)%>%
  ggplot(aes(x = Group, y = IT_corr_partacc, fill = Group, color = Group)) + 
  stat_summary(fun = mean, position = position_dodge(width = .9),
               geom="bar", colour = "black") + 
  geom_hline(yintercept = .5, color = "grey", linetype = "dashed") + 
  #facet_grid(~Group) + 
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1),
             geom = "errorbar", 
             position = position_dodge(width = 0.9), 
             size = 1, width = 0.25, color = "black") +  # Standard deviation bars
  geom_text(
  data = learned_it_summary_df,
  aes(
    x = Group,
    y = label_y,
    label = sprintf("%.2f", mean_accuracy),
    group = Group
  ),
  position = position_dodge(width = 0.9),
  size = 4,
  color = "black") +  # Add formatted text on top of bars
  # scale_fill_brewer(palette = "Dark2") +
  #langcog::scale_fill_solarized()+
  labs(y = "Mean Accuracy of Target Meaning/Word Identification", 
       x = "Group")+ 
       #fill = "Meaning Condition")  +
  theme(axis.text.x = element_text(hjust = 0.5, angle = 0, size = 12, color = "black"),  # Customize x-axis text
        axis.text.y = element_text(size = 12, color = "black"), 
        axis.title.x = element_text(size = 14, color = "black", face = "bold", margin = margin(t = 10)),  # x-axis title
        axis.title.y = element_text(size = 14, color = "black", face = "bold", margin = margin(r = 10)),  # y-axis title
        strip.text = element_text(size = 12, color = "black", face = "bold"),  # Facet labels
        legend.key.size = unit(.5, 'cm'), 
        legend.text = element_text(size = 10), 
        legend.title = element_text(size = 11), 
        legend.margin = margin(t = 0, unit = 'cm'), 
        plot.title = element_text(size = 12)) +
  guides(fill = FALSE, color = FALSE) +  # Remove both fill and color legends
  scale_y_continuous(breaks = seq(0, 1, .25))

# Proportions of Semantic Recognition task (disregarding learned/not learned status in SL task)
propit_data_partsum %>%
    mutate(IT.Response.Type = factor(IT.Response.Type, levels = c("correct response (M+ target word)","semantically-related foil", "familiar foil", "unrelated foil", "no meaning"))  # Set the desired order of variables
)%>%
  filter(IT.Response.Type != "NA") %>%  # Removes both NA and character "NA"
  droplevels() %>%
  ggplot(aes(x = IT.Response.Type, y = proportion_partacc, fill = Group)) + 
 stat_summary(fun = mean, position = position_dodge(width = .9),
               geom="bar", colour = "black") + 
  geom_hline(yintercept = .5, color = "grey", linetype = "dashed") + 
  facet_grid(~Group) + 
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1),
             geom = "errorbar", 
             position = position_dodge(width = 0.9), 
             size = 1, width = 0.25, color = "black") +  # Standard deviation bars
  geom_text(
  data = propit_summary_df %>%
    filter(IT.Response.Type != "NA") %>%
    droplevels(),
  aes(
    x = IT.Response.Type,
    y = label_y,
    label = sprintf("%.2f", mean_proportion),
    group = Group
  ),
  position = position_dodge(width = 0.9),
  size = 4,
  color = "black") +  # Add formatted text on top of bars
  labs(#title = "Proportions of Semantic Recognition Task Responses",
    x = "Response Type",
    y = "Mean Proportion of Responses",
    fill = "Group")  +
  scale_x_discrete(labels = c(
  "correct response (M+ target word)" = "correct response\n(M+ target word)",
  "semantically-related foil" = "semantically-related foil",
  "familiar foil" = "familiar foil",
  "unrelated foil" = "unrelated foil",
  "no meaning" = "no meaning"
))+
 theme(axis.text.x = element_text(hjust = 1, angle = 45, size = 12, color = "black"),  # Customize x-axis text
        axis.text.y = element_text(size = 12, color = "black"), 
        axis.title.x = element_text(size = 14, color = "black", face = "bold", margin = margin(t = 10)),  # x-axis title
        axis.title.y = element_text(size = 14, color = "black", face = "bold", margin = margin(r = 10)),  # y-axis title
        strip.text = element_text(size = 12, color = "black", face = "bold"),  # Facet labels
        legend.key.size = unit(.5, 'cm'), 
        legend.text = element_text(size = 11), 
        legend.title = element_text(size = 12, face = "bold"), 
        legend.margin = margin(t = 0, unit = 'cm'), 
        plot.title = element_text(size = 12),
        plot.margin = margin(t = 10, r = 20, b = 20, l = 10, unit = "pt"))+
  #guides(fill = FALSE, color = FALSE) +  # Remove both fill and color legends
  scale_y_continuous(breaks = seq(0, 1, .25))

# Proportions of Semantic Recognition task for *learned* words
learned_propit_data_partsum %>%
    mutate(IT.Response.Type = factor(IT.Response.Type, levels = c("correct response (M+ target word)","semantically-related foil", "familiar foil", "unrelated foil", "no meaning"))  # Set the desired order of variables
)%>%
  filter(IT.Response.Type != "NA") %>%  # Removes both NA and character "NA"
  droplevels() %>%
  ggplot(aes(x = IT.Response.Type, y = proportion_partacc, fill = Group)) + 
 stat_summary(fun = mean, position = position_dodge(width = .9),
               geom="bar", colour = "black") + 
  geom_hline(yintercept = .5, color = "grey", linetype = "dashed") + 
  facet_grid(~Group) + 
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1),
             geom = "errorbar", 
             position = position_dodge(width = 0.9), 
             size = 1, width = 0.25, color = "black") +  # Standard deviation bars
  geom_text(
  data = learned_propit_summary_df %>%
    filter(IT.Response.Type != "NA") %>%
    droplevels(),
  aes(
    x = IT.Response.Type,
    y = label_y,
    label = sprintf("%.2f", mean_proportion),
    group = Group
  ),
  position = position_dodge(width = 0.9),
  size = 4,
  color = "black") +  # Add formatted text on top of bars
  labs(#title = "Proportions of Semantic Recognition Task Responses",
    x = "Response Type",
    y = "Mean Proportion of Responses",
    fill = "Group")  +
  scale_x_discrete(labels = c(
  "correct response (M+ target word)" = "correct response\n(M+ target word)",
  "semantically-related foil" = "semantically-related foil",
  "familiar foil" = "familiar foil",
  "unrelated foil" = "unrelated foil",
  "no meaning" = "no meaning"
))+
 theme(axis.text.x = element_text(hjust = 1, angle = 45, size = 12, color = "black"),  # Customize x-axis text
        axis.text.y = element_text(size = 12, color = "black"), 
        axis.title.x = element_text(size = 14, color = "black", face = "bold", margin = margin(t = 10)),  # x-axis title
        axis.title.y = element_text(size = 14, color = "black", face = "bold", margin = margin(r = 10)),  # y-axis title
        strip.text = element_text(size = 12, color = "black", face = "bold"),  # Facet labels
        legend.key.size = unit(.5, 'cm'), 
        legend.text = element_text(size = 11), 
        legend.title = element_text(size = 12, face = "bold"), 
        legend.margin = margin(t = 0, unit = 'cm'), 
        plot.title = element_text(size = 12),
        plot.margin = margin(t = 10, r = 20, b = 20, l = 10, unit = "pt"))+
  #guides(fill = FALSE, color = FALSE) +  # Remove both fill and color legends
  scale_y_continuous(breaks = seq(0, 1, .25))

# Proportions of Semantic Recognition task for child data only (disregarding learned/not learned status in SL task)
kidpropit_data_plot <- propit_data_partsum %>%
    mutate(IT.Response.Type = factor(IT.Response.Type, levels = c("correct response (M+ target word)","semantically-related foil", "familiar foil", "unrelated foil", "no meaning"))  # Set the desired order of variables
)%>%
  filter(IT.Response.Type != "NA" & Group == "C") %>%  # Removes both NA and character "NA"
  droplevels() %>%
  ggplot(aes(x = IT.Response.Type, y = proportion_partacc, fill = Group)) + 
 stat_summary(fun = mean, position = position_dodge(width = .9),
               geom="bar", colour = "black", fill = "#619CFF") + 
  geom_hline(yintercept = .5, color = "grey", linetype = "dashed") + 
  facet_grid(~Group) + 
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1),
             geom = "errorbar", 
             position = position_dodge(width = 0.9), 
             size = 1, width = 0.25, color = "black") +  # Standard deviation bars
  geom_text(
  data = propit_summary_df %>%
    filter(IT.Response.Type != "NA" & Group == "C") %>%
    droplevels(),
  aes(
    x = IT.Response.Type,
    y = label_y,
    label = sprintf("%.2f", mean_proportion),
    group = Group
  ),
  position = position_dodge(width = 0.9),
  size = 4,
  color = "black") +  # Add formatted text on top of bars
  labs(#title = "Proportions of Semantic Recognition Task Responses",
    x = "Semantic Recognition Response Type",
    y = "Mean Proportion of Responses",
    fill = "Group")  +
  scale_x_discrete(labels = c(
  "correct response (M+ target word)" = "correct response\n(target word)",
  "semantically-related foil" = "semantically-related\nfoil",
  "familiar foil" = "familiar foil",
  "unrelated foil" = "unrelated foil",
  "no meaning" = "red X\n(no meaning)"
))+
 theme(axis.text.x = element_text(hjust = .5, angle = 0, size = 12, color = "black"),  # Customize x-axis text
        axis.text.y = element_text(size = 12, color = "black"), 
        axis.title.x = element_text(size = 14, color = "black", face = "bold", margin = margin(t = 10)),  # x-axis title
        axis.title.y = element_text(size = 14, color = "black", face = "bold", margin = margin(r = 10)),  # y-axis title
        strip.text = element_text(size = 12, color = "black", face = "bold"),  # Facet labels
        legend.key.size = unit(.5, 'cm'), 
        legend.text = element_text(size = 11), 
        legend.title = element_text(size = 12, face = "bold"), 
        legend.margin = margin(t = 0, unit = 'cm'), 
        legend.position = "none",
        plot.title = element_text(size = 12),
        plot.margin = margin(t = 10, r = 20, b = 20, l = 10, unit = "pt"))+
  #guides(fill = FALSE, color = FALSE) +  # Remove both fill and color legends
  scale_y_continuous(breaks = seq(0, 1, .25))

ggplot2::ggsave(filename = "ID Task Responses - Kids.jpeg", 
                plot = kidpropit_data_plot, 
                device = "jpeg", 
                dpi = 300, 
                width = 12,
                height = 8, 
                units = "in",
                limitsize = FALSE)


# Proportions of Semantic Recognition task for child data only for *learned* words
learned_kidpropit_data_plot <- learned_propit_data_partsum %>%
    mutate(IT.Response.Type = factor(IT.Response.Type, levels = c("correct response (M+ target word)","semantically-related foil", "familiar foil", "unrelated foil", "no meaning"))  # Set the desired order of variables
)%>%
  filter(IT.Response.Type != "NA" & Group == "C") %>%  # Removes both NA and character "NA"
  droplevels() %>%
  ggplot(aes(x = IT.Response.Type, y = proportion_partacc, fill = Group)) + 
 stat_summary(fun = mean, position = position_dodge(width = .9),
               geom="bar", colour = "black", fill = "#619CFF") + 
  geom_hline(yintercept = .5, color = "grey", linetype = "dashed") + 
  facet_grid(~Group) + 
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1),
             geom = "errorbar", 
             position = position_dodge(width = 0.9), 
             size = 1, width = 0.25, color = "black") +  # Standard deviation bars
  geom_text(
  data = learned_propit_summary_df %>%
    filter(IT.Response.Type != "NA" & Group == "C") %>%
    droplevels(),
  aes(
    x = IT.Response.Type,
    y = label_y,
    label = sprintf("%.2f", mean_proportion),
    group = Group
  ),
  position = position_dodge(width = 0.9),
  size = 4,
  color = "black") +  # Add formatted text on top of bars
  labs(#title = "Proportions of Semantic Recognition Task Responses",
    x = "Semantic Recognition Response Type",
    y = "Mean Proportion of Responses",
    fill = "Group")  +
  scale_x_discrete(labels = c(
  "correct response (M+ target word)" = "correct response\n(target word)",
  "semantically-related foil" = "semantically related\nfoil",
  "familiar foil" = "familiar foil",
  "unrelated foil" = "unrelated foil",
  "no meaning" = "red X\n(no meaning)"
))+
 theme(axis.text.x = element_text(hjust = .5, angle = 0, size = 12, color = "black"),  # Customize x-axis text
        axis.text.y = element_text(size = 12, color = "black"), 
        axis.title.x = element_text(size = 14, color = "black", face = "bold", margin = margin(t = 10)),  # x-axis title
        axis.title.y = element_text(size = 14, color = "black", face = "bold", margin = margin(r = 10)),  # y-axis title
        strip.text = element_text(size = 12, color = "black", face = "bold"),  # Facet labels
        legend.key.size = unit(.5, 'cm'), 
        legend.text = element_text(size = 11), 
        legend.title = element_text(size = 12, face = "bold"), 
        legend.margin = margin(t = 0, unit = 'cm'), 
        legend.position = "none",
        plot.title = element_text(size = 12),
        plot.margin = margin(t = 10, r = 20, b = 20, l = 10, unit = "pt"))+
  #guides(fill = FALSE, color = FALSE) +  # Remove both fill and color legends
  scale_y_continuous(breaks = seq(0, 1, .25))

ggplot2::ggsave(filename = "ID Task Responses - Kids.jpeg", 
                plot = learned_kidpropit_data_plot, 
                device = "jpeg", 
                dpi = 300, 
                width = 12,
                height = 8, 
                units = "in",
                limitsize = FALSE)

# Proportions of Semantic Recognition task for adult data only (disregarding learned/not learned status in SL task)
adultpropit_data_plot <- propit_data_partsum %>%
    mutate(IT.Response.Type = factor(IT.Response.Type, levels = c("correct response (M+ target word)","semantically-related foil", "familiar foil", "unrelated foil", "no meaning"))  # Set the desired order of variables
)%>%
  filter(IT.Response.Type != "NA" & Group == "A") %>%  # Removes both NA and character "NA"
  droplevels() %>%
  ggplot(aes(x = IT.Response.Type, y = proportion_partacc, fill = Group)) + 
 stat_summary(fun = mean, position = position_dodge(width = .9),
               geom="bar", colour = "black") + 
  geom_hline(yintercept = .5, color = "grey", linetype = "dashed") + 
  facet_grid(~Group) + 
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1),
             geom = "errorbar", 
             position = position_dodge(width = 0.9), 
             size = 1, width = 0.25, color = "black") +  # Standard deviation bars
  geom_text(
  data = propit_summary_df %>%
    filter(IT.Response.Type != "NA" & Group == "A") %>%
    droplevels(),
  aes(
    x = IT.Response.Type,
    y = label_y,
    label = sprintf("%.2f", mean_proportion),
    group = Group
  ),
  position = position_dodge(width = 0.9),
  size = 4,
  color = "black") +  # Add formatted text on top of bars
  labs(#title = "Proportions of Semantic Recognition Task Responses",
    x = "Semantic Recognition Response Type",
    y = "Mean Proportion of Responses",
    fill = "Group")  +
  scale_x_discrete(labels = c(
  "correct response (M+ target word)" = "correct response\n(target word)",
  "semantically-related foil" = "semantically-related\nfoil",
  "familiar foil" = "familiar foil",
  "unrelated foil" = "unrelated foil",
  "no meaning" = "red X\n(no meaning)"
))+
 theme(axis.text.x = element_text(hjust = .5, angle = 0, size = 12, color = "black"),  # Customize x-axis text
        axis.text.y = element_text(size = 12, color = "black"), 
        axis.title.x = element_text(size = 14, color = "black", face = "bold", margin = margin(t = 10)),  # x-axis title
        axis.title.y = element_text(size = 14, color = "black", face = "bold", margin = margin(r = 10)),  # y-axis title
        strip.text = element_text(size = 12, color = "black", face = "bold"),  # Facet labels
        legend.key.size = unit(.5, 'cm'), 
        legend.text = element_text(size = 11), 
        legend.title = element_text(size = 12, face = "bold"), 
        legend.margin = margin(t = 0, unit = 'cm'), 
        legend.position = "none",
        plot.title = element_text(size = 12),
        plot.margin = margin(t = 10, r = 20, b = 20, l = 10, unit = "pt"))+
  #guides(fill = FALSE, color = FALSE) +  # Remove both fill and color legends
  scale_y_continuous(breaks = seq(0, 1, .25))

ggplot2::ggsave(filename = "ID Task Responses - Adults.jpeg", 
                plot = adultpropit_data_plot, 
                device = "jpeg", 
                dpi = 300, 
                width = 12,
                height = 8, 
                units = "in",
                limitsize = FALSE)


# Proportions of Semantic Recognition task for adult data only for *learned* words
learned_adultpropit_data_plot <- learned_propit_data_partsum %>%
    mutate(IT.Response.Type = factor(IT.Response.Type, levels = c("correct response (M+ target word)","semantically-related foil", "familiar foil", "unrelated foil", "no meaning"))  # Set the desired order of variables
)%>%
  filter(IT.Response.Type != "NA" & Group == "A") %>%  # Removes both NA and character "NA"
  droplevels() %>%
  ggplot(aes(x = IT.Response.Type, y = proportion_partacc, fill = Group)) + 
 stat_summary(fun = mean, position = position_dodge(width = .9),
               geom="bar", colour = "black") + 
  geom_hline(yintercept = .5, color = "grey", linetype = "dashed") + 
  facet_grid(~Group) + 
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1),
             geom = "errorbar", 
             position = position_dodge(width = 0.9), 
             size = 1, width = 0.25, color = "black") +  # Standard deviation bars
  geom_text(
  data = learned_propit_summary_df %>%
    filter(IT.Response.Type != "NA" & Group == "A") %>%
    droplevels(),
  aes(
    x = IT.Response.Type,
    y = label_y,
    label = sprintf("%.2f", mean_proportion),
    group = Group
  ),
  position = position_dodge(width = 0.9),
  size = 4,
  color = "black") +  # Add formatted text on top of bars
  labs(#title = "Proportions of Semantic Recognition Task Responses",
    x = "Semantic Recognition Response Type",
    y = "Mean Proportion of Responses",
    fill = "Group")  +
  scale_x_discrete(labels = c(
  "correct response (M+ target word)" = "correct response\n(target word)",
  "semantically-related foil" = "semantically related\nfoil",
  "familiar foil" = "familiar foil",
  "unrelated foil" = "unrelated foil",
  "no meaning" = "red X\n(no meaning)"
))+
 theme(axis.text.x = element_text(hjust = .5, angle = 0, size = 12, color = "black"),  # Customize x-axis text
        axis.text.y = element_text(size = 12, color = "black"), 
        axis.title.x = element_text(size = 14, color = "black", face = "bold", margin = margin(t = 10)),  # x-axis title
        axis.title.y = element_text(size = 14, color = "black", face = "bold", margin = margin(r = 10)),  # y-axis title
        strip.text = element_text(size = 12, color = "black", face = "bold"),  # Facet labels
        legend.key.size = unit(.5, 'cm'), 
        legend.text = element_text(size = 11), 
        legend.title = element_text(size = 12, face = "bold"), 
        legend.margin = margin(t = 0, unit = 'cm'), 
        legend.position = "none",
        plot.title = element_text(size = 12),
        plot.margin = margin(t = 10, r = 20, b = 20, l = 10, unit = "pt"))+
  #guides(fill = FALSE, color = FALSE) +  # Remove both fill and color legends
  scale_y_continuous(breaks = seq(0, 1, .25))

ggplot2::ggsave(filename = "ID Task Responses - Adults.jpeg", 
                plot = learned_adultpropit_data_plot, 
                device = "jpeg", 
                dpi = 300, 
                width = 12,
                height = 8, 
                units = "in",
                limitsize = FALSE)

Analyses

RQ1: When an individual correctly identifies a new word’s meaning in the Semantic Learning task, do they correctly identify the word’s meaning in the Semantic Recognition task?

Children

Results:
- intercept not significant, so child participants who failed to identify the meaning of the word in the Semantic Learning task were not significantly more likely to correctly or incorrectly identify the image in the Semantic Recognition task
- 2.91 times more likely to correctly identify the image in the Semantic Recognition task if they had correctly identified the word’s meaning in the Semantic Learning task, compared to if they didn’t

Child participants who formed a correct semantic representation during learning were significantly more likely to get the Semantic Recognition trial correct—almost 3 times higher odds, even after accounting for age, gender, and subject/item variability.

# # maximal model
# rq1.c.m1 <- glmer(IT.Correct. ~ SL.Correct.Enough.for.IT. + age.c + gender.c +(1 + SL.Correct.Enough.for.IT. |Participant.ID) +(1 + SL.Correct.Enough.for.IT. |SL.Correct.Response)+(1+ SL.Correct.Enough.for.IT.|SL.Trial.Order.by.Task)+(1+ SL.Correct.Enough.for.IT.|IT.Trial.Order.by.Task), data=subset(mp_slid_data,Group == "C"), family = 'binomial', control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e4))) # isSingular warning, so checking importance of each component to decide how to simplify model
#    
# summary(rePCA(rq1.c.m1)) # PC 2 for Semantic Learning task trial order (SL.Trial.Order.by.Task), Semantic Recognition task trial order (IT.Trial.Order.by.Task), and participant account for negligible proportions of variance
# 
# # model with above random slopes removed
rq1.c.m2 <- glmer(IT.Correct. ~ SL.Correct.Enough.for.IT. + age.c + gender.c +(1|Participant.ID)+ (1 + SL.Correct.Enough.for.IT. |SL.Correct.Response)+(1|SL.Trial.Order.by.Task)+(1|IT.Trial.Order.by.Task), data=subset(mp_slid_data,Group == "C"), family = 'binomial', control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e4))) # converges!

# final model results 
tab_model(rq1.c.m2, show.se = TRUE,show.ci = FALSE,show.stat = TRUE, show.df = TRUE)
  IT.Correct.
Predictors Odds Ratios std. Error Statistic p df
(Intercept) 0.23 0.27 -1.27 0.205 Inf
SL Correct Enough for IT 2.91 0.80 3.89 <0.001 Inf
age c 0.98 0.13 -0.13 0.900 Inf
gender c 1.17 0.26 0.71 0.478 Inf
Random Effects
σ2 3.29
τ00 Participant.ID 0.17
τ00 IT.Trial.Order.by.Task 0.03
τ00 SL.Trial.Order.by.Task 0.08
τ00 SL.Correct.Response 0.12
τ11 SL.Correct.Response.SL.Correct.Enough.for.IT. 0.42
ρ01 SL.Correct.Response -0.68
ICC 0.13
N Participant.ID 45
N SL.Correct.Response 15
N SL.Trial.Order.by.Task 30
N IT.Trial.Order.by.Task 31
Observations 675
Marginal R2 / Conditional R2 0.064 / 0.182
summary(rq1.c.m2)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: IT.Correct. ~ SL.Correct.Enough.for.IT. + age.c + gender.c +  
##     (1 | Participant.ID) + (1 + SL.Correct.Enough.for.IT. | SL.Correct.Response) +  
##     (1 | SL.Trial.Order.by.Task) + (1 | IT.Trial.Order.by.Task)
##    Data: subset(mp_slid_data, Group == "C")
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 20000))
## 
##      AIC      BIC   logLik deviance df.resid 
##    863.5    908.6   -421.7    843.5      665 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.4958 -0.7278 -0.5010  0.9408  2.2953 
## 
## Random effects:
##  Groups                 Name                      Variance Std.Dev. Corr 
##  Participant.ID         (Intercept)               0.17282  0.4157        
##  IT.Trial.Order.by.Task (Intercept)               0.02539  0.1594        
##  SL.Trial.Order.by.Task (Intercept)               0.07857  0.2803        
##  SL.Correct.Response    (Intercept)               0.11698  0.3420        
##                         SL.Correct.Enough.for.IT. 0.42399  0.6511   -0.68
## Number of obs: 675, groups:  
## Participant.ID, 45; IT.Trial.Order.by.Task, 31; SL.Trial.Order.by.Task, 30; SL.Correct.Response, 15
## 
## Fixed effects:
##                           Estimate Std. Error z value Pr(>|z|)    
## (Intercept)               -1.45000    1.14441  -1.267    0.205    
## SL.Correct.Enough.for.IT.  1.06959    0.27469   3.894 9.87e-05 ***
## age.c                     -0.01725    0.13686  -0.126    0.900    
## gender.c                   0.15553    0.21934   0.709    0.478    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) SL.C.E age.c 
## SL.C.E..IT. -0.182              
## age.c        0.981 -0.043       
## gender.c     0.154  0.084  0.159

Adults

Results:
- intercept is significant, so adult participants who failed to identify the meaning of the word in the Semantic Learning task were significantly more likely to not correctly identify the image in the Semantic Recognition task (i.e., pick a foil/say no meaning)
- 4.8 times more likely to correctly identify the image in the Semantic Recognition task if they had correctly identified the word’s meaning in the Semantic Learning task, compared to if they didn’t

Adult participants who formed a correct semantic representation during learning were significantly more likely to get the Semantic Recognition trial correct—about 4.8 times higher odds, even after accounting for age, gender, and subject/item variability.

Comparing patterns of results across the two participant groups, while Semantic Learning task performance still supports Semantic Recognition task performance in children, it has a weaker effect in children than in adults.

# # maximal model
#rq1.a.m1 <- glmer(IT.Correct. ~ SL.Correct.Enough.for.IT. + age.c + gender.c + (1 + SL.Correct.Enough.for.IT. |Participant.ID)+(1 + SL.Correct.Enough.for.IT. |SL.Correct.Response)+(1+ SL.Correct.Enough.for.IT.|SL.Trial.Order.by.Task)+(1+ SL.Correct.Enough.for.IT.|IT.Trial.Order.by.Task), data=subset(mp_slid_data,Group == "A"), family = 'binomial', control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e4))) # isSingular warning, so checking importance of each component to decide how to simplify model
#   
# summary(rePCA(rq1.a.m1)) # all PC 2s for Semantic Learning task accuracy (SL.Correct.Enough.for.IT.) account for negligible proportions of variance
# 
# # model with all random slopes removed
# rq1.a.m2 <- glmer(IT.Correct. ~ SL.Correct.Enough.for.IT. + age.c + gender.c + (1 |Participant.ID)+(1 |SL.Correct.Response)+(1|SL.Trial.Order.by.Task)+(1|IT.Trial.Order.by.Task), data=subset(mp_slid_data,Group == "A"), family = 'binomial', control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e4))) # isSingular warning, so checking importance of each component to decide how to further simplify model
#   
# summary(rePCA(rq1.a.m2)) # random intercept for Semantic Learning task order (SL.Trial.Order.by.Task) and Semantic Recognition task trial order (IT.Trial.Order.by.Task) accounts for a negligible proportion of variance
# 
# # model with random intercept for Semantic Learning task order (SL.Trial.Order.by.Task) and Semantic Recognition task trial order (IT.Trial.Order.by.Task) removed
 rq1.a.m3 <- glmer(IT.Correct. ~ SL.Correct.Enough.for.IT. + age.c + gender.c + (1 |Participant.ID)+(1 |SL.Correct.Response), data=subset(mp_slid_data,Group == "A"), family = 'binomial', control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e4))) # converges!

# final model results 
tab_model(rq1.a.m3, show.se = TRUE,show.ci = FALSE,show.stat = TRUE, show.df = TRUE)
  IT.Correct.
Predictors Odds Ratios std. Error Statistic p df
(Intercept) 0.15 0.06 -4.64 <0.001 Inf
SL Correct Enough for IT 4.80 1.08 6.96 <0.001 Inf
age c 1.00 0.05 0.05 0.957 Inf
gender c 1.24 0.22 1.20 0.231 Inf
Random Effects
σ2 3.29
τ00 Participant.ID 0.14
τ00 SL.Correct.Response 0.14
ICC 0.08
N Participant.ID 60
N SL.Correct.Response 15
Observations 900
Marginal R2 / Conditional R2 0.106 / 0.176
summary(rq1.a.m3)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: IT.Correct. ~ SL.Correct.Enough.for.IT. + age.c + gender.c +  
##     (1 | Participant.ID) + (1 | SL.Correct.Response)
##    Data: subset(mp_slid_data, Group == "A")
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 20000))
## 
##      AIC      BIC   logLik deviance df.resid 
##   1117.8   1146.6   -552.9   1105.8      894 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.4151 -0.7930 -0.4219  0.9933  3.6762 
## 
## Random effects:
##  Groups              Name        Variance Std.Dev.
##  Participant.ID      (Intercept) 0.1394   0.3734  
##  SL.Correct.Response (Intercept) 0.1396   0.3737  
## Number of obs: 900, groups:  Participant.ID, 60; SL.Correct.Response, 15
## 
## Fixed effects:
##                            Estimate Std. Error z value Pr(>|z|)    
## (Intercept)               -1.866224   0.401821  -4.644 3.41e-06 ***
## SL.Correct.Enough.for.IT.  1.568281   0.225440   6.957 3.49e-12 ***
## age.c                      0.002893   0.053101   0.054    0.957    
## gender.c                   0.214073   0.178667   1.198    0.231    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) SL.C.E age.c 
## SL.C.E..IT. -0.501              
## age.c       -0.812  0.021       
## gender.c    -0.098  0.102  0.089