bridge: Bridge sampling

Description Usage Arguments Details Value Examples

Description

Evaluates marginal likelihood of Stan model at the posterior mean using bridge sampling

Usage

1
2
3
bridge(ikde.model, burn.iter = 1000, sample.iter = 1000, tol = 1e-08,
  control = NULL, refresh = NULL, display.output = FALSE,
  show.trace = FALSE)

Arguments

ikde.model

An object of class ikde.model, does not necessarily have to be built

burn.iter

Number of warmup iterations

sample.iter

Number of sampling iterations

control

Control parameters used in the Markov chain. See ?rstan::stan for details.

refresh

How frequently should progress be reported, in numbers of iterations

display.output

Boolean indicating whether output from rstan::stan should be printed

show.trace

Boolean indicating whether to show trace plots

Details

Uses evaluate.likelihood, evaluate.priors, and a custom bridge sampling routine to estimate marginal likelihood.

Value

A real number indicating value of the log-marginal-likelihood at the posterior mean

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
data(lm.generated)

X <- lm.generated$X
y <- lm.generated$y

data <- list(N = list(type = "int<lower=1>", dim = 1, value = nrow(X)),
             k = list(type = "int<lower=1>", dim = 1, value = ncol(X)),
             X = list(type = "matrix", dim = "[N, k]", value = X),
             y = list(type = "vector", dim = "[N]", value = y))
parameters <- list(beta = list(type = "vector", dim = "[k]"),
                   sigma_sq = list(type = "real<lower=0>", dim = 1))
model <- list(priors = c("beta ~ normal(0, 10);",
                         "sigma_sq ~ inv_gamma(1, 1);"),
              likelihood = c("y ~ normal(X * beta, sqrt(sigma_sq));"))

ikde.model <- define.model(data, parameters, model)

# Only an estimation, may not exactly match presented result
bridge(ikde.model)
# [1] -389.0141

tkmckenzie/ikde documentation built on May 13, 2019, 9:53 p.m.