Skip to contents

For continuous, count, and ordinal traits, plots conformal prediction intervals when present; otherwise it shows an approximate prediction +/- 1.96 * SE ribbon, sorted by predicted value. If truth is supplied, observed values are overlaid as points. Binary and categorical predictions are refused because their uncertainty scores are not standard errors. Their probability plots are available through plot(prediction, type = "probabilities"). See predict.pigauto_fit for type-specific uncertainty meanings.

Usage

plot_uncertainty(pred_result, truth = NULL, trait_name)

Arguments

pred_result

list with imputed and se components (output of predict.pigauto_fit), or a pigauto_result from impute (its $prediction is used).

truth

matrix or data.frame of true values (same scale as pred_result$imputed), or NULL.

trait_name

character. Which trait to plot (must match column name). Binary and categorical traits are not supported by this interval plot: their uncertainty scores are not Gaussian standard errors. Use plot(prediction, type = "probabilities") for those traits.

Value

A ggplot object.

Details

Uses conformal bounds when supplied. Otherwise the displayed bands use an analytic standard error and a Normal approximation; these bands do not establish calibrated prediction coverage.

Examples

pred <- list(
  imputed = data.frame(mass = c(10, 12, 15)),
  se = matrix(c(1, 1.5, 2), ncol = 1,
              dimnames = list(NULL, "mass"))
)
plot_uncertainty(pred, trait_name = "mass")
Mass predictions for three species sorted by prediction, with a shaded uncertainty band around the line; both prediction and band rise across the displayed species.