Load libraries and functions

rm(list=ls())
knitr::opts_chunk$set(cache = F, warning = F, message = F, echo = T)
library(ggplot2)
library(metafor)
library(compute.es)
library(dplyr)
library(langcog)

Load data and calculate d values

df = read.csv("L2C_data.csv")
df$id = 1:dim(df)[1]

ts = df[!is.na(df$t),]  
ts$d = tes(ts$t, ts$n_1, ts$n_1, verbose = F)$d
ts$d_var = tes(ts$t, ts$n_1, ts$n_1, verbose = F)$var.d

ms = df[is.na(df$t),]  
ms$d = mes(ms$x_1, ms$x_2, ms$SD_1,ms$SD_1, ms$n_1, ms$n_1, verbose = F)$d
ms$d_var = mes(ms$x_1, ms$x_2, ms$SD_1,ms$SD_1, ms$n_1, ms$n_1, verbose = F)$var.d

df = rbind(ts, ms)

Model with no moderators

model <- rma(d, vi = d_var, slab = as.character(short_cite),
                  data = df, method = "REML")
forest(model)

funnel(model)

ES as a function of age

ggplot(df, aes_string(x = "mean_age_1", y = "d")) +
  geom_point(aes(size = n_1)) +
  geom_smooth(method = "lm", formula = y ~ log(x)) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  scale_colour_brewer(name = "", palette = "Set1") +
  scale_size_continuous(guide = FALSE) +
  xlab("\nMean Subject Age (days)") +
  ylab("Effect Size\n") +
  theme_bw(base_size=14) +
  theme(panel.background = element_blank(),
         panel.grid.major = element_blank(),
         panel.grid.minor = element_blank(), 
         axis.text.x = element_text(angle = 90, hjust = 1))

ES as a function of age and audio stimulus

df$audio_condition_2 = factor(df$audio_condition_2,
                              levels(df$audio_condition_2)[c(4,1,3,2,5,6)])

ggplot(df, aes_string(x = "mean_age_1", y = "d")) +
  geom_point(aes(size = n_1, color = audio_condition_2)) +
  geom_smooth(method = "lm", formula = y ~ log(x)) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  scale_colour_brewer(name = "", palette = "Set1") +
  scale_size_continuous(guide = FALSE) +
  facet_grid(~audio_condition_2) +
  xlab("\nMean Subject Age (days)") +
  ylab("Effect Size\n") +
  theme_bw(base_size=14) +
  theme(panel.background = element_blank(),
         panel.grid.major = element_blank(),
         panel.grid.minor = element_blank(), 
         axis.text.x = element_text(angle = 90, hjust = 1))

ES as a function of number of trials

  df$age.f = cut(df$mean_age_1, 
               breaks = seq(1,500,100), labels = F)
    
  ggplot(df, aes_string(x = "number.of.familiarization.trials", y = "d")) +
  geom_point(aes(size = age.f, color = audio_condition_2)) +
  geom_smooth(method = "lm", formula = y ~ log(x)) +
  geom_hline(yintercept = 0, linetype = "dashed") +
  scale_colour_brewer(name = "", palette = "Set1") +
  scale_size_continuous(guide = FALSE) +
  facet_grid(~audio_condition_2) +
  xlab("\nNumber of Trials") +
  ylab("Effect Size\n") +
  theme_bw(base_size=14) +
  theme(panel.background = element_blank(),
         panel.grid.major = element_blank(),
         panel.grid.minor = element_blank(), 
         axis.text.x = element_text(angle = 90, hjust = 1))

Model with age moderators

model.age = rma(d ~ mean_age_1, vi = d_var,  
                method = "REML", data = df, slab = as.character(short_cite))
model.age
## 
## Mixed-Effects Model (k = 81; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of residual heterogeneity):     0.2608 (SE = 0.0631)
## tau (square root of estimated tau^2 value):             0.5107
## I^2 (residual heterogeneity / unaccounted variability): 67.50%
## H^2 (unaccounted variability / sampling variability):   3.08
## R^2 (amount of heterogeneity accounted for):            8.79%
## 
## Test for Residual Heterogeneity: 
## QE(df = 79) = 233.2078, p-val < .0001
## 
## Test of Moderators (coefficient(s) 2): 
## QM(df = 1) = 7.2285, p-val = 0.0072
## 
## Model Results:
## 
##             estimate      se     zval    pval    ci.lb   ci.ub    
## intrcpt      -0.0702  0.2347  -0.2988  0.7651  -0.5303  0.3899    
## mean_age_1    0.0019  0.0007   2.6886  0.0072   0.0005  0.0033  **
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
forest(model.age)

funnel(model.age)

Model with age and audio-type moderator

model.age.audio2 = rma(d ~ mean_age_1 + audio_condition_2, 
                       vi = d_var,  method = "REML", data = df)
model.age.audio2
## 
## Mixed-Effects Model (k = 81; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of residual heterogeneity):     0.2470 (SE = 0.0629)
## tau (square root of estimated tau^2 value):             0.4970
## I^2 (residual heterogeneity / unaccounted variability): 66.19%
## H^2 (unaccounted variability / sampling variability):   2.96
## R^2 (amount of heterogeneity accounted for):            13.61%
## 
## Test for Residual Heterogeneity: 
## QE(df = 74) = 208.9410, p-val < .0001
## 
## Test of Moderators (coefficient(s) 2,3,4,5,6,7): 
## QM(df = 6) = 14.2159, p-val = 0.0273
## 
## Model Results:
## 
##                                             estimate      se     zval
## intrcpt                                       0.1788  0.2859   0.6252
## mean_age_1                                    0.0013  0.0008   1.5634
## audio_condition_2adjective                    0.4231  0.2802   1.5099
## audio_condition_2non-word linguistic sound   -0.0768  0.3602  -0.2133
## audio_condition_2non-linguistic sound        -0.2734  0.1804  -1.5156
## audio_condition_2other                       -0.2964  0.3124  -0.9489
## audio_condition_2silence                      0.0773  0.1953   0.3960
##                                               pval    ci.lb   ci.ub   
## intrcpt                                     0.5319  -0.3817  0.7392   
## mean_age_1                                  0.1180  -0.0003  0.0028   
## audio_condition_2adjective                  0.1311  -0.1261  0.9723   
## audio_condition_2non-word linguistic sound  0.8311  -0.7828  0.6291   
## audio_condition_2non-linguistic sound       0.1296  -0.6269  0.0802   
## audio_condition_2other                      0.3427  -0.9087  0.3158   
## audio_condition_2silence                    0.6921  -0.3054  0.4601   
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
funnel(model.age.audio2)