Skip to contents

Compute one posterior draw from the smoothed transformation implied by (separate) Bayesian bootstrap models for the CDFs of y and X.

Usage

g_bnp(y, xt_Sigma_x = rep(0, length(y)), z_grid = NULL)

Arguments

y

n x 1 vector of observed counts

xt_Sigma_x

n x 1 vector of t(X_i) Sigma_theta X_i, where Sigma_theta is the prior variance

z_grid

optional vector of grid points for evaluating the CDF of z (Fz)

Value

A smooth monotone function which can be used for evaluations of the transformation at each posterior draw.

Examples

# \donttest{
# Sample some data:
y = rpois(n = 200, lambda = 5)
# Compute 100 draws of g on a grid:
t = seq(0, max(y), length.out = 50) # grid
g_post = t(sapply(1:100, function(s) g_bnp(y)(t)))
# Plot together:
plot(t, t, ylim = range(g_post), type='n', ylab = 'g(t)',  main = 'Bayesian bootstrap posterior: g')
temp = apply(g_post, 1, function(g) lines(t, g, col='gray'))
# And the posterior mean of g:
lines(t, colMeans(g_post), lwd=3)

# }