jomulder / BFpack

BFpack can be used for testing statistical hypotheses using the Bayes factor, a Bayesian criterion originally developed by sir Harold Jeffreys.
https://bfpack.info/
14 stars 4 forks source link

Contradictory BFs with glm #29

Closed anikalowe closed 3 months ago

anikalowe commented 6 months ago

I'm using the following glm: glm(formula = VAR ~ 1 + SLEEP, family = "binomial", data = DATA) which yields the following coefficients: Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.45199 0.48349 0.935 0.3499
SLEEP3 0.05884 0.70741 0.083 0.9337
SLEEP2 1.33977 0.72487 1.848 0.0646 .

I then test the following hypotheses using the BFpack function BF: 1) BF(glm1, hypothesis = 'SLEEP2 = Intercept') Evidence matrix (Bayes factors): H1 H2 H1 1.000 5.711 H2 0.175 1.000

2) BF(glm1, hypothesis = 'SLEEP3 = Intercept') Evidence matrix (Bayes factors): H1 H2 H1 1.000 7.384 H2 0.135 1.000

3) BF(glm1, hypothesis = 'SLEEP2 > SLEEP3') Evidence matrix (Bayes factors): H1 H2 H1 1.000 22.127 H2 0.045 1.000

This clearly doesn't make sense. The coefficients from the glm suggest an effect of SLEEP2. BF model 3) makes sense regarding this, although the BF is huge. BF model 2) also fits with the glm. BF model 1) however makes no sense. How can there be evidence for SLEEP2 being equal to the Intercept, when there is also so much evidence for the Intercept being equal to SLEEP3 and SLEEP2 being way larger than SLEEP3.

Do you have any leads on how these illogical and contradictory effects come to be?

Thank you very much. Anika

jomulder commented 3 months ago

I do not really see any real contradictions in the results. I plotted the normal approximations of the posteriors based on the MLE and the standard errors from the glm fit. Based on these plots I would also say that the relative evidence of the intercept and SLEEP2 being equal is comparable with the evidence of SLEEP3 being equal to the intercept as the estimates of SLEEP2 and SLEEP3 are on a comparable distance from the intercept, and there is sufficient overlap of the posteriors due to relatively large standard errors resulting in some mild evidence for equality. About your observation that the estimates indicate that SLEEP2 is unequal to zero and that SLEEP3 is equal to zero, note that the hypotheses that you are considering are not testing whether the effects of SLEEP2 and SLEEP3 are equal to zero or not but rather whether they are close to the intercept (having value .45 with uncertainty .48), and both (again) lie roughly equally away from the intercept. So I think the results make sense. Finally it is true that 'SLEEP2 > SLEEP3' gets a lot of evidence against its complement (i.e., "SLEEP2<SLEEP3") which makes sense given these estimates. However if an equality hypothesis would be added so that 'SLEEP2 > SLEEP3' would be tested against 'SLEEP2 = SLEEP3', then I would expect that the evidence for 'SLEEP2 > SLEEP3' would be considerable less.