Generates samples from the prior predictive distribution for the hierarchical shrinkage model. Useful for prior elicitation and sensitivity analysis.
The generative process is:
Sample mu from p(mu)
Sample tau from p(tau)
Sample theta_i ~ N(mu, tau) for each group i
Value
A list with class "shrinkr_prior_pred" containing:
- mu
Vector of mu draws
- tau
Vector of tau draws
- theta
Matrix of theta draws (n_draws x n_groups)
- implied_range
Vector of ranges (max - min) of theta across groups for each draw
- implied_sd
Vector of standard deviations of theta across groups for each draw
- group_names
Group labels
- n_draws
Number of draws
- n_groups
Number of groups
- priors
The hierarchical_priors specification used
See also
shrink for fitting the hierarchical model,
plot.shrinkr_prior_pred for visualizing prior predictive samples
Examples
priors <- list(
mu = distributional::dist_normal(0, 5),
tau = distributional::dist_truncated(distributional::dist_normal(0, 1), lower = 0)
)
prior_pred <- sample_prior_predictive(priors, n_groups = 3, n_draws = 50)
median(prior_pred$implied_range)
#> [1] 0.9419793
head(as.data.frame(prior_pred))
#> # A tibble: 6 × 5
#> .draw group theta mu tau
#> <int> <chr> <dbl> <dbl> <dbl>
#> 1 1 group1 0.326 0.305 0.305
#> 2 1 group2 -0.159 0.305 0.305
#> 3 1 group3 0.568 0.305 0.305
#> 4 2 group1 -3.65 -4.12 0.930
#> 5 2 group2 -4.45 -4.12 0.930
#> 6 2 group3 -4.57 -4.12 0.930