Init

library(kirkegaard)
## Loading required package: tidyverse
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## 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: weights
## 
## Loading required package: Hmisc
## 
## 
## 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: psych
## 
## 
## Attaching package: 'psych'
## 
## 
## The following object is masked from 'package:Hmisc':
## 
##     describe
## 
## 
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
## 
## 
## 
## Attaching package: 'kirkegaard'
## 
## 
## The following object is masked from 'package:psych':
## 
##     rescale
## 
## 
## The following object is masked from 'package:assertthat':
## 
##     are_equal
## 
## 
## The following object is masked from 'package:purrr':
## 
##     is_logical
## 
## 
## The following object is masked from 'package:base':
## 
##     +
load_packages(
  metafor,
  brms,
  extraDistr,
  patchwork
)
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## 
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## Loading required package: metadat
## Loading required package: numDeriv
## 
## Loading the 'metafor' package (version 4.6-0). For an
## introduction to the package please type: help(metafor)
## 
## Loading required package: Rcpp
## Loading 'brms' package (version 2.22.0). Useful instructions
## can be found by typing help('brms'). A more detailed introduction
## to the package is available through vignette('brms_overview').
## 
## Attaching package: 'brms'
## 
## The following object is masked from 'package:psych':
## 
##     cs
## 
## The following object is masked from 'package:stats':
## 
##     ar
## 
## 
## Attaching package: 'extraDistr'
## 
## The following objects are masked from 'package:brms':
## 
##     ddirichlet, dfrechet, pfrechet, qfrechet, rdirichlet, rfrechet
## 
## The following object is masked from 'package:purrr':
## 
##     rdunif
theme_set(theme_bw())

options(
    digits = 3
)

Data

