#Bayesian t-test Example # In this example we explore differences between males and females # on anxiety female_anx <- c(51, 57, 42, 41, 36, 42) male_anx <- c(34, 38, 37, 27, 29, 33) #Let's start with an ordinary t-test on the data, and we will use #alpha = .05 t.test(male_anx, female_anx) #Next we are going to use the BEST package to run a Bayesian #t-test #There are several "parameters" in the model, #including a mean for each group, a sd for each #mean, a sd for each each group, a sd for each #sd, a degrees of freedom for the distribution shape (t dist), #and a sd for the degrees of freedom #For each parameter we can explicitly define a prior, #or use the default distribution for that prior #First, let's run the model with all the default priors library(BEST) mod1 <- BESTmcmc(male_anx, female_anx, parallel=FALSE) plot(mod1) #Next, let's assume we have prior information regarding #the means of the groups (e.g., from a past study). #Specifically, males have a prior mean of 35 and #females have a prior mean of 45 (both with standard #deviations of 5) #muM is the argument for the mean parameter, muSD #is the argument for the sd of of the mean parameter priors <- list(muM = c(35,45), muSD = c(5,5)) mod2 <- BESTmcmc(male_anx, female_anx, priors=priors, parallel=FALSE) plot(mod2) #Here is a full list of priors, most set to defaults priors2 <- list(muM = c(35,45), muSD = c(5,5), sigmaMode = c(sd(male_anx),sd(female_anx)), sigmaSD = c(sd(male_anx)*5,sd(female_anx)*5), nuMean = 30, nuSD = 5) mod3 <- BESTmcmc(male_anx, female_anx, priors=priors2) plot(mod3)