inclusion: Inclusion Bayes Factor

Description Usage Arguments Examples

View source: R/inclusion.R

Description

Computes the inclusion Bayes factor for two sets of models (e.g., A={M1,M2} vs. B={M3,M4}).

Usage

1
inclusion(logml, include = 1, prior = 1)

Arguments

logml

a vector with log-marginal likelihoods. Alternatively, a list with meta-analysis models (fitted via meta_random or meta_fixed).

include

integer vector which models to include in inclusion Bayes factor/posterior probability. If only two marginal likelihoods/meta-analyses are supplied, the inclusion Bayes factor is identical to the usual Bayes factor BF_{M1,M2}. One can include models depending on the names of the models (such as "random_H1") by providing a character value, for instance: include="H1" (all H1 vs. all H0 models) or include="random" (all random- vs. all fixed-effects models).

prior

prior probabilities over models (possibly unnormalized). For instance, if the first model is as likely as models 2, 3 and 4 together: prior = c(3,1,1,1). The default is a discrete uniform distribution over models.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#### Example with simple Normal-distribution models
# generate data:
x <- rnorm(50)

# Model 1: x ~ Normal(0,1)
logm1 <- sum(dnorm(x, log = TRUE))
# Model 2: x ~ Normal(.2, 1)
logm2 <- sum(dnorm(x, mean = .2, log = TRUE))
# Model 3: x ~ Student-t(df=2)
logm3 <- sum(dt(x, df = 2, log = TRUE))

# BF: Correct (Model 1) vs. misspecified (2 & 3)
inclusion(c(logm1, logm2, logm3), include = 1)

Example output

Loading required package: Rcpp
Warning message:
In file(con, "r") : cannot open file '/proc/stat': Permission denied
### Inclusion Bayes factor ###
    Model Prior Posterior included
1 Model 1 0.333   0.98326        x
2 Model 2 0.333   0.01497         
3 Model 3 0.333   0.00177         

  Inclusion posterior probability: 0.983 
  Inclusion Bayes factor: 117.507

metaBMA documentation built on March 17, 2021, 9:06 a.m.