richarddmorey / BayesFactor

BayesFactor R package for Bayesian data analysis with common statistical models.
https://richarddmorey.github.io/BayesFactor/
132 stars 49 forks source link

Contrast from posterior estimates #68

Open wdonald1985 opened 8 years ago

wdonald1985 commented 8 years ago

Although I find the Bayes factor interesting, I am most interested in uncertainty and effect size. When using the lmBF function for the following code: bayesBF <- lmBF(len ~ dose, iterations = 10000, data = toothgrowth), the output does does not tell me which groups differ, by how much, and the uncertainty (credible intervals). I notice that I have mu and estimates for all of the levels of dose. Can I add the posterior estimates for dose to mu to get the mcmc mean for each level of dose. Then can I subtract these means, for example, dose.5 - dose.1 to get the contrasts?

When obtaining 10000 posterior estimates, I get the following from the methods I described. variable, empirical mean, mcmc mean Dose 0.5, 10.61, 10.78 Dose 1.0, 19.73, 19.72 Does 2.0, 26.1, 25.92

at all levels of Dose: empirical 18.813, mu = 18.812

Lastly, I saw the post about order constraints, but that still does not make it clear how I can calculate contrasts for specific comparisons.

Thanks in advance, Donny

richarddmorey commented 8 years ago

Can I add the posterior estimates for dose to mu to get the mcmc mean for each level of dose. Then can I subtract these means, for example, dose.5 - dose.1 to get the contrasts?

Yes, you can do this. Note though: if you just care about the contrasts, you don't need to add the mean back in, because if you're going to just subtract them then the mean just subtracts right back out. You just need the difference between the effects themselves.

wdonald1985 commented 8 years ago

When using the random option in lmBF, can I also use the same approach for interactions? Thank you for the quick reply!

richarddmorey commented 8 years ago

I'm not sure what you mean.

wdonald1985 commented 8 years ago

When there is an interaction, can I subtract posterior estimates of the interactions to determine the difference between interactions.

richarddmorey commented 8 years ago

You mean, eg, if there is a three-way interaction, can you take the (say) two two-way interactions and subtract them?

wdonald1985 commented 8 years ago

Yes. As an aside, I will be starting graduate school this fall at UC Davis where I will be focusing on the neuroendocrinology of social bonding in prarie voles and titi monkeys. As an undergraduate, I completed a minor in statistics, all NHST, but am attempting to train myself in Bayesian methods. In my field, journals often ask for effect sizes such as Cohen's d. As such, I am trying to use RSTAN or use a package such as yours for models where I get mean estimates and estimates of sigma for all variables or levels of a factor. In lmbf, for example, I was considereding obtaining estimates of mu, subtraction to get mean differences, and dividing by the empirical pooled sd. Or just placing a prior that would shrink estimates toward zero and conduct several t.testbf's.

I guess my main concern is that, although I have been reading extensively about Bayesian statistics (DBDA and Rethinking), my adviser and most people in my field have not. As such, ensuring what I am doing is correct is very, very important.

Thank you for the responses and I am sure that I will figure it all out soon!

richarddmorey commented 8 years ago

The three-way interaction parameters itself contain the information, don't they? Unless I'm misunderstanding what you want.