| Title: | Open Systems Pharmacology Parameter Identification package |
|---|---|
| Description: | R package for performing parameter identification for the Open Systems Pharmacology models. |
| Authors: | Open-Systems-Pharmacology Community [cph], esqLABS GmbH [fnd], Pavel Balazki [aut, cre], Rudi Engelke [aut], Sergei Vavilov [ctb], Felix Mil [ctb] |
| Maintainer: | Pavel Balazki <[email protected]> |
| License: | GPL-2 | file LICENSE |
| Version: | 2.2.0 |
| Built: | 2026-07-15 13:22:56 UTC |
| Source: | https://github.com/Open-Systems-Pharmacology/OSPSuite.ParameterIdentification |
Default options for various optimization algorithms used within the package.
These algorithms are configured via the PIConfiguration class.
AlgorithmOptions_HJKB AlgorithmOptions_BOBYQA AlgorithmOptions_DEoptim AlgorithmDefaultsAlgorithmOptions_HJKB AlgorithmOptions_BOBYQA AlgorithmOptions_DEoptim AlgorithmDefaults
Default options for the HJKB algorithm. See
dfoptim::hjkb() for more details on the options.
Default options for the BOBYQA algorithm.
See nloptr::nl.opts() for more details on the options.
Default options for the DEoptim
algorithm. See DEoptim::DEoptim.control() for more details on the
options.
Optimization algorithms supported by optimization routines, available for use
in the ParameterIdentification class. These algorithms are configured via
the PIConfiguration class.
AlgorithmsAlgorithms
Supported algorithms include:
HJKB – Hooke-Jeeves algorithm from the dfoptim package.
BOBYQA – BOBYQA algorithm from the nloptr package.
DEoptim – Differential evolution algorithm from the DEoptim
package, suitable for stochastic global optimization.
These algorithms can be specified and configured within the
PIConfiguration class to tailor the parameter identification process to
specific needs.
Confidence interval estimation methods supported in the
ParameterIdentification class. These methods are configured via the
PIConfiguration class.
CIMethodsCIMethods
Supported methods:
hessian - Hessian-based approximation using the Fisher Information Matrix.
PL – Profile likelihood estimation, iterating over each parameter.
bootstrap – Bootstrap resampling to estimate parameter uncertainty.
These methods can be specified and configured within the PIConfiguration
class to customize confidence interval estimation.
Default options for various confidence interval estimation methods used
within the package. These methods are configured via the PIConfiguration
class.
CIOptions_hessian CIOptions_PL CIOptions_bootstrap CIDefaultsCIOptions_hessian CIOptions_PL CIOptions_bootstrap CIDefaults
A list containing default settings for confidence interval estimation methods.
Default options for the hessian method.
The Hessian matrix is computed via numDeriv::hessian() using the
Richardson method (the only supported method). The r and d options map
directly to method.args of that function.
epsilon: Numerical step size for numerical differentiation. Default
is NULL, which applies an adaptive step size based on the parameter
values.
confLevel: Confidence level for interval estimation. Default is 0.95
(95% confidence intervals).
r: Number of Richardson iterations. Controls the trade-off between
accuracy and computation time: approximately (N^2 + N)*r objective
function evaluations are performed, where N is the number of free
parameters.
Must be at least 2. Default is NULL, which uses numDeriv's default
of 4.
d: Fractional step size. Smaller values reduce the step size relative
to the parameter value. Default is NULL, which uses numDeriv's default
of 0.1.
Default options for the PL (Profile Likelihood)
method.
epsilon: Numerical step size for profile likelihood adjustments.
Default is NULL, which applies an adaptive step size.
confLevel: Confidence level for interval estimation. Default is 0.95
(95% confidence intervals).
maxIter: Maximum number of iterations for likelihood profiling.
Default is 100.
Default options for the bootstrap method.
nSamples: Number of bootstrap resampling iterations. Default is 1000.
confLevel: Confidence level for interval estimation. Default is 0.95
(95% confidence intervals).
seed: Random seed for reproducibility. Default is NULL.
Get the value of a global ospsuite.parameteridentification setting.
getOSPSuitePISetting(settingName)getOSPSuitePISetting(settingName)
settingName |
String name of the setting |
Value of the setting stored in piEnv. If the setting does not exist,
an error is thrown.
getOSPSuitePISetting("packageVersion")getOSPSuitePISetting("packageVersion")
Default settings for objective function options in model fit analysis,
pivotal for calculating error and fit. These configurations enable tailored
analysis approaches, pivotal in the ParameterIdentification process for
optimizing parameter values against observed data. These options are
configured via the PIConfiguration class.
ObjectiveFunctionOptionsObjectiveFunctionOptions
Settings include:
objectiveFunctionType – Type of objective function used. Default is
lsq (least squares), influencing error calculation.
residualWeightingMethod – Method for residual weighting. Default is
none.
robustMethod – Method for robust outlier handling. Default is none
(standard analysis).
scaleVar – Whether residual scaling is applied. Default is FALSE.
linScaleCV – Coefficient of variation for linear scaling. Default is
0.2.
logScaleSD – Standard deviation for log scaling. Default is NULL.
These options are configurable in PIConfiguration, directly influencing
the calculateCostMetrics functionality for detailed model fit assessment.
getOSPSuitePISetting()
Names of the settings stored in piEnv Can be used with
getOSPSuitePISetting()
ospsuitePIRSettingNamesospsuitePIRSettingNames
Performs parameter estimation by fitting model simulations to observed data. Supports customizable optimization and confidence interval methods.
simulationsA named list of Simulation objects, keyed by the IDs
of their root containers.
parametersA list of PIParameters, each representing a grouped
set of model parameters to be optimized (read-only).
configurationA PIConfiguration object controlling algorithm, CI
estimation, and objective function options.
outputMappingsA list of PIOutputMapping objects mapping
observed datasets to simulated outputs.
pkOutputMappingsA list of PKOutputMapping objects for PK
metric optimization. NULL in standard PI mode. Read-only.
ParameterIdentification$new()Initializes a ParameterIdentification instance.
ParameterIdentification$new( simulations, parameters, outputMappings = NULL, pkOutputMappings = NULL, configuration = NULL )
simulationsA Simulation or list of Simulation objects to be
used for parameter estimation. Each simulation must contain the model
parameters specified in parameters. Use
ospsuite::loadSimulation() to load simulation files.
parametersA PIParameters or list of PIParameters objects
specifying the model parameters to optimize. Each PIParameters object
may group one or more underlying model parameters. See
PIParameters for details.
outputMappings(Optional) A PIOutputMapping or list of
PIOutputMapping objects mapping model outputs to observed data.
Mutually exclusive with pkOutputMappings.
pkOutputMappings(Optional) A PKOutputMapping or list of
PKOutputMapping objects for PK metric optimization. Mutually
exclusive with outputMappings.
configuration(Optional) A PIConfiguration object specifying
algorithm, CI method, and objective function settings. Defaults to a
new configuration if omitted. See
PIConfiguration for configuration
options.
A ParameterIdentification object ready to run parameter
estimation.
Executes Parameter Identification
ParameterIdentification$run()Runs parameter identification using the configured
optimization algorithm. Returns a structured piResultsobject
containing estimated parameters, diagnostics, and (optionally)
confidence intervals.
ParameterIdentification$run()
A PIResult object in standard mode, or a PKResult object
(internal) when pkOutputMappings was provided.
Estimate Confidence Intervals
ParameterIdentification$estimateCI()Computes confidence intervals for the optimized parameters
using the method defined in the associated PIConfiguration. Intended
for advanced use when autoEstimateCI was set to FALSE during the
initial run.
ParameterIdentification$estimateCI()
The same PIResult object returned by the run() method,
updated to include confidence interval estimates.
Plot Parameter Estimation Results
ParameterIdentification$plotResults()Re-runs model simulations using the current or specified parameter values and generates plots comparing predictions to observed data.
ParameterIdentification$plotResults(par = NULL)
parOptional parameter values for simulations, in the order of
ParameterIdentification$parameters. Use current values if NULL.
A list of patchwork objects (one per output mapping), showing:
Individual time profiles
Predicted vs. observed values
Residuals vs. time Perform a Parameter Grid Search
Generates a grid of parameter combinations, computes the OFV for each, and optionally sets the best result as the starting point for s subsequent optimization.
Note: The resulting grid can be used to explore the parameter space or initialize better starting values.
ParameterIdentification$gridSearch()ParameterIdentification$gridSearch( lower = NULL, upper = NULL, logScaleFlag = FALSE, totalEvaluations = 50, setStartValue = FALSE )
lowerNumeric vector of parameter lower bounds, defaulting to
PIParameter minimum values.
upperNumeric vector of parameter upper bounds, defaulting to
PIParameter maximum values.
logScaleFlagLogical scalar or vector; determines if grid points
are spaced logarithmically. Default is FALSE.
totalEvaluationsInteger specifying the total grid points. Default is 50.
setStartValueLogical. If TRUE, updates PIParameter starting
values to the best grid point. Default is FALSE.
A tibble where each row is a parameter combination and the
corresponding objective function value (ofv).
Calculate Objective Function Value (OFV) Profiles
ParameterIdentification$calculateOFVProfiles()Generates OFV profiles by varying each PIParameter independently while
holding the others fixed at par. Useful as a post-optimization
diagnostic: around a (local) minimum the OFV is expected to be roughly
convex along each axis.
ParameterIdentification$calculateOFVProfiles( par = NULL, boundFactor = 0.1, totalEvaluations = 20 )
parNumeric vector of parameter values, one for each
PIParameter. Defaults to current parameter values if NULL,
not numeric, or of mismatched length.
boundFactorNumeric scalar. A value of 0.1 (default) means
bounds extend ±10% around par for each parameter.
totalEvaluationsInteger specifying the number of grid points
per parameter profile. Default is 20.
For each parameter i a one-dimensional grid of totalEvaluations
equally spaced points is built between lower[i] and upper[i], with
the bounds derived from par[i] and boundFactor:
par[i] >= 0: lower[i] = (1 - boundFactor) * par[i],
upper[i] = (1 + boundFactor) * par[i].
par[i] < 0: bounds are mirrored so that lower < upper is preserved.
The objective function is evaluated along each axis with all other
parameters held at their par values. Failed simulations contribute
Inf to the corresponding ofv cell.
A named list of tibbles, one element per PIParameter. List
names are the parameter paths (taken from parameters[[1]]$path).
Each tibble has two columns:
a column named after the parameter path, holding the grid values;
ofv, holding the matching objective function values.
Pass the returned list to plotOFVProfiles() to visualize the
profiles.
# piTask is a configured ParameterIdentification instance # Default: +/-10% around current values, 20 grid points per parameter # ofvProfiles <- piTask$calculateOFVProfiles() # Wider neighborhood, finer grid # ofvProfiles <- piTask$calculateOFVProfiles( # boundFactor = 0.5, # totalEvaluations = 50 # ) # plotOFVProfiles(ofvProfiles)[[1]]
ParameterIdentification$print()Prints a summary of ParameterIdentification instance.
ParameterIdentification$print()
## ------------------------------------------------ ## Method `ParameterIdentification$calculateOFVProfiles()` ## ------------------------------------------------ # piTask is a configured ParameterIdentification instance # Default: +/-10% around current values, 20 grid points per parameter # ofvProfiles <- piTask$calculateOFVProfiles() # Wider neighborhood, finer grid # ofvProfiles <- piTask$calculateOFVProfiles( # boundFactor = 0.5, # totalEvaluations = 50 # ) # plotOFVProfiles(ofvProfiles)[[1]]## ------------------------------------------------ ## Method `ParameterIdentification$calculateOFVProfiles()` ## ------------------------------------------------ # piTask is a configured ParameterIdentification instance # Default: +/-10% around current values, 20 grid points per parameter # ofvProfiles <- piTask$calculateOFVProfiles() # Wider neighborhood, finer grid # ofvProfiles <- piTask$calculateOFVProfiles( # boundFactor = 0.5, # totalEvaluations = 50 # ) # plotOFVProfiles(ofvProfiles)[[1]]
Encapsulates configurations such as optimization algorithm choice, and evaluation settings for parameter identification.
printEvaluationFeedbackBoolean. If TRUE, prints objective
function value after each evaluation. Default is FALSE.
simulationRunOptionsObject of SimulationRunOptions for
simulation runs. If NULL, default options are used.
objectiveFunctionOptionsSettings for model fit evaluation,
affecting error metrics and cost calculation. Defaults in
ObjectiveFunctionOptions. Partial lists are merged with the current
settings; only the provided keys are updated and validated.
algorithmOptimization algorithm name. See
Algorithms for a list of
supported algorithms. Defaults to BOBYQA. Changing the algorithm
resets algorithmOptions to the new algorithm's defaults.
ciMethodConfidence interval estimation method. See
CIMethods for available options.
Defaults to hessian. Changing the method resets ciOptions to the
new method's defaults.
algorithmOptionsNamed list of user-defined overrides for the
selected algorithm's settings. Returns NULL if no overrides are set;
in that case algorithm defaults (AlgorithmOptions_XYZ) are used
automatically. Partial lists are merged with previously stored
overrides. Unknown keys produce a warning and are ignored. Set to
NULL to clear all overrides.
ciOptionsNamed list of settings for the selected CI method. Refer
to CIOptions for default settings
per method (e.g., CIOptions_XYZ where XYZ corresponds to the method
name). If NULL, CI method's default settings are returned. Partial
lists are merged with the current settings; only the provided keys are
validated. Unknown keys produce a warning and are ignored. Set to
NULL to reset to defaults.
autoEstimateCILogical. If TRUE, confidence intervals are
automatically estimated after optimization. If FALSE, the step is
skipped and can be triggered manually by calling the estimateCI()
method on the ParameterIdentification object.
modelCostFieldRead-only field name in the cost object used as the
optimization target. Currently, only modelCost is supported.
PIConfiguration$new()Initialize a new instance of the class.
PIConfiguration$new()
A new PIConfiguration object.
PIConfiguration$print()Prints a summary of the PIConfiguration.
PIConfiguration$print()
PIConfiguration$clone()The objects of this class are cloneable with this method.
PIConfiguration$clone(deep = FALSE)
deepWhether to make a deep clone.
Establishes connections between simulated quantities and
corresponding observed data sets. Utilized within ParameterIdentification
instances to align and compare simulation outputs with empirical data.
observedDataSetsA named list containing DataSet objects for
comparison with simulation outcomes.
dataTransformationsA named list of factors and offsets.
dataWeightsA named list of y-value weights.
quantitySimulation quantities to be aligned with observed data values.
simIdIdentifier of the simulation associated with the mapped quantity.
scalingSpecifies scaling for output mapping: linear (default) or logarithmic.
transformResultsFunctionA function to preprocess simulated
results (time and observation values) before residual calculation. It
takes numeric vectors xVals and yVals, and returns a named list
with keys xVals and yVals.
PIOutputMapping$new()Initialize a new instance of the class.
PIOutputMapping$new(quantity)
quantityAn object of the type Quantity.
A new PIOutputMapping object.
PIOutputMapping$addObservedDataSets()Adds or updates observed data using DataSet objects.
PIOutputMapping$addObservedDataSets(data, weights = NULL)
dataA DataSet object or a list thereof, matching the simulation
quantity dimensions.
weightsA named list of numeric values or numeric vectors. The names must match the names of the observed datasets.
Replaces any existing dataset with the same label.
PIOutputMapping$removeObservedDataSet()Removes specified observed data series.
PIOutputMapping$removeObservedDataSet(label)
labelThe label of the observed data series to remove.
PIOutputMapping$setDataTransformations()Configures transformations for datasets.
PIOutputMapping$setDataTransformations( labels = NULL, xOffsets = 0, yOffsets = 0, xFactors = 1, yFactors = 1 )
labelsList of dataset labels for targeted transformations. Absence of labels applies transformations globally.
xOffsetsNumeric list/value for X-offset adjustments.
yOffsetsNumeric list/value for Y-offset adjustments.
xFactorsNumeric list/value for X-scaling factors.
yFactorsNumeric list/value for Y-scaling factors.
PIOutputMapping$setDataWeights()Assigns weights to observed data sets for residual weighting during parameter identification.
PIOutputMapping$setDataWeights(weights)
weightsA named list of numeric values or numeric vectors. The names must match the names of the observed datasets.
Each element in the list can be:
a scalar, which will be broadcast to all y-values of the corresponding dataset,
or a numeric vector matching the number of y-values for that dataset.
To apply both dataset-level and point-level weights, multiply them beforehand and provide the combined result as a single numeric vector per dataset.
PIOutputMapping$print()Prints a summary of the PIOutputMapping.
PIOutputMapping$print()
PIOutputMapping$clone()The objects of this class are cloneable with this method.
PIOutputMapping$clone(deep = FALSE)
deepWhether to make a deep clone.
A parameter to be optimized in a parameter identification routine
parametersA list of parameter objects. Adding or removing parameters is not supported.
currValueThe current parameter values for simulations, in units
specified by $unit.
startValueInitial value used for optimization.
minValueLowest permissible parameter value.
maxValueHighest permissible parameter value.
unitParameter value units. Changing the unit does NOT automatically adjust min/max/start values.
PIParameters$new()Initialize a new instance of the class. The initial start
value is derived from the first parameter upon creation, modifiable via
PIParameters$startValue. All parameters are optimized using this
unified value.
PIParameters$new(parameters)
parametersList of Parameter class objects to be optimized.
A new PIParameters object.
PIParameters$setValue()Updates parameter(s) value. Value is specified in units of
$unit.
PIParameters$setValue(value)
valueNumeric value to set.
PIParameters$toDataFrame()Export parameter metadata and configuration to a data frame.
Returns one row per internal model parameter wrapped by the
PIParameters object.
PIParameters$toDataFrame(group = NULL)
groupOptional character label identifying the optimization group.
A data.frame with one row per internal parameter.
PIParameters$print()Prints a summary of the PIParameters.
PIParameters$print()
PIParameters$clone()The objects of this class are cloneable with this method.
PIParameters$clone(deep = FALSE)
deepWhether to make a deep clone.
Maps a simulation output quantity to a target PK parameter for use
in ParameterIdentification optimization.
quantityThe Quantity object from the simulation. Read-only.
simIdID of the root simulation container. Read-only.
pkParameterName of the PK parameter to target. Must be one of
ospsuite::StandardPKParameter.
targetValueInBaseUnitTarget value in base units. Computed from
targetValue and targetUnit. Read-only.
targetValueNumeric target value in units of targetUnit.
Recomputes targetValueInBaseUnit on assignment.
targetUnitUnit string for targetValue. Must be compatible with
the PK parameter's dimension. Recomputes targetValueInBaseUnit on
assignment.
PKOutputMapping$new()Initialize a new PKOutputMapping.
PKOutputMapping$new(quantity, pkParameter, targetValue, targetUnit)
quantityAn ospsuite Quantity object from the simulation whose
PK profile will be analyzed.
pkParameterCharacter string specifying the PK parameter to target.
Must be one of ospsuite::StandardPKParameter (e.g., "C_max",
"AUC_tEnd").
targetValueNumeric scalar target value in units of targetUnit.
targetUnitCharacter string specifying the unit of targetValue.
Must be dimensionally compatible with pkParameter.
A new PKOutputMapping object.
sim <- ospsuite::loadSimulation("model.pkml")
quantity <- ospsuite::getQuantity(
"Organism|PeripheralVenousBlood|Drug|Plasma (Peripheral Venous Blood)",
container = sim
)
mapping <- PKOutputMapping$new(
quantity = quantity,
pkParameter = "C_max",
targetValue = 500,
targetUnit = "nmol/l"
)
PKOutputMapping$print()Print a summary of the PKOutputMapping.
PKOutputMapping$print()
Called for its side effect of printing. Returns invisible(self).
PKOutputMapping$clone()The objects of this class are cloneable with this method.
PKOutputMapping$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------ ## Method `PKOutputMapping$new()` ## ------------------------------------------------ ## Not run: sim <- ospsuite::loadSimulation("model.pkml") quantity <- ospsuite::getQuantity( "Organism|PeripheralVenousBlood|Drug|Plasma (Peripheral Venous Blood)", container = sim ) mapping <- PKOutputMapping$new( quantity = quantity, pkParameter = "C_max", targetValue = 500, targetUnit = "nmol/l" ) ## End(Not run)## ------------------------------------------------ ## Method `PKOutputMapping$new()` ## ------------------------------------------------ ## Not run: sim <- ospsuite::loadSimulation("model.pkml") quantity <- ospsuite::getQuantity( "Organism|PeripheralVenousBlood|Drug|Plasma (Peripheral Venous Blood)", container = sim ) mapping <- PKOutputMapping$new( quantity = quantity, pkParameter = "C_max", targetValue = 500, targetUnit = "nmol/l" ) ## End(Not run)
Plots raw residuals and, if different, weighted and robust weighted residuals
from a modelCost object.
## S3 method for class 'modelCost' plot(x, legpos = "topright", ...)## S3 method for class 'modelCost' plot(x, legpos = "topright", ...)
x |
A |
legpos |
Position of the legend; default is "topright". Use NA to omit the legend. |
... |
Additional arguments passed to the plot function. |
Generates a plot.
# Assuming modelCostObj is a valid `modelCost` object ## Not run: plot.modelCost(modelCostObj) ## End(Not run)# Assuming modelCostObj is a valid `modelCost` object ## Not run: plot.modelCost(modelCostObj) ## End(Not run)
Visualizes the OFV profiles produced by
ParameterIdentification$calculateOFVProfiles(). Each profile is rendered
as a scatter plot of the OFV against the corresponding parameter value,
with point color encoding OFV (lower = brighter, reversed Viridis).
plotOFVProfiles(profiles)plotOFVProfiles(profiles)
profiles |
A named list of tibbles as returned by
|
Around a (local) minimum the objective function is expected to be convex and roughly parabolic. Inspecting the OFV profile around a tentative optimum is therefore a quick visual check that the optimization has converged to a sensible point in parameter space.
Because parameter paths in OSP simulations can be long
(e.g. Neighborhoods|Kidney_pls_Kidney_ur|Aciclovir|Renal Clearances-TS-Aciclovir|TSspec),
the x-axis label uses only the last |-separated segment, while the full
path is shown as the plot title.
A list of ggplot objects, one per parameter profile, in the
same order as profiles.
ParameterIdentification for calculateOFVProfiles().
## Not run: # piTask is a configured ParameterIdentification instance ofvProfiles <- piTask$calculateOFVProfiles() plots <- plotOFVProfiles(ofvProfiles) plots[[1]] ## End(Not run)## Not run: # piTask is a configured ParameterIdentification instance ofvProfiles <- piTask$calculateOFVProfiles() plots <- plotOFVProfiles(ofvProfiles) plots[[1]] ## End(Not run)
Methods for weighting residuals in the model cost function, affecting how discrepancies between simulations and observed data are evaluated.
residualWeightingOptionsresidualWeightingOptions
The methods include:
none – No weighting applied, treating all residuals equally.
error – Weights based on error estimates for the dependent variable
in observed data.
Robust weighting methods to address outliers in the cost function calculation during parameter optimization.
robustMethodOptionsrobustMethodOptions
The available methods are:
none – No robust weighting applied.
huber – Huber weighting for moderate outliers.
bisquare – Bisquare (Tukey's biweight) weighting for severe outliers.
Scaling options applicable to output mappings, impacting how simulation results are compared to observed data.
ScalingOptionsScalingOptions
Available scaling options:
lin – Linear scaling (default).
log – Logarithmic scaling, used when data spans several orders of
magnitude.