Plots residuals as a histogram, grouped by "group".
This function generates a histogram of the residuals, providing a visual representation of their distribution.
Usage
plotResidualsAsHistogram(
plotData,
metaData = NULL,
mapping = ggplot2::aes(),
yUnit = NULL,
distribution = "normal",
residualScale = "log",
...
)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 simulated and observed y-values used for residual calculation. If
NULL(default), the most frequent unit in the data is used. For available units, seeospsuite::ospUnits.- distribution
parameter passed to
ospsuite.plots::plotHistogram.- residualScale
Either "linear", "log", or "ratio" method for computing residuals. Default is
log.- ...
Arguments passed on to
ospsuite.plots::plotHistogramgeomHistAttributesA
listof arguments passed toggplot2::geom_histogram(orgeom_barifasBarPlot= TRUE).plotAsFrequencyA
logicalindicating if the histogram displays frequency on the y-axis.xScaleeither 'linear' then
ggplot2::scale_x_continuous()or 'log' thenggplot2::scale_x_log10()is usedxScaleArgslist of arguments passed to
ggplot2::scale_x_continuous()orggplot2::scale_x_log10()yScaleeither 'linear' then
ggplot2::scale_y_continuous()or 'log' thenggplot2::scale_y_log10()is usedmeanFunctionFunction selection for the display of a vertical line. Options:
'none','mean','geomean','median','auto'(default).'auto'selects'mean'for normal distribution,'geomean'for lognormal,'median'for other distributions, and'none'when no distribution fit.
See also
Other plot functions based on ospsuite.plots:
plotPredictedVsObserved(),
plotQuantileQuantilePlot(),
plotResidualsVsCovariate(),
plotTimeProfile()