richarddmorey / BayesFactor

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

ttest sampler does not respect mu parameter #102

Open richarddmorey opened 7 years ago

richarddmorey commented 7 years ago

via email:

Here is some code that should illustrate my question:

IQ<-rnorm(10000,100,15)
bf<-ttestBF(IQ, mu=100, posterior=TRUE, iterations=1000)
summary(bf)

The posterior of delta has a mean above 6.5 (~100/15). When I subtract 100 from the IQ scores and use mu=0, the posterior distribution of delta looks okay.

ghost commented 7 years ago

Probably a related issue - posterior() in version 0.9.12-4 produces wrong posterior means - as if they were inflated by a constant. The last stable version 0.9.12-2 doesn't have that issue.

richarddmorey commented 7 years ago

could you post some code to demonstrate?

ghost commented 7 years ago

Hi Richard,

with the exactly same data and code, posterior() in versions 0.9.12-4 and 0.9.12-2 yield different values. BFs and posterior probabilities stay the same.

Here is a snippet of the code I'm using, with generated data. Version 0.9.12-2: http://rpubs.com/ivanropovik/275528 Version 0.9.12-4: http://rpubs.com/ivanropovik/275527

As you can see, one of the posteriors is 0.084, the other 0.016. For our real data, the difference is much more pronounced, like 0.02 vs 7.78, with the latter value (version 0.9.12-4) not just being way off, but physiologically impossible.

richarddmorey commented 7 years ago

Did you notice that the regression posteriors now include the intercept? I think you're looking at different parameters here.

ghost commented 7 years ago

Oh yes, very sorry for the confusion! I should have looked at that more carefully. Thank you for the clarification.