Description Usage Arguments Details Examples
Computes the Bayes factor for comparison of 2 blm
objects.
1 | bayes_factor(model1, model2)
|
model1 |
first |
model2 |
second |
Returns the ratio of the probability of model1 divided by the probability of model2. A value of K > 1 means that M1 is more strongly supported by the data under consideration than M2 (https://en.wikipedia.org/wiki/Bayes_factor). Wikipedia mentions additional scales for interpretation, ie by Harold Jeffreys:
K < 1: supports model2
K > 10: strong support for model1
K > 100: decisive support for model1
. An alternative table, widely cited, is provided by Kass and Raftery.
K 1-3: not worth more than a bare mention
K 3-20: positive support for model1
K 20-150: strong support for model1
K >150: very strong support for model1
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | set.seed(1)
x <- seq(-10,10,.1)
b <- 0.3
w0 <- 0.2 ; w1 <- 3 ; w2 <- 10
y <- rnorm(201, mean = w0 + w1 * x + w2 *sin(x), sd = sqrt(1/b))
mod1 <- blm(y ~ x + sin(x))
pblm(mod1) ## -886.4801 this is the log-probability (log=TRUE by default)
#another model removing the sinus term
mod2 <- blm(y ~ x)
pblm(mod2) ## -891.0581
bayes_factor(mod1, mod2) #97.31074 #strong support for mod1 over mod2
mod3 <- blm(y ~ x + 0)
pblm(mod3) ## -891.842
bayes_factor(mod1, mod3) #213.128 #very strong support for mod1 over mod3
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.