Learn R Programming

BayesFluxR (version 0.1.3)

posterior_predictive: Draw from the posterior predictive distribution

Description

Draw from the posterior predictive distribution

Usage

posterior_predictive(bnn, posterior_samples, x = NULL)

Value

A matrix whose columns are the posterior predictive draws.

Arguments

bnn

a BNN obtained using link{BNN}

posterior_samples

a vector or matrix containing posterior samples. This can be obtained using mcmc, or bayes_by_backprop or find_mode.

x

input variables. If `NULL` (default), training values will be used.

Examples

Run this code
if (FALSE) {
  ## Needs previous call to `BayesFluxR_setup` which is time
  ## consuming and requires Julia and BayesFlux.jl
  BayesFluxR_setup(installJulia=TRUE, seed=123)
  net <- Chain(Dense(5, 1))
  like <- likelihood.feedforward_normal(net, Gamma(2.0, 0.5))
  prior <- prior.gaussian(net, 0.5)
  init <- initialise.allsame(Normal(0, 0.5), like, prior)
  x <- matrix(rnorm(5*100), nrow = 5)
  y <- rnorm(100)
  bnn <- BNN(x, y, like, prior, init)
  sampler <- sampler.SGLD()
  ch <- mcmc(bnn, 10, 1000, sampler)
  pp <- posterior_predictive(bnn, ch$samples)
}

Run the code above in your browser using DataLab