plot_prediction_region_ternary: plot_prediction_region_ternary: Plot predictive confidence...

View source: R/simplex_plotting.R

plot_prediction_region_ternaryR Documentation

plot_prediction_region_ternary: Plot predictive confidence regions on a ternary plot

Description

Plot prediction regions. Please note these wrap the 'ggtern' function 'geom_confidence_region' but are actually prediction regions (or predictive confidence regions): regions in which a future data point is expected to fall with the given probability (rather than a confidence region for a particular statistic).

Usage

plot_prediction_region_ternary(
  data,
  groups = NULL,
  parts_to_plot = NULL,
  probs = c(0.5, 0.9, 0.95),
  mark_points = NULL,
  theme = NULL,
  transparency = 0.2,
  suppress_legend = FALSE
)

Arguments

data

Data frame containing data to be plotted.

groups

If plotting groups separately, name of the variable in the data frame which identifies the groups to be plotted. This variable should be a factor variable.

parts_to_plot

Names of the three variables in the data frame which are to be plotted on the ternary plot. Note they should be on the same scale (they don't need to be normalised to 1).

probs

Sequence of probabilities to plot prediction regions for.

mark_points

Points should be the rows of a data frame with the elements of parts_to_plot as columns names. If a groups argument is given, it should also have a column for this (if the groups aren't relevant to the point in a certain row, this can be set as NA).

theme

Optional theme argument which can be set as a ggplot2::theme object and will control how the plot appears.

transparency

Control the transparency of plots. Should be between 0 and 1.

suppress_legend

Suppress legend on plot. May be used when combining plots.

Details

This is a wrapper for ggtern.

Value

Plot showing prediction regions for data on ternary plot.

Examples

simdata$activity <- simdata$vigorous + simdata$moderate + simdata$light

plot_prediction_region_ternary(data = simdata,
parts_to_plot = c("activity", "sedentary", "sleep"),
probs = c(0.25, 0.5, 0.75) # This argument specifies
# we want to plot 25%, 50% and 75% prediction regions.
)

OxWearables/epicoda documentation built on Dec. 7, 2022, 9:07 p.m.