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
DataCombinedor adata.table. If adata.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—eitherobservedorsimulated.Optional:
yErrorType: Type of y error, relative toospsuite::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, seeospsuite::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 ingetFoldDistanceList.- 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 thenamecolumn).
User-provided
mappingwill override internal settings.- ...
Arguments passed on to
ospsuite.plots::plotYVsXgeomPointAttributesA
listwith arguments which are passed on to the callggplot2::geom_pointgeomErrorbarAttributesA
listwith arguments which are passed on to the callggplot2::geom_errorbargeomGuestLineAttributesA
listof arguments passed toggplot2::geom_functionto display guest criteria.geomComparisonLineAttributesA
listof arguments passed toggplot2::hlineorggplot2::ablineto display comparison lines.geomLLOQAttributesA
listwith arguments which are passed on to the callggplot2::geom_hlinegroupAestheticsA 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".addRegressionA boolean that activates the insertion of a regression line.
addGuestLimitsA boolean that activates the insertion of guest limits.
deltaGuestNumeric value parameter for the Guest function.
labelGuestCriteriaLabel used in the legend for guest criteria (default: "guest criteria").
xScaleArgslist of arguments passed to
ggplot2::scale_x_continuous()orggplot2::scale_x_log10()yScaleArgslist of arguments passed to
ggplot2::scale_y_continuous()orggplot2::scale_y_log10()lloqOnBothAxesA boolean; if
TRUE, LLOQ lines are drawn on both axes. IfFALSE(default), the LLOQ line is drawn for the observed-data axis only. (geom_vlinewhenobservedDataDirection = "x",geom_hlinewhenobservedDataDirection = "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.
See also
Other plot functions based on ospsuite.plots:
plotQuantileQuantilePlot(),
plotResidualsAsHistogram(),
plotResidualsVsCovariate(),
plotTimeProfile()
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")
} # }