d = read_tsv("Sample    Tests   Race    Model   male_d  se
NLSY79  12  White   HOF 0.298   0.035
NLSY79  12  White   BF  -0.034  0.031
NLSY79  12  All HOF 0.214   0.028
NLSY79  12  All BF  -0.024  0.023
NLSY97  15  White   HOF 0.076   0.034
NLSY97  15  White   BF  -0.15   0.036
NLSY97  15  All HOF 0.08    0.026
NLSY97  15  All BF  0.167   0.027
Talent  34  White   HOF 0.36    0.007
Talent  34  White   BF  0.931   0.014
Talent  34  Black   HOF 0.153   0.036
Talent  34  Black   BF  0.481   0.054
Talent  20  White   HOF 0.05    0.008
Talent  20  White   BF  0.352   0.007
Talent  20  Black   HOF 0.082   0.03
Talent  20  Black   BF  -0.066  0.031
")
## Rows: 16 Columns: 6
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr (3): Sample, Race, Model
## dbl (3): Tests, male_d, se
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
d

Analysis

#plot one at a time
p1 = d %>% GG_group_means("male_d", "Sample", type = "boxplot") + geom_hline(yintercept = 0)
p2 = d %>% GG_group_means("male_d", "Tests", type = "boxplot") + geom_hline(yintercept = 0)
p3 = d %>% GG_group_means("male_d", "Model", type = "boxplot") + geom_hline(yintercept = 0)
p4 = d %>% GG_group_means("male_d", "Race", type = "boxplot") + geom_hline(yintercept = 0)

p1 + p2 + p3 + p4

GG_save("sex_diff_boxplots.png")

#naive
d$male_d %>% mean()
## [1] 0.186
weighted.mean(d$male_d, 1/d$se)
## [1] 0.242
d$male_d %>% median()
## [1] 0.117
#freq
fit_freq = rma(d$male_d, sei = d$se)
fit_freq
## 
## Random-Effects Model (k = 16; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of total heterogeneity): 0.0686 (SE = 0.0254)
## tau (square root of estimated tau^2 value):      0.2620
## I^2 (total heterogeneity / total variability):   99.63%
## H^2 (total variability / sampling variability):  272.16
## 
## Test for Heterogeneity:
## Q(df = 15) = 3956.9935, p-val < .0001
## 
## Model Results:
## 
## estimate      se    zval    pval   ci.lb   ci.ub     
##   0.1858  0.0659  2.8195  0.0048  0.0566  0.3150  ** 
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#with covars
fit_freq_covar1 = rma(d$male_d, sei = d$se, mods = ~ Sample + Tests + Race + Model, data = d)
fit_freq_covar1
## 
## Mixed-Effects Model (k = 16; tau^2 estimator: REML)
## 
## tau^2 (estimated amount of residual heterogeneity):     0.0447 (SE = 0.0215)
## tau (square root of estimated tau^2 value):             0.2115
## I^2 (residual heterogeneity / unaccounted variability): 99.12%
## H^2 (unaccounted variability / sampling variability):   113.78
## R^2 (amount of heterogeneity accounted for):            34.80%
## 
## Test for Residual Heterogeneity:
## QE(df = 9) = 979.2160, p-val < .0001
## 
## Test of Moderators (coefficients 2:7):
## QM(df = 6) = 13.8568, p-val = 0.0313
## 
## Model Results:
## 
##               estimate      se     zval    pval    ci.lb   ci.ub    
## intrcpt        -0.1568  0.1912  -0.8201  0.4122  -0.5317  0.2180    
## SampleNLSY97   -0.1498  0.1545  -0.9695  0.3323  -0.4527  0.1531    
## SampleTalent   -0.0622  0.2334  -0.2664  0.7899  -0.5197  0.3954    
## Tests           0.0269  0.0108   2.4941  0.0126   0.0058  0.0480  * 
## RaceBlack      -0.3229  0.2136  -1.5120  0.1305  -0.7415  0.0957    
## RaceWhite      -0.0616  0.1511  -0.4078  0.6834  -0.3578  0.2345    
## ModelHOF       -0.0443  0.1068  -0.4146  0.6785  -0.2535  0.1650    
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#bayes
priors <- c(prior(normal(0,1), class = Intercept),
            prior(cauchy(0,0.5), class = sd))

fit_bayes <- brm(male_d|se(se) ~ 1,
             data = d,
             iter = 4000)
## Compiling Stan program...
## Trying to compile a simple C file
## Running /usr/lib/R/bin/R CMD SHLIB foo.c
## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
## gcc -I"/usr/share/R/include" -DNDEBUG   -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include/"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/unsupported"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/BH/include" -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/src/"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppParallel/include/"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DUSE_STANC3 -DSTRICT_R_HEADERS  -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION  -D_HAS_AUTO_PTR_ETC=0  -include '/home/emil/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/stan/math/prim/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1       -fpic  -g -O2 -ffile-prefix-map=/build/r-base-6tgf7J/r-base-4.4.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c foo.c -o foo.o
## In file included from /home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/Eigen/Core:19,
##                  from /home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/Eigen/Dense:1,
##                  from /home/emil/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22,
##                  from <command-line>:
## /home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/Eigen/src/Core/util/Macros.h:679:10: fatal error: cmath: No such file or directory
##   679 | #include <cmath>
##       |          ^~~~~~~
## compilation terminated.
## make: *** [/usr/lib/R/etc/Makeconf:195: foo.o] Error 1
## Start sampling
## 
## SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 1).
## Chain 1: 
## Chain 1: Gradient evaluation took 1.1e-05 seconds
## Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds.
## Chain 1: Adjust your expectations accordingly!
## Chain 1: 
## Chain 1: 
## Chain 1: Iteration:    1 / 4000 [  0%]  (Warmup)
## Chain 1: Iteration:  400 / 4000 [ 10%]  (Warmup)
## Chain 1: Iteration:  800 / 4000 [ 20%]  (Warmup)
## Chain 1: Iteration: 1200 / 4000 [ 30%]  (Warmup)
## Chain 1: Iteration: 1600 / 4000 [ 40%]  (Warmup)
## Chain 1: Iteration: 2000 / 4000 [ 50%]  (Warmup)
## Chain 1: Iteration: 2001 / 4000 [ 50%]  (Sampling)
## Chain 1: Iteration: 2400 / 4000 [ 60%]  (Sampling)
## Chain 1: Iteration: 2800 / 4000 [ 70%]  (Sampling)
## Chain 1: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 1: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 1: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 1: 
## Chain 1:  Elapsed Time: 0.011 seconds (Warm-up)
## Chain 1:                0.012 seconds (Sampling)
## Chain 1:                0.023 seconds (Total)
## Chain 1: 
## 
## SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 2).
## Chain 2: 
## Chain 2: Gradient evaluation took 2e-06 seconds
## Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.02 seconds.
## Chain 2: Adjust your expectations accordingly!
## Chain 2: 
## Chain 2: 
## Chain 2: Iteration:    1 / 4000 [  0%]  (Warmup)
## Chain 2: Iteration:  400 / 4000 [ 10%]  (Warmup)
## Chain 2: Iteration:  800 / 4000 [ 20%]  (Warmup)
## Chain 2: Iteration: 1200 / 4000 [ 30%]  (Warmup)
## Chain 2: Iteration: 1600 / 4000 [ 40%]  (Warmup)
## Chain 2: Iteration: 2000 / 4000 [ 50%]  (Warmup)
## Chain 2: Iteration: 2001 / 4000 [ 50%]  (Sampling)
## Chain 2: Iteration: 2400 / 4000 [ 60%]  (Sampling)
## Chain 2: Iteration: 2800 / 4000 [ 70%]  (Sampling)
## Chain 2: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 2: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 2: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 2: 
## Chain 2:  Elapsed Time: 0.011 seconds (Warm-up)
## Chain 2:                0.012 seconds (Sampling)
## Chain 2:                0.023 seconds (Total)
## Chain 2: 
## 
## SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 3).
## Chain 3: 
## Chain 3: Gradient evaluation took 2e-06 seconds
## Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.02 seconds.
## Chain 3: Adjust your expectations accordingly!
## Chain 3: 
## Chain 3: 
## Chain 3: Iteration:    1 / 4000 [  0%]  (Warmup)
## Chain 3: Iteration:  400 / 4000 [ 10%]  (Warmup)
## Chain 3: Iteration:  800 / 4000 [ 20%]  (Warmup)
## Chain 3: Iteration: 1200 / 4000 [ 30%]  (Warmup)
## Chain 3: Iteration: 1600 / 4000 [ 40%]  (Warmup)
## Chain 3: Iteration: 2000 / 4000 [ 50%]  (Warmup)
## Chain 3: Iteration: 2001 / 4000 [ 50%]  (Sampling)
## Chain 3: Iteration: 2400 / 4000 [ 60%]  (Sampling)
## Chain 3: Iteration: 2800 / 4000 [ 70%]  (Sampling)
## Chain 3: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 3: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 3: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 3: 
## Chain 3:  Elapsed Time: 0.011 seconds (Warm-up)
## Chain 3:                0.011 seconds (Sampling)
## Chain 3:                0.022 seconds (Total)
## Chain 3: 
## 
## SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 4).
## Chain 4: 
## Chain 4: Gradient evaluation took 2e-06 seconds
## Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.02 seconds.
## Chain 4: Adjust your expectations accordingly!
## Chain 4: 
## Chain 4: 
## Chain 4: Iteration:    1 / 4000 [  0%]  (Warmup)
## Chain 4: Iteration:  400 / 4000 [ 10%]  (Warmup)
## Chain 4: Iteration:  800 / 4000 [ 20%]  (Warmup)
## Chain 4: Iteration: 1200 / 4000 [ 30%]  (Warmup)
## Chain 4: Iteration: 1600 / 4000 [ 40%]  (Warmup)
## Chain 4: Iteration: 2000 / 4000 [ 50%]  (Warmup)
## Chain 4: Iteration: 2001 / 4000 [ 50%]  (Sampling)
## Chain 4: Iteration: 2400 / 4000 [ 60%]  (Sampling)
## Chain 4: Iteration: 2800 / 4000 [ 70%]  (Sampling)
## Chain 4: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 4: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 4: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 4: 
## Chain 4:  Elapsed Time: 0.011 seconds (Warm-up)
## Chain 4:                0.012 seconds (Sampling)
## Chain 4:                0.023 seconds (Total)
## Chain 4:
summary(fit_bayes)
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: male_d | se(se) ~ 1 
##    Data: d (Number of observations: 16) 
##   Draws: 4 chains, each with iter = 4000; warmup = 2000; thin = 1;
##          total post-warmup draws = 8000
## 
## Regression Coefficients:
##           Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept     0.28      0.00     0.28     0.29 1.00     3422     3573
## 
## Further Distributional Parameters:
##       Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma     0.00      0.00     0.00     0.00   NA       NA       NA
## 
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
#covars
fit_bayes_covars <- brm(male_d|se(se) ~ 1 + Sample + Tests + Race + Model,
                 data = d,
                 iter = 4000)
## Compiling Stan program...
## Trying to compile a simple C file
## Running /usr/lib/R/bin/R CMD SHLIB foo.c
## using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
## gcc -I"/usr/share/R/include" -DNDEBUG   -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/Rcpp/include/"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/unsupported"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/BH/include" -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/src/"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppParallel/include/"  -I"/home/emil/R/x86_64-pc-linux-gnu-library/4.4/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DUSE_STANC3 -DSTRICT_R_HEADERS  -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION  -D_HAS_AUTO_PTR_ETC=0  -include '/home/emil/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/stan/math/prim/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1       -fpic  -g -O2 -ffile-prefix-map=/build/r-base-6tgf7J/r-base-4.4.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c foo.c -o foo.o
## In file included from /home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/Eigen/Core:19,
##                  from /home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/Eigen/Dense:1,
##                  from /home/emil/R/x86_64-pc-linux-gnu-library/4.4/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22,
##                  from <command-line>:
## /home/emil/R/x86_64-pc-linux-gnu-library/4.4/RcppEigen/include/Eigen/src/Core/util/Macros.h:679:10: fatal error: cmath: No such file or directory
##   679 | #include <cmath>
##       |          ^~~~~~~
## compilation terminated.
## make: *** [/usr/lib/R/etc/Makeconf:195: foo.o] Error 1
## Start sampling
## 
## SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 1).
## Chain 1: 
## Chain 1: Gradient evaluation took 1.4e-05 seconds
## Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.14 seconds.
## Chain 1: Adjust your expectations accordingly!
## Chain 1: 
## Chain 1: 
## Chain 1: Iteration:    1 / 4000 [  0%]  (Warmup)
## Chain 1: Iteration:  400 / 4000 [ 10%]  (Warmup)
## Chain 1: Iteration:  800 / 4000 [ 20%]  (Warmup)
## Chain 1: Iteration: 1200 / 4000 [ 30%]  (Warmup)
## Chain 1: Iteration: 1600 / 4000 [ 40%]  (Warmup)
## Chain 1: Iteration: 2000 / 4000 [ 50%]  (Warmup)
## Chain 1: Iteration: 2001 / 4000 [ 50%]  (Sampling)
## Chain 1: Iteration: 2400 / 4000 [ 60%]  (Sampling)
## Chain 1: Iteration: 2800 / 4000 [ 70%]  (Sampling)
## Chain 1: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 1: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 1: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 1: 
## Chain 1:  Elapsed Time: 0.165 seconds (Warm-up)
## Chain 1:                0.113 seconds (Sampling)
## Chain 1:                0.278 seconds (Total)
## Chain 1: 
## 
## SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 2).
## Chain 2: 
## Chain 2: Gradient evaluation took 4e-06 seconds
## Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds.
## Chain 2: Adjust your expectations accordingly!
## Chain 2: 
## Chain 2: 
## Chain 2: Iteration:    1 / 4000 [  0%]  (Warmup)
## Chain 2: Iteration:  400 / 4000 [ 10%]  (Warmup)
## Chain 2: Iteration:  800 / 4000 [ 20%]  (Warmup)
## Chain 2: Iteration: 1200 / 4000 [ 30%]  (Warmup)
## Chain 2: Iteration: 1600 / 4000 [ 40%]  (Warmup)
## Chain 2: Iteration: 2000 / 4000 [ 50%]  (Warmup)
## Chain 2: Iteration: 2001 / 4000 [ 50%]  (Sampling)
## Chain 2: Iteration: 2400 / 4000 [ 60%]  (Sampling)
## Chain 2: Iteration: 2800 / 4000 [ 70%]  (Sampling)
## Chain 2: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 2: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 2: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 2: 
## Chain 2:  Elapsed Time: 0.141 seconds (Warm-up)
## Chain 2:                0.112 seconds (Sampling)
## Chain 2:                0.253 seconds (Total)
## Chain 2: 
## 
## SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 3).
## Chain 3: 
## Chain 3: Gradient evaluation took 4e-06 seconds
## Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds.
## Chain 3: Adjust your expectations accordingly!
## Chain 3: 
## Chain 3: 
## Chain 3: Iteration:    1 / 4000 [  0%]  (Warmup)
## Chain 3: Iteration:  400 / 4000 [ 10%]  (Warmup)
## Chain 3: Iteration:  800 / 4000 [ 20%]  (Warmup)
## Chain 3: Iteration: 1200 / 4000 [ 30%]  (Warmup)
## Chain 3: Iteration: 1600 / 4000 [ 40%]  (Warmup)
## Chain 3: Iteration: 2000 / 4000 [ 50%]  (Warmup)
## Chain 3: Iteration: 2001 / 4000 [ 50%]  (Sampling)
## Chain 3: Iteration: 2400 / 4000 [ 60%]  (Sampling)
## Chain 3: Iteration: 2800 / 4000 [ 70%]  (Sampling)
## Chain 3: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 3: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 3: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 3: 
## Chain 3:  Elapsed Time: 0.138 seconds (Warm-up)
## Chain 3:                0.118 seconds (Sampling)
## Chain 3:                0.256 seconds (Total)
## Chain 3: 
## 
## SAMPLING FOR MODEL 'anon_model' NOW (CHAIN 4).
## Chain 4: 
## Chain 4: Gradient evaluation took 4e-06 seconds
## Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.04 seconds.
## Chain 4: Adjust your expectations accordingly!
## Chain 4: 
## Chain 4: 
## Chain 4: Iteration:    1 / 4000 [  0%]  (Warmup)
## Chain 4: Iteration:  400 / 4000 [ 10%]  (Warmup)
## Chain 4: Iteration:  800 / 4000 [ 20%]  (Warmup)
## Chain 4: Iteration: 1200 / 4000 [ 30%]  (Warmup)
## Chain 4: Iteration: 1600 / 4000 [ 40%]  (Warmup)
## Chain 4: Iteration: 2000 / 4000 [ 50%]  (Warmup)
## Chain 4: Iteration: 2001 / 4000 [ 50%]  (Sampling)
## Chain 4: Iteration: 2400 / 4000 [ 60%]  (Sampling)
## Chain 4: Iteration: 2800 / 4000 [ 70%]  (Sampling)
## Chain 4: Iteration: 3200 / 4000 [ 80%]  (Sampling)
## Chain 4: Iteration: 3600 / 4000 [ 90%]  (Sampling)
## Chain 4: Iteration: 4000 / 4000 [100%]  (Sampling)
## Chain 4: 
## Chain 4:  Elapsed Time: 0.142 seconds (Warm-up)
## Chain 4:                0.108 seconds (Sampling)
## Chain 4:                0.25 seconds (Total)
## Chain 4:
summary(fit_bayes_covars)
##  Family: gaussian 
##   Links: mu = identity; sigma = identity 
## Formula: male_d | se(se) ~ 1 + Sample + Tests + Race + Model 
##    Data: d (Number of observations: 16) 
##   Draws: 4 chains, each with iter = 4000; warmup = 2000; thin = 1;
##          total post-warmup draws = 8000
## 
## Regression Coefficients:
##              Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept       -0.08      0.02    -0.12    -0.05 1.00     6634     6143
## SampleNLSY97    -0.07      0.02    -0.11    -0.03 1.00     4975     4947
## SampleTalent    -0.04      0.02    -0.08     0.01 1.00     3623     4431
## Tests            0.03      0.00     0.02     0.03 1.00     8081     7488
## RaceBlack       -0.25      0.03    -0.31    -0.20 1.00     3836     4662
## RaceWhite       -0.04      0.02    -0.09    -0.00 1.00     3926     4289
## ModelHOF        -0.29      0.01    -0.30    -0.27 1.00     6235     5600
## 
## Further Distributional Parameters:
##       Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma     0.00      0.00     0.00     0.00   NA       NA       NA
## 
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

Meta

#versions
write_sessioninfo()
## R version 4.4.2 (2024-10-31)
## Platform: x86_64-pc-linux-gnu
## Running under: Linux Mint 21.1
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## 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       
## 
## time zone: Europe/Brussels
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] patchwork_1.2.0       extraDistr_1.10.0     brms_2.22.0          
##  [4] Rcpp_1.0.13           metafor_4.6-0         numDeriv_2016.8-1.1  
##  [7] metadat_1.2-0         Matrix_1.7-2          kirkegaard_2025-03-07
## [10] psych_2.4.6.26        assertthat_0.2.1      weights_1.0.4        
## [13] Hmisc_5.1-3           magrittr_2.0.3        lubridate_1.9.3      
## [16] forcats_1.0.0         stringr_1.5.1         dplyr_1.1.4          
## [19] purrr_1.0.2           readr_2.1.5           tidyr_1.3.1          
## [22] tibble_3.2.1          ggplot2_3.5.1         tidyverse_2.0.0      
## 
## loaded via a namespace (and not attached):
##   [1] mathjaxr_1.6-0       tensorA_0.36.2.1     rstudioapi_0.16.0   
##   [4] jsonlite_1.8.8       shape_1.4.6.1        jomo_2.7-6          
##   [7] farver_2.1.2         nloptr_2.1.1         rmarkdown_2.28      
##  [10] ragg_1.3.2           vctrs_0.6.5          minqa_1.2.8         
##  [13] base64enc_0.1-3      htmltools_0.5.8.1    distributional_0.5.0
##  [16] broom_1.0.6          Formula_1.2-5        mitml_0.4-5         
##  [19] sass_0.4.9           StanHeaders_2.32.10  bslib_0.8.0         
##  [22] htmlwidgets_1.6.4    plyr_1.8.9           cachem_1.1.0        
##  [25] lifecycle_1.0.4      iterators_1.0.14     pkgconfig_2.0.3     
##  [28] R6_2.5.1             fastmap_1.2.0        digest_0.6.37       
##  [31] colorspace_2.1-1     ps_1.7.7             textshaping_0.4.0   
##  [34] labeling_0.4.3       fansi_1.0.6          timechange_0.3.0    
##  [37] gdata_3.0.0          abind_1.4-5          compiler_4.4.2      
##  [40] bit64_4.0.5          withr_3.0.1          htmlTable_2.4.3     
##  [43] backports_1.5.0      inline_0.3.19        highr_0.11          
##  [46] QuickJSR_1.4.0       pkgbuild_1.4.4       pan_1.9             
##  [49] MASS_7.3-64          gtools_3.9.5         loo_2.8.0           
##  [52] tools_4.4.2          foreign_0.8-88       nnet_7.3-20         
##  [55] glue_1.7.0           callr_3.7.6          nlme_3.1-167        
##  [58] grid_4.4.2           checkmate_2.3.2      cluster_2.1.8       
##  [61] reshape2_1.4.4       generics_0.1.3       gtable_0.3.5        
##  [64] tzdb_0.4.0           data.table_1.16.0    hms_1.1.3           
##  [67] utf8_1.2.4           foreach_1.5.2        pillar_1.9.0        
##  [70] vroom_1.6.5          posterior_1.6.0      splines_4.4.2       
##  [73] lattice_0.22-5       survival_3.8-3       bit_4.0.5           
##  [76] tidyselect_1.2.1     knitr_1.48           gridExtra_2.3       
##  [79] stats4_4.4.2         xfun_0.47            bridgesampling_1.1-2
##  [82] matrixStats_1.4.1    rstan_2.32.6         stringi_1.8.4       
##  [85] yaml_2.3.10          boot_1.3-31          evaluate_0.24.0     
##  [88] codetools_0.2-19     cli_3.6.3            RcppParallel_5.1.9  
##  [91] rpart_4.1.24         systemfonts_1.1.0    munsell_0.5.1       
##  [94] processx_3.8.4       jquerylib_0.1.4      coda_0.19-4.1       
##  [97] parallel_4.4.2       rstantools_2.4.0     bayesplot_1.11.1    
## [100] Brobdingnag_1.2-9    lme4_1.1-35.5        glmnet_4.1-8        
## [103] mvtnorm_1.2-6        scales_1.3.0         crayon_1.5.3        
## [106] rlang_1.1.4          mnormt_2.1.1         mice_3.16.0
#write data to file for reuse
#d %>% write_rds("data/data_for_reuse.rds")

#OSF
if (F) {
  library(osfr)
  
  #login
  osf_auth(readr::read_lines("~/.config/osf_token"))
  
  #the project we will use
  osf_proj = osf_retrieve_node("https://osf.io/XXX/")
  
  #upload all files in project
  #overwrite existing (versioning)
  osf_upload(
    osf_proj,
    path = c("data", "figures", "papers", "notebook.Rmd", "notebook.html", "sessions_info.txt"), 
    conflicts = "overwrite"
    )
}