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. For binary traits, the centre line is the predicted probability when available. Binary predictions have no conformal bounds here. If bounds are absent, this function still draws a ribbon using min(p, 1-p), a probability-of-error score, as if it were an SE. This binary ribbon is only a visual score display: it is not a calibrated interval and has no stated coverage. Interpret the centre line as the probability; do not interpret the ribbon as an uncertainty interval. 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).

Value

A ggplot object.

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.