######################################################################################################## # Script for article "Internal conceptual replications do not increase independent replication success"# # Submitted to Psychonomic Bulletin & Review # # Responsible for this file: R. Kunert (rikunert@gmail.com) # ######################################################################################################## #setwd(choose.dir()) # source functions if(!require(devtools)){install.packages('devtools')} #RPP functions library(devtools) source_url('https://raw.githubusercontent.com/FredHasselman/toolboxR/master/C-3PR.R') in.IT(c('ggplot2','RColorBrewer','lattice','gridExtra','plyr','dplyr','httr','extrafont')) if(!require(BayesFactor)){install.packages('BayesFactor')} #Bayesian analysis library(BayesFactor) if(!require(BEST)){install.packages('BEST')} #Bayesian estimation of posterior mean and 95% Credible Interval for t-tests library(BEST) ########################################################################################################################################################################################## #----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #Figures 1: visualising distributions #get raw data from OSF website info <- GET('https://osf.io/fgjvw/?action=download', write_disk('rpp_data.csv', overwrite = TRUE)) #downloads data file from the OSF RPPdata <- read.csv("rpp_data.csv")[1:167, ] colnames(RPPdata)[1] <- "ID" # Change first column name to ID to be able to load #prepare IDs for internally replicated effects and non-internally replicated effects #for studies with r reported idIntRepl_r <- RPPdata$ID[!is.na(RPPdata$T_r..O.) & !is.na(RPPdata$T_r..R.) & RPPdata$Successful.conceptual.replications..O. > 0] idNotIntRepl_r <- RPPdata$ID[!is.na(RPPdata$T_r..O.) & !is.na(RPPdata$T_r..R.) & RPPdata$Successful.conceptual.replications..O. == 0] #for studies with significant p reported in original publication idIntRepl_sigp <- RPPdata$ID[!is.na(RPPdata$T_pval_USE..O.) & !is.na(RPPdata$T_pval_USE..R.) & RPPdata$T_sign_O == 1 & RPPdata$Successful.conceptual.replications..O. > 0] idNotIntRepl_sigp <- RPPdata$ID[!is.na(RPPdata$T_pval_USE..O.) & !is.na(RPPdata$T_pval_USE..R.) & RPPdata$T_sign_O == 1 & RPPdata$Successful.conceptual.replications..O. == 0] # Get ggplot2 themes predefined in C-3PR mytheme <- gg.theme("clean") # VQP PANEL A: p-value ------------------------------------------------- dat_vis <- data.frame(ReplicationPValue = as.numeric(c(RPPdata$T_pval_USE..R.[idIntRepl_sigp], RPPdata$T_pval_USE..R.[idNotIntRepl_sigp])), grp=factor(c(rep("Internally Replicated Effects",times=length(idIntRepl_sigp)), rep("Internally Unreplicated Effects",times=length(idNotIntRepl_sigp))))) # Create some variables for plotting dat_vis$grp <- as.numeric(dat_vis$grp) probs <- seq(0,1,.25) # Get p-value quantiles and frequencies from data qtiles <- ldply(unique(dat_vis$grp), function(gr) quantile(round(dat_vis$ReplicationPValue[dat_vis$grp==gr],digits=4),probs,na.rm=T,type=3)) freqs <- ldply(unique(dat_vis$grp), function(gr) table(cut(dat_vis$ReplicationPValue[dat_vis$grp==gr],breaks=qtiles[gr,],na.rm=T,include.lowest=T,right=T))) labels <- sapply(unique(dat_vis$grp), function(gr)levels(cut(round(dat_vis$ReplicationPValue[dat_vis$grp==gr],digits=4), breaks = qtiles[gr,],na.rm=T,include.lowest=T,right=T))) # Get regular violinplot using package ggplot2 A <- ggplot(dat_vis,aes(x=grp,y=ReplicationPValue)) + geom_violin(aes(group=grp),scale="width",color="grey30",fill="grey30",trim=T,adjust=.7) # Cut at quantiles using vioQtile() in C-3PR A0 <- vioQtile(A,qtiles,probs) # Garnish (I still don't know what this word means!) A <- A0 + geom_hline(aes(yintercept=.05),linetype=2) + xlab("") + ylab("Independent Replication p-value") + xlim("Internal\nReplication \nPresent", "Internal\n Replication\nAbsent") + mytheme + theme(axis.text.x = element_text(size=12)) # VQP PANEL B: reduction in effect size ------------------------------------------------- #restructure data in data frame dat_vis <- data.frame(EffectSizeDifference = as.numeric(c(c(RPPdata$T_r..R.[idIntRepl_r]) - c(RPPdata$T_r..O.[idIntRepl_r]), c(RPPdata$T_r..R.[idNotIntRepl_r]) - c(RPPdata$T_r..O.[idNotIntRepl_r]))), grp=factor(c(rep("Internally Replicated Effects",times=length(idIntRepl_r)), rep("Internally Unreplicated Effects",times=length(idNotIntRepl_r))))) # Create some variables for plotting dat_vis$grp <- as.numeric(dat_vis$grp) probs <- seq(0,1,.25) # Get effect size difference quantiles and frequencies from data qtiles <- ldply(unique(dat_vis$grp), function(gr) quantile(round(dat_vis$EffectSizeDifference[dat_vis$grp==gr],digits=4),probs,na.rm=T,type=3)) freqs <- ldply(unique(dat_vis$grp), function(gr) table(cut(dat_vis$EffectSizeDifference[dat_vis$grp==gr],breaks=qtiles[gr,],na.rm=T,include.lowest=T,right=T))) labels <- sapply(unique(dat_vis$grp), function(gr)levels(cut(round(dat_vis$EffectSizeDifference[dat$grp==gr],digits=4), breaks = qtiles[gr,],na.rm=T,include.lowest=T,right=T))) # Get regular violinplot using package ggplot2 B <- ggplot(dat_vis,aes(x=grp,y=EffectSizeDifference)) + geom_violin(aes(group=grp),scale="width",color="grey30",fill="grey30",trim=T,adjust=.7) # Cut at quantiles using vioQtile() in C-3PR B0 <- vioQtile(B,qtiles,probs) B <- B0 + xlab("") + ylab("Replicated - Original Effect Size r") + xlim("Internal\nReplication \nPresent", "Internal\n Replication\nAbsent") + mytheme + theme(axis.text.x = element_text(size=12)) #put two plots together multi.PLOT(A,B,cols=2) #I used RStudio's export function with aspect ratio 800 x 400 to save the figure as eps file, then used Adobe Illustrator for saving in different formats ########################################################################################################################################################################################## #----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #Table 1: comparing distributions #How many draws are to be taken from posterior distribution for BF and Credible Interval calculations? The more samples the more precise the estimate and the slower the calculation. draws = 10000 * 10#BayesFactor package standard = 10000 #custom functions for data transformations noninversion <- function(d1, d2) {return(list(d1 + abs(min(c(d1, d2))) + 1, d2 + abs(min(c(d1, d2))) + 1))} inversion <- function(d1, d2) {return(list(-d1 + abs(min(c(-d1, -d2))) + 1, -d2 + abs(min(c(-d1, -d2))) + 1))} #How many studies are considered in this analysis in total?------------------------------------------------- sprintf('In the reproducibility project s dataset, %d original effects were internally, conceptually replicated, %d once, %d twice, %d three times, and %d more than three times', sum(RPPdata$Successful.conceptual.replications..O.[RPPdata$Completion..R. == 1] > 0), sum(RPPdata$Successful.conceptual.replications..O.[RPPdata$Completion..R. == 1] == 1), sum(RPPdata$Successful.conceptual.replications..O.[RPPdata$Completion..R. == 1] == 2), sum(RPPdata$Successful.conceptual.replications..O.[RPPdata$Completion..R. == 1] == 3), sum(RPPdata$Successful.conceptual.replications..O.[RPPdata$Completion..R. == 1] > 3)) #Statistically Significant Replications------------------------------------------------- #calculate counts sum(RPPdata$T_pval_USE..R.[idIntRepl_sigp] <= .05)#How many internally replicated effects 'worked' upon replication? sum(RPPdata$T_pval_USE..R.[idIntRepl_sigp] > .05)#How many internally replicated effects 'did not work' upon replication? sum(RPPdata$T_pval_USE..R.[idNotIntRepl_sigp] <= .05)#How many internally non-replicated effects 'worked' upon replication? sum(RPPdata$T_pval_USE..R.[idNotIntRepl_sigp] > .05)#How many internally non-replicated effects 'did not work' upon replication? #prepare BayesFactor analysis data_contingency = matrix(c(sum(RPPdata$T_pval_USE..R.[idIntRepl_sigp] <= .05),#row 1, col 1 sum(RPPdata$T_pval_USE..R.[idIntRepl_sigp] > .05),#row 2, col 1 sum(RPPdata$T_pval_USE..R.[idNotIntRepl_sigp] <= .05),#row 1, col 2 sum(RPPdata$T_pval_USE..R.[idNotIntRepl_sigp] > .05)),#row 2, col 2 nrow = 2, ncol = 2, byrow = F)#prepare BayesFactor analysis bf = contingencyTableBF(data_contingency, sampleType = "indepMulti", fixedMargin = "cols")#run BayesFactor comparison #sprintf('BF01 = %1.2f', 1/exp(bf@bayesFactor$bf))#alternative hypothesis = independent replication success DIFFERENT (two-sided prediction) depending on presence of internal replication, exponentiate BF10 because stored as natural log, turn into BF01 #calculate one-sided BF chains = posterior(bf, iterations = draws)#draw samples from the posterior consistent = chains[,"pi[1,1]"] / chains[,"pi[*,1]"] > chains[,"pi[1,2]"] / chains[,"pi[*,2]"]#greater proportion of independent replication when internally replicated compared to not internally replicated posteriorProb_consistent = sum(consistent)/draws bf1 = posteriorProb_consistent / (1/2) * exp(bf@bayesFactor$bf)#one-sided posterior / prior odds for x>y * BF two-sided against null sprintf('BF01 = %1.2f', 1/(bf1))#alternative hypothesis = independent replication success greater in case of presence of internal replication #result has been verified with JASPv.0.7.5.Beta2, see file contingencyTable_internalReplication.jasp #Parameter estimation odds_ratio = (chains[,"omega[1,1]"] * chains[,"omega[2,2]"]) / (chains[,"omega[2,1]"] * chains[,"omega[1,2]"]) sprintf('Median = %1.2f [%1.2f; %1.2f]', median(log(odds_ratio)),#Median for increase in independent replication success due to internal replication\n(internally replicated versus not internally replicated) quantile(log(odds_ratio), 0.025),#Lower edge of 95% Credible Interval for increase in independent replication success due to internal replication\n(internally replicated versus not internally replicated) quantile(log(odds_ratio), 0.975))#Higher edge of 95% Credible Interval for increase in independent replication success due to internal replication\n(internally replicated versus not internally replicated) #plot(mcmc(log(odds_ratio)), main = "Log Odds Ratio") #Effect Size Reduction (simple subtraction)------------------------------------------------- #calculate means and standard deviations mean(c(RPPdata$T_r..R.[idIntRepl_r]) - c(RPPdata$T_r..O.[idIntRepl_r]))#mean ES reduction of internally replicated effects sd(c(RPPdata$T_r..R.[idIntRepl_r]) - c(RPPdata$T_r..O.[idIntRepl_r]))#Standard Deviation ES reduction of internally replicated effects mean(c(RPPdata$T_r..R.[idNotIntRepl_r]) - c(RPPdata$T_r..O.[idNotIntRepl_r]))#mean ES reduction of NOT internally replicated effects sd(c(RPPdata$T_r..R.[idNotIntRepl_r]) - c(RPPdata$T_r..O.[idNotIntRepl_r]))#Standard Deviation ES reduction of NOT internally replicated effects #perform BayesFactor analysis (one-sided BF) #problem with normal distribution identified, no transformation performs well, see KunertCodeNormality.R int_repl_r_diff = c(RPPdata$T_r..R.[idIntRepl_r]) - c(RPPdata$T_r..O.[idIntRepl_r])#untransformed not_int_repl_r_diff = c(RPPdata$T_r..R.[idNotIntRepl_r]) - c(RPPdata$T_r..O.[idNotIntRepl_r])#untransformed dat_bf <- data.frame(EffectSizeDifference = as.numeric(c(int_repl_r_diff, not_int_repl_r_diff)), grp=factor(c(rep("Internally Replicated Effects",times=length(idIntRepl_r)), rep("Internally Unreplicated Effects",times=length(idNotIntRepl_r)))))#prepare BayesFactor analysis bf = ttestBF(formula = EffectSizeDifference ~ grp, data = dat_bf, nullInterval=c(0, Inf))#Bayesian t-test to test the difference/similarity between the previous two #null Interval is positive because effect size reduction is expressed negatively, H1 predicts less reduction in case of internally replicated effects sprintf('BF0+ = %1.2f', 1/exp(bf@bayesFactor$bf[1]))#exponentiate BF10 because stored as natural log, turn into BF01 ##Parameter estimation: use BEST package to estimate posterior median and 95% Credible Interval BESTout = BESTmcmc(c(RPPdata$T_r..R.[idIntRepl_r]) - c(RPPdata$T_r..O.[idIntRepl_r]), c(RPPdata$T_r..R.[idNotIntRepl_r]) - c(RPPdata$T_r..O.[idNotIntRepl_r]), priors=NULL, parallel=FALSE) #plotAll(BESTout) sprintf('Median = %1.2f [%1.2f; %1.2f]', median(BESTout$mu1 - BESTout$mu2),#Median for increase in independent replication success due to internal replication\n(internally replicated versus not internally replicated) quantile(BESTout$mu1 - BESTout$mu2, 0.025),#Lower edge of 95% Credible Interval for increase in independent replication success due to internal replication\n(internally replicated versus not internally replicated) quantile(BESTout$mu1 - BESTout$mu2, 0.975))#Higher edge of 95% Credible Interval for increase in independent replication success due to internal replication\n(internally replicated versus not internally replicated) #Effect Size Reduction (Cohen's q)------------------------------------------------- #prepare function to calculate Cohen's q Cohenq <- function(r1, r2) { fis_r1 = 0.5 * (log((1+r1)/(1-r1))) fis_r2 = 0.5 * (log((1+r2)/(1-r2))) fis_r1 - fis_r2 } #calculate means and standard deviations mean(Cohenq(c(RPPdata$T_r..R.[idIntRepl_r]), c(RPPdata$T_r..O.[idIntRepl_r])))#mean ES reduction of internally replicated effects sd(Cohenq(c(RPPdata$T_r..R.[idIntRepl_r]), c(RPPdata$T_r..O.[idIntRepl_r])))#Standard Deviation ES reduction of internally replicated effects mean(Cohenq(c(RPPdata$T_r..R.[idNotIntRepl_r]), c(RPPdata$T_r..O.[idNotIntRepl_r])))#mean ES reduction of NOT internally replicated effects sd(Cohenq(c(RPPdata$T_r..R.[idNotIntRepl_r]), c(RPPdata$T_r..O.[idNotIntRepl_r])))#Standard Deviation ES reduction of NOT internally replicated effects #perform BayesFactor analysis (one-sided BF) #problem with normal distribution identified, no transformation performs well, see KunertCodeNormality.R dat_bf <- data.frame(EffectSizeDifference = as.numeric(c(Cohenq(c(RPPdata$T_r..R.[idIntRepl_r]), c(RPPdata$T_r..O.[idIntRepl_r])), Cohenq(c(RPPdata$T_r..R.[idNotIntRepl_r]), c(RPPdata$T_r..O.[idNotIntRepl_r])))), grp=factor(c(rep("Internally Replicated Effects",times=length(idIntRepl_r)), rep("Internally Unreplicated Effects",times=length(idNotIntRepl_r)))))#prepare BayesFactor analysis bf = ttestBF(formula = EffectSizeDifference ~ grp, data = dat_bf, nullInterval=c(0, Inf))#Bayesian t-test to test the difference/similarity between the previous two #null Interval is positive because effect size reduction is expressed negatively, H1 predicts less reduction in case of internally replicated effects sprintf('BF0+ = %1.2f', 1/exp(bf@bayesFactor$bf[1]))#exponentiate BF10 because stored as natural log, turn into BF01 #Parameter estimation: use BEST package to estimate posterior median and 95% Credible Interval BESTout = BESTmcmc(Cohenq(c(RPPdata$T_r..R.[idIntRepl_r]), c(RPPdata$T_r..O.[idIntRepl_r])), Cohenq(c(RPPdata$T_r..R.[idNotIntRepl_r]), c(RPPdata$T_r..O.[idNotIntRepl_r])), priors=NULL, parallel=FALSE) #plotAll(BESTout) sprintf('Median = %1.2f [%1.2f; %1.2f]', median(BESTout$mu1 - BESTout$mu2),#Median for increase in independent replication success due to internal replication\n(internally replicated versus not internally replicated) quantile(BESTout$mu1 - BESTout$mu2, 0.025),#Lower edge of 95% Credible Interval for increase in independent replication success due to internal replication\n(internally replicated versus not internally replicated) quantile(BESTout$mu1 - BESTout$mu2, 0.975))#Higher edge of 95% Credible Interval for increase in independent replication success due to internal replication\n(internally replicated versus not internally replicated) #Field of study------------------------------------------------- #calculate counts sum(RPPdata$Discipline..O.[idIntRepl_sigp] == 'Cognitive')#How many internally replicated effects were in field of Cognitive Psychology? sum(RPPdata$Discipline..O.[idIntRepl_sigp] == 'Social')#How many internally replicated effects were in field of Social Psychology? sum(RPPdata$Discipline..O.[idNotIntRepl_sigp] == 'Cognitive')#How many Not internally replicated effects were in field of Cognitive Psychology? sum(RPPdata$Discipline..O.[idNotIntRepl_sigp] == 'Social')#How many Not internally replicated effects were in field of Social Psychology? #prepare BayesFactor analysis data_contingency = matrix(c(sum(RPPdata$Discipline..O.[idIntRepl_sigp] == 'Cognitive'),#row 1, col 1 sum(RPPdata$Discipline..O.[idIntRepl_sigp] == 'Social'),#row 2, col 1 sum(RPPdata$Discipline..O.[idNotIntRepl_sigp] == 'Cognitive'),#row 1, col 2 sum(RPPdata$Discipline..O.[idNotIntRepl_sigp] == 'Social')),#row 2, col 2 nrow = 2, ncol = 2, byrow = F)#prepare BayesFactor analysis bf = contingencyTableBF(data_contingency, sampleType = "indepMulti", fixedMargin = "cols")#run BayesFactor comparison #sprintf('BF10 = %1.2f', exp(bf@bayesFactor$bf))#two-sided BF, exponentiate BF10 because stored as natural log #calculate one-sided BF chains = posterior(bf, iterations = draws)#draw samples from the posterior consistent = chains[,"pi[1,1]"] / chains[,"pi[*,1]"] < chains[,"pi[1,2]"] / chains[,"pi[*,2]"]#smaller proportion of cognitive classification when internally replicated compared to not internally replicated posteriorProb_consistent = sum(consistent)/draws bf1 = posteriorProb_consistent / (1/2) * exp(bf@bayesFactor$bf)#one-sided posterior / prior odds for x 0 & RPPdata$Discipline..O. == 'Social'] idNotIntRepl_soc_r <- RPPdata$ID[!is.na(RPPdata$T_r..O.) & !is.na(RPPdata$T_r..R.) & RPPdata$Successful.conceptual.replications..O. == 0 & RPPdata$Discipline..O. == 'Social'] #for studies with significant p reported in original publication idIntRepl_soc_sigp <- RPPdata$ID[!is.na(RPPdata$T_pval_USE..O.) & !is.na(RPPdata$T_pval_USE..R.) & RPPdata$T_sign_O == 1 & RPPdata$Successful.conceptual.replications..O. > 0 & RPPdata$Discipline..O. == 'Social'] idNotIntRepl_soc_sigp <- RPPdata$ID[!is.na(RPPdata$T_pval_USE..O.) & !is.na(RPPdata$T_pval_USE..R.) & RPPdata$T_sign_O == 1 & RPPdata$Successful.conceptual.replications..O. == 0 & RPPdata$Discipline..O. == 'Social'] #Statistically Significant Replications------------------------------------------------- #calculate counts sum(RPPdata$T_pval_USE..R.[idIntRepl_soc_sigp] <= .05)#How many internally replicated effects 'worked' upon replication? sum(RPPdata$T_pval_USE..R.[idIntRepl_soc_sigp] > .05)#How many internally replicated effects 'did not work' upon replication? sum(RPPdata$T_pval_USE..R.[idNotIntRepl_soc_sigp] <= .05)#How many internally non-replicated effects 'worked' upon replication? sum(RPPdata$T_pval_USE..R.[idNotIntRepl_soc_sigp] > .05)#How many internally non-replicated effects 'did not work' upon replication? #prepare BayesFactor analysis data_contingency = matrix(c(sum(RPPdata$T_pval_USE..R.[idIntRepl_soc_sigp] <= .05),#row 1, col 1 sum(RPPdata$T_pval_USE..R.[idIntRepl_soc_sigp] > .05),#row 2, col 1 sum(RPPdata$T_pval_USE..R.[idNotIntRepl_soc_sigp] <= .05),#row 1, col 2 sum(RPPdata$T_pval_USE..R.[idNotIntRepl_soc_sigp] > .05)),#row 2, col 2 nrow = 2, ncol = 2, byrow = F)#prepare BayesFactor analysis bf = contingencyTableBF(data_contingency, sampleType = "indepMulti", fixedMargin = "cols")#run BayesFactor comparison #sprintf('BF01 = %1.2f', 1/exp(bf@bayesFactor$bf))#exponentiate BF10 because stored as natural log, turn into BF01 #calculate one-sided BF chains = posterior(bf, iterations = draws)#draw samples from the posterior consistent = chains[,"pi[1,1]"] / chains[,"pi[*,1]"] > chains[,"pi[1,2]"] / chains[,"pi[*,2]"]#greater proportion of independent replication success when internally replicated compared to not internally replicated posteriorProb_consistent = sum(consistent)/draws bf1 = posteriorProb_consistent / (1/2) * exp(bf@bayesFactor$bf)#one-sided posterior / prior odds for x 0 & RPPdata$Discipline..O. == 'Cognitive'] idNotIntRepl_cog_r <- RPPdata$ID[!is.na(RPPdata$T_r..O.) & !is.na(RPPdata$T_r..R.) & RPPdata$Successful.conceptual.replications..O. == 0 & RPPdata$Discipline..O. == 'Cognitive'] #for studies with significant p reported in original publication idIntRepl_cog_sigp <- RPPdata$ID[!is.na(RPPdata$T_pval_USE..O.) & !is.na(RPPdata$T_pval_USE..R.) & RPPdata$T_sign_O == 1 & RPPdata$Successful.conceptual.replications..O. > 0 & RPPdata$Discipline..O. == 'Cognitive'] idNotIntRepl_cog_sigp <- RPPdata$ID[!is.na(RPPdata$T_pval_USE..O.) & !is.na(RPPdata$T_pval_USE..R.) & RPPdata$T_sign_O == 1 & RPPdata$Successful.conceptual.replications..O. == 0 & RPPdata$Discipline..O. == 'Cognitive'] #Statistically Significant Replications------------------------------------------------- #calculate counts sum(RPPdata$T_pval_USE..R.[idIntRepl_cog_sigp] <= .05)#How many internally replicated effects 'worked' upon replication? sum(RPPdata$T_pval_USE..R.[idIntRepl_cog_sigp] > .05)#How many internally replicated effects 'did not work' upon replication? sum(RPPdata$T_pval_USE..R.[idNotIntRepl_cog_sigp] <= .05)#How many internally non-replicated effects 'worked' upon replication? sum(RPPdata$T_pval_USE..R.[idNotIntRepl_cog_sigp] > .05)#How many internally non-replicated effects 'did not work' upon replication? #prepare BayesFactor analysis data_contingency = matrix(c(sum(RPPdata$T_pval_USE..R.[idIntRepl_cog_sigp] <= .05),#row 1, col 1 sum(RPPdata$T_pval_USE..R.[idIntRepl_cog_sigp] > .05),#row 2, col 1 sum(RPPdata$T_pval_USE..R.[idNotIntRepl_cog_sigp] <= .05),#row 1, col 2 sum(RPPdata$T_pval_USE..R.[idNotIntRepl_cog_sigp] > .05)),#row 2, col 2 nrow = 2, ncol = 2, byrow = F)#prepare BayesFactor analysis bf = contingencyTableBF(data_contingency, sampleType = "indepMulti", fixedMargin = "cols")#run BayesFactor comparison #sprintf('BF01 = %1.2f', 1/exp(bf@bayesFactor$bf))#exponentiate BF10 because stored as natural log, turn into BF01 #calculate one-sided BF chains = posterior(bf, iterations = draws)#draw samples from the posterior consistent = chains[,"pi[1,1]"] / chains[,"pi[*,1]"] > chains[,"pi[1,2]"] / chains[,"pi[*,2]"]#greater proportion of independent replication success when internally replicated compared to not internally replicated posteriorProb_consistent = sum(consistent)/draws bf1 = posteriorProb_consistent / (1/2) * exp(bf@bayesFactor$bf)#one-sided posterior / prior odds for x