Init

library(kirkegaard)
## Loading required package: tidyverse
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.6     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.4     ✓ stringr 1.4.0
## ✓ readr   2.1.0     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
## Loading required package: weights
## Loading required package: Hmisc
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## The following objects are masked from 'package:base':
## 
##     format.pval, units
## Loading required package: assertthat
## 
## Attaching package: 'assertthat'
## The following object is masked from 'package:tibble':
## 
##     has_name
## Loading required package: magrittr
## 
## Attaching package: 'magrittr'
## The following object is masked from 'package:purrr':
## 
##     set_names
## The following object is masked from 'package:tidyr':
## 
##     extract
## Loading required package: psych
## 
## Attaching package: 'psych'
## The following object is masked from 'package:Hmisc':
## 
##     describe
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
## Loading required package: metafor
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## Loading the 'metafor' package (version 3.0-2). For an
## introduction to the package please type: help(metafor)
## Loading required package: rlang
## 
## Attaching package: 'rlang'
## The following object is masked from 'package:magrittr':
## 
##     set_names
## The following object is masked from 'package:assertthat':
## 
##     has_name
## The following objects are masked from 'package:purrr':
## 
##     %@%, as_function, flatten, flatten_chr, flatten_dbl, flatten_int,
##     flatten_lgl, flatten_raw, invoke, list_along, modify, prepend,
##     splice
## 
## Attaching package: 'kirkegaard'
## The following object is masked from 'package:rlang':
## 
##     is_logical
## The following object is masked from 'package:psych':
## 
##     rescale
## The following object is masked from 'package:assertthat':
## 
##     are_equal
## The following objects are masked from 'package:purrr':
## 
##     is_logical, is_numeric
## The following object is masked from 'package:base':
## 
##     +
load_packages(
  readxl,
  metafor,
  metaviz
)

options(
  digits = 3
  )

theme_set(theme_bw())

Data

#read the data
d = readxl::read_excel("data/data.xlsx", range = "A1:F61") %>% 
  df_legalize_names()

#get the standard error from the CI
d %<>% mutate(
  lower_95 = str_match(x95pct_CI_per_study, "(.+) to (.+)")[, 2] %>% as.numeric(),
  upper_95 = str_match(x95pct_CI_per_study, "(.+) to (.+)")[, 3] %>% as.numeric(),
  lower_CI_width = abs(Hedges_g - lower_95),
  upper_CI_width = abs(Hedges_g - upper_95),
  CI_width_mean = rowMeans(cbind(lower_CI_width, upper_CI_width)),
  SE = CI_width_mean / 1.96 #95%
)

#arrange by SE
d = arrange(d, SE)

Analysis

#plot p values
d %>% 
  ggplot(aes(p_value)) + 
  geom_histogram(binwidth = .05, boundary = 0)

#the critical region
d %>% 
  filter(p_value < .10) %>% 
  ggplot(aes(p_value)) + 
  geom_histogram(binwidth = .01, boundary = 0)

#RMA
rma_fit = d %>% arrange(SE) %$% rma(Hedges_g, sei = SE)
rma_fit
## 
## Random-Effects Model (k = 60; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.8565 (SE = 0.1834)
## tau (square root of estimated tau^2 value):      0.9254
## I^2 (total heterogeneity / total variability):   90.19%
## H^2 (total variability / sampling variability):  10.19
## 
## Test for Heterogeneity:
## Q(df = 59) = 367.9339, p-val < .0001
## 
## Model Results:
## 
## estimate      se    zval    pval   ci.lb   ci.ub 
##   0.8223  0.1292  6.3647  <.0001  0.5691  1.0755  *** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#funnel
rma_fit %>% GG_funnel()

GG_save("figs/funnel.png")

#forest
rma_fit %>% GG_forest(.alphabetic_sort_names = T)

#not in right order, fail

#with metaviz
metaviz::viz_forest(rma_fit)

GG_save("figs/forrest_better.png")

#funnel
metaviz::funnelinf(rma_fit, n = 1)

GG_save("figs/funnel_better.png")

Meta

write_sessioninfo()
## R version 4.1.2 (2021-11-01)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Linux Mint 19.3
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_DK.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_DK.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_DK.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] metaviz_0.3.1         readxl_1.3.1          kirkegaard_2021-12-14
##  [4] rlang_0.4.12          metafor_3.0-2         Matrix_1.4-0         
##  [7] psych_2.1.9           magrittr_2.0.1        assertthat_0.2.1     
## [10] weights_1.0.4         Hmisc_4.6-0           Formula_1.2-4        
## [13] survival_3.2-13       lattice_0.20-45       forcats_0.5.1        
## [16] stringr_1.4.0         dplyr_1.0.7           purrr_0.3.4          
## [19] readr_2.1.0           tidyr_1.1.4           tibble_3.1.6         
## [22] ggplot2_3.3.5         tidyverse_1.3.1      
## 
## loaded via a namespace (and not attached):
##  [1] nlme_3.1-152        fs_1.5.0            lubridate_1.8.0    
##  [4] RColorBrewer_1.1-2  httr_1.4.2          tools_4.1.2        
##  [7] backports_1.3.0     bslib_0.3.1         utf8_1.2.2         
## [10] R6_2.5.1            rpart_4.1-15        DBI_1.1.1          
## [13] colorspace_2.0-2    nnet_7.3-16         withr_2.4.2        
## [16] mnormt_2.0.2        tidyselect_1.1.1    gridExtra_2.3      
## [19] rematch_1.0.1       compiler_4.1.2      cli_3.1.0          
## [22] rvest_1.0.2         htmlTable_2.3.0     mice_3.13.0        
## [25] xml2_1.3.2          labeling_0.4.2      sass_0.4.0         
## [28] scales_1.1.1        checkmate_2.0.0     digest_0.6.28      
## [31] minqa_1.2.4         foreign_0.8-81      rmarkdown_2.11     
## [34] base64enc_0.1-3     jpeg_0.1-9          pkgconfig_2.0.3    
## [37] htmltools_0.5.2     lme4_1.1-27.1       highr_0.9          
## [40] dbplyr_2.1.1        fastmap_1.1.0       htmlwidgets_1.5.4  
## [43] rstudioapi_0.13     farver_2.1.0        jquerylib_0.1.4    
## [46] generics_0.1.1      jsonlite_1.7.2      gtools_3.9.2       
## [49] Rcpp_1.0.7          munsell_0.5.0       fansi_0.5.0        
## [52] lifecycle_1.0.1     stringi_1.7.5       yaml_2.2.1         
## [55] mathjaxr_1.4-0      MASS_7.3-54         grid_4.1.2         
## [58] parallel_4.1.2      gdata_2.18.0        crayon_1.4.2       
## [61] haven_2.4.3         splines_4.1.2       hms_1.1.1          
## [64] tmvnsim_1.0-2       knitr_1.36          pillar_1.6.4       
## [67] boot_1.3-28         reprex_2.0.1        glue_1.5.0         
## [70] evaluate_0.14       latticeExtra_0.6-29 data.table_1.14.2  
## [73] modelr_0.1.8        nloptr_1.2.2.3      png_0.1-7          
## [76] vctrs_0.3.8         tzdb_0.2.0          cellranger_1.1.0   
## [79] gtable_0.3.0        xfun_0.28           broom_0.7.10       
## [82] cluster_2.1.2       ellipsis_0.3.2