# How to include Cohen's D from Meta-Analysis into JAGS/BUGS mean difference model

I was wondering if anyone knew of a way to use Cohen's D (and Standard Error) as an informed prior while building a BUGS model (to be tested in JAGS through R) that compares the mean difference between two groups.

I was able to specify and run a model with uninformed priors just fine, but wanted to see if I could add the information from a meta-analysis. The uninformed model is below; thank you for sharing your thoughts and expertise.

#Non-Informative Prior Model
library(R2jags)
null <- "model {
#Priors
mu1 ~ dunif(-1e10,1e10)
mu2 ~ dunif(-1e10,1e10)
tau1 ~ dgamma(0.001,0.001)
tau2 ~ dgamma(0.001,0.001)

#Likelihood
for (i in 1:n1){
y1[i] ~ dnorm(mu1, tau1)
}
for (j in 1:n2){
y2[j] ~ dnorm(mu2, tau2)
}

#Mean Difference
delta <- mu1 - mu2
cohenD <- delta/sqrt(((n2-1)*sqrt(tau1^(-1))^2/(n2+n1-2))+((n1-1)*sqrt(tau2^(-1))^2/(n2+n1-2)))
}"

model<-textConnection(null)
jags.n <- jags(model.file = model,data = data,
parameters.to.save = c("cohenD"), n.iter = 1000)


I never found an answer on Google, so I kept on experimenting until I found my own solution that works. It turns out that you do not edit the model, but rather the data. If you z-score all of your data using your reference group's mean and pooled standard deviation, the mean of your focal group is actually your Cohen's d effect size.

Once the data is in this format, it is very easy to edit the model to contain a prior Cohen's d that was previously found on a meta-analysis.

alt <- "model {
#Informed Priors
mu1 ~ dnorm(.36,15.29584) #.36 is previously found Cohen's d
mu2 ~ dnorm(0,15.29584) # reference group mean fixed to 0
tau1 ~ dnorm(1,100) # standard deviations are 1 because of z scoring
tau2 ~ dnorm(1,100)

#Likelihood
for (i in 1:n1){
y1[i] ~ dnorm(mu1, tau1)
}
for (j in 1:n2){
y2[j] ~ dnorm(mu2, tau2)
}
}"


Hope someone finds this helpful at some point in the future.