options(digits = 2)
library(pacman)
p_load(kirkegaard, readr, dplyr, metafor)
d = read_csv("data/study table.csv") %>% 
  mutate(
    year = str_match(citation, "\\d+") %>% as.vector,
    sample_name = str_uniquify(citation)
  )
## Parsed with column specification:
## cols(
##   citation = col_character(),
##   g = col_double(),
##   se = col_double(),
##   n1 = col_integer(),
##   n2 = col_integer()
## )
#model
meta_main = d %$% rma(yi = g, sei = se)
meta_main
## 
## Random-Effects Model (k = 17; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.1570 (SE = 0.0930)
## tau (square root of estimated tau^2 value):      0.3963
## I^2 (total heterogeneity / total variability):   64.77%
## H^2 (total variability / sampling variability):  2.84
## 
## Test for Heterogeneity: 
## Q(df = 16) = 47.8399, p-val < .0001
## 
## Model Results:
## 
## estimate       se     zval     pval    ci.lb    ci.ub          
##   0.4340   0.1256   3.4563   0.0005   0.1879   0.6801      *** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#plot
GG_forest(meta_main, .names = d$sample_name)

GG_funnel(meta_main)

#trim fill
trimfill(meta_main, estimator = "L0")
## 
## Estimated number of missing studies on the left side: 0 (SE = 2.5709)
## 
## Random-Effects Model (k = 17; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.1570 (SE = 0.0930)
## tau (square root of estimated tau^2 value):      0.3963
## I^2 (total heterogeneity / total variability):   64.77%
## H^2 (total variability / sampling variability):  2.84
## 
## Test for Heterogeneity: 
## Q(df = 16) = 47.8399, p-val < .0001
## 
## Model Results:
## 
## estimate       se     zval     pval    ci.lb    ci.ub          
##   0.4340   0.1256   3.4563   0.0005   0.1879   0.6801      *** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
trimfill(meta_main, estimator = "R0")
## 
## Estimated number of missing studies on the left side: 11 (SE = 4.8990)
## Test of H0: no missing studies on the left side: p-val = 0.0002
## 
## Random-Effects Model (k = 28; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.4645 (SE = 0.1603)
## tau (square root of estimated tau^2 value):      0.6815
## I^2 (total heterogeneity / total variability):   82.86%
## H^2 (total variability / sampling variability):  5.83
## 
## Test for Heterogeneity: 
## Q(df = 27) = 138.0074, p-val < .0001
## 
## Model Results:
## 
## estimate       se     zval     pval    ci.lb    ci.ub          
##  -0.0246   0.1454  -0.1695   0.8654  -0.3096   0.2603          
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
trimfill(meta_main, estimator = "Q0")
## 
## Estimated number of missing studies on the left side: 0 (SE = 2.5804)
## 
## Random-Effects Model (k = 17; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.1570 (SE = 0.0930)
## tau (square root of estimated tau^2 value):      0.3963
## I^2 (total heterogeneity / total variability):   64.77%
## H^2 (total variability / sampling variability):  2.84
## 
## Test for Heterogeneity: 
## Q(df = 16) = 47.8399, p-val < .0001
## 
## Model Results:
## 
## estimate       se     zval     pval    ci.lb    ci.ub          
##   0.4340   0.1256   3.4563   0.0005   0.1879   0.6801      *** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#egger test
regtest(meta_main)
## 
## Regression Test for Funnel Plot Asymmetry
## 
## model:     mixed-effects meta-regression model
## predictor: standard error
## 
## test for funnel plot asymmetry: z = 1.8577, p = 0.0632
#correlation
cor.test(d$g, d$se)
## 
##  Pearson's product-moment correlation
## 
## data:  d$g and d$se
## t = 2, df = 20, p-value = 0.08
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.06  0.76
## sample estimates:
##  cor 
## 0.43