Predictive distribution from fitted means
simulate_from_means.RdJoint draws of the responses of n_rows rows, for engines that give a
mean per row and nothing else (gradient boosting, an imported network):
the family adds the process noise, and several mean vectors (bootstrap
refits) add the parameter uncertainty. Simulation i picks one mean
vector uniformly, then draws each row's response from family with that
mean, dispersion and the row's weight. Components are keyed
row = 0, 1, ..., as for glm_fit()'s draws.
Usage
simulate_from_means(
family,
means,
n_sims,
seed,
n_rows = NULL,
dispersion = 1,
weights = NULL,
theta = NULL,
power = NULL
)Arguments
- family
"gaussian","poisson","gamma","inverse_gaussian","binomial","negative_binomial"(needstheta) or"tweedie"(needspower).- means
A matrix with one row per policy and one column per mean vector, or a vector of
n_rows * kmeans stacked column by column.- n_sims
Number of simulations.
- seed
Generator seed.
- n_rows
Rows per mean vector; defaults to
nrow(means), or the length of a vector.- dispersion
The family's dispersion: one value, or one per row.
- weights
Optional prior weights, one per row.
- theta
Negative binomial
theta.- power
Tweedie power in
(1, 2).