add_residuals#

pharmpy.modeling.add_residuals(model, res)[source]#

Add predictions and/or residuals

Add residuals to estimation step.

Added redidual variable(s) need to be one of the following :

[‘RES’, ‘IRES’, ‘WRES’, ‘IWRES’, ‘CWRES’]

Parameters:
  • model (Model) – Pharmpy model

  • res (list) – List of residuals (e.g. [‘CWRES’])

Returns:

Model – Pharmpy model object

Examples

>>> from pharmpy.modeling import *
>>> model = load_example_model("pheno")
>>> model.execution_steps[-1].residuals
('CWRES', 'RES')
>>> model = add_residuals(model, ['WRES'])
>>> model.execution_steps[-1].residuals
('CWRES', 'RES', 'WRES')