Skip to contents

Plots predicted vs observed data, grouped by "group".

This function visualizes the relationship between predicted and observed values, allowing for easy identification of discrepancies.

Usage

plotPredictedVsObserved(
  plotData,
  metaData = NULL,
  mapping = ggplot2::aes(),
  yUnit = NULL,
  xyScale = "log",
  predictedAxis = "y",
  comparisonLineVector = ospsuite.plots::getFoldDistanceList(folds = c(2)),
  showLegendPerDataset = "all",
  ...
)

Arguments

plotData

An object of class DataCombined or a data.table. If a data.table, it must include the following:

  • xValues: Numeric time points.

  • yValues: Observed or simulated values (numeric).

  • group: Grouping variable (factor or character).

  • name: Name for the dataset (factor or character).

  • xUnit: Unit of the x-axis values (character).

  • yUnit: Unit of the y-axis values (character).

  • dataType: Specifies data type—either observed or simulated.

  • Optional:

    • yErrorType: Type of y error, relative to ospsuite::DataErrorType.

    • yErrorValues: Numeric error values.

    • yMin, yMax: Custom ranges for y-axis instead of error types.

    • IndividualId: Used for aggregation of simulated population data.

metaData

A list containing metadata for the plot. If NULL, a default list is constructed from the data. Expected structure includes information about dimensions and units for both x and y axes.

mapping

A ggplot2 aesthetic mapping object. Default is ggplot2::aes(). This is added or replaces the default mapping constructed by the data.

yUnit

A character string specifying the target unit for the x and y-axis. If NULL (default), the most frequent unit in the data is used. For available units, see ospsuite::ospUnits.

xyScale

A character string specifying the scale for the x and y-axis. Default is log.

predictedAxis

A character string specifying which axis to use for predicted values. Options are "x" (predicted on x-axis, observed on y-axis) or "y" (default, predicted on y-axis, observed on x-axis).

comparisonLineVector

A named list generated by the function ospsuite.plots::getFoldDistanceList. This list contains fold distances, where each entry represents a fold and its reciprocal. The identity fold (1) will be included if specified in getFoldDistanceList.

showLegendPerDataset

Controls display of separate legend entries for individual datasets. One of:

  • "none" : No per-dataset differentiation. Only group-level legend.

  • "all" (default) or "observed": Differentiate observed datasets via different shapes (using the name column).

User-provided mapping will override internal settings.

...

Arguments passed on to ospsuite.plots::plotYVsX

geomPointAttributes

A list with arguments which are passed on to the call ggplot2::geom_point

geomErrorbarAttributes

A list with arguments which are passed on to the call ggplot2::geom_errorbar

geomGuestLineAttributes

A list of arguments passed to ggplot2::geom_function to display guest criteria.

geomComparisonLineAttributes

A list of arguments passed to ggplot2::hline or ggplot2::abline to display comparison lines.

geomLLOQAttributes

A list with arguments which are passed on to the call ggplot2::geom_hline

groupAesthetics

A character vector of aesthetic names used for grouping data points when calculating comparison statistics. Data will be grouped by combinations of these aesthetics before computing counts and proportions within comparison lines. Common grouping aesthetics include "colour", "fill", "shape".

addRegression

A boolean that activates the insertion of a regression line.

addGuestLimits

A boolean that activates the insertion of guest limits.

deltaGuest

Numeric value parameter for the Guest function.

labelGuestCriteria

Label used in the legend for guest criteria (default: "guest criteria").

xScaleArgs

list of arguments passed to ggplot2::scale_x_continuous() or ggplot2::scale_x_log10()

yScaleArgs

list of arguments passed to ggplot2::scale_y_continuous() or ggplot2::scale_y_log10()

lloqOnBothAxes

A boolean; if TRUE, LLOQ lines are drawn on both axes. If FALSE (default), the LLOQ line is drawn for the observed-data axis only. (geom_vline when observedDataDirection = "x", geom_hline when observedDataDirection = "y").

Value

A ggplot2 plot object representing predicted vs observed values, including aesthetics for the x and y axes, or NULL if the data contains no plottable entries.

Examples

if (FALSE) { # \dontrun{
# Generate a predicted vs observed plot for the provided data
plotPredictedVsObserved(myDataCombined)

# Generate an observed vs predicted plot (swap axes)
plotPredictedVsObserved(myDataCombined, predictedAxis = "x")

# Show individual dataset names in legend
plotPredictedVsObserved(myDataCombined, showLegendPerDataset = "observed")
} # }