bayes_factor: Bayes Factor

Description Usage Arguments Details Examples

Description

Computes the Bayes factor for comparison of 2 blm objects.

Usage

1
bayes_factor(model1, model2)

Arguments

model1

first blm object

model2

second blm object

Details

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:

. An alternative table, widely cited, is provided by Kass and Raftery.

.

Examples

 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

manschmi/blmr documentation built on May 21, 2019, 11:25 a.m.