scrHpd {bfp}R Documentation

Calculate an SCB from a samples matrix

Description

Calculate an SCB from a samples matrix, which minimizes the absolute distances of the contained samples to a mode vector, at each gridpoint. Therefore the SCB might be considered an “HPD SCB”.

Usage

scrHpd(samples, mode = apply(samples, 2, median), level = 0.95)

Arguments

samples

m by n matrix where m is the number of samples and n the number of parameters, hence each (multivariate) sample is a row in the matrix samples

mode

mode vector of length n (defaults to the vector of medians)

level

credible level for the SCB (default: 0.95)

Details

This function first computes the matrix of absolute distances of the samples to the mode vector. Then based on this distance matrix, a one-sided SCB as described in Besag et al. (1995) is computed, which is then mapped back to the samples.

Value

A matrix with rows “lower” and “upper”, with the lower and upper SCB bounds.

Author(s)

Daniel Saban\'es Bov\'e

References

Besag, J.; Green, P.; Higdon, D. and Mengersen, K. (1995): “Bayesian computation and stochastic systems (with discussion)”, Statistical Science, 10, 3-66.

See Also

empiricalHpd

Examples

## create some samples
time <- 1:10
nSamples <- 50
samples <- t(replicate(nSamples,
                       time * rnorm(1) + rexp(1))) +
           rnorm(length(time) * nSamples)
matplot(time, t(samples), type="l", lty=1, col=1,
        xlab="time", ylab="response")

## now test the function: 50% credible band
scb <- scrHpd(samples, level=0.5)
matlines(time, t(scb), col=2, lwd=2, lty=1)

[Package bfp version 0.0-48 Index]