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)),
  ...
)

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.

...

Arguments passed on to ospsuite.plots::plotYVsX

geomPointAttributes

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

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.

xScale

either 'linear' then ggplot2::scale_x_continuous() or 'log' then ggplot2::scale_x_log10() is used

xScaleArgs

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

yScale

either 'linear' then ggplot2::scale_y_continuous() or 'log' then ggplot2::scale_y_log10() is used

Value

A ggplot2 plot object representing predicted vs observed values, including aesthetics for the x and y axes.

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")
} # }