# Bayesian hierarchical model of reporting report_propensity, implemented in stan

rm(list=ls())
library(rstan)
library(Hmisc)
library(rstanarm)
library(loo)
library(data.table)
library(stargazer)

setwd('~/research/gTiger/Article_citsci/open_code')
source('settings/parameters.r')
source('settings/paths.r')
source('settings/functions.r')

setwd(path_to_data)

ncores = 4

rstan_options(auto_write = TRUE)
options(mc.cores = ncores)

stan_settings = list(iterations=1000, chains=options()$mc.cores, warmup=500)

invstd2 = function(x, d) (x/(2*sd(d, na.rm=T)))

D = readRDS('reporting_propensity_resampled.Rds')

D$trials = 1

t_models_table = readRDS('reporting_propensity_model_comparison_table.Rds')

stargazer(t_models_table, type="html", summary=F, digits=2, rownames=F, out=paste0(path_to_figures, "reporting_propsensity_model_selection.html"))
