set_transit_compartments#

pharmpy.modeling.set_transit_compartments(model, n, keep_depot=True)[source]#

Set the number of transit compartments of model.

Initial estimate for absorption rate is set the previous rate if available, otherwise it is set to the time of first observation/2.

Parameters:
  • model (Model) – Pharmpy model

  • n (int) – Number of transit compartments

  • keep_depot (bool) – False to convert depot compartment into a transit compartment

Returns:

Model – Pharmpy model object

Examples

>>> from pharmpy.modeling import *
>>> model = load_example_model("pheno")
>>> model = set_transit_compartments(model, 3)
>>> model.statements.ode_system
Bolus(AMT, admid=1) → TRANSIT1
┌────────┐      ┌────────┐      ┌────────┐      ┌───────┐
│TRANSIT1│──K12→│TRANSIT2│──K23→│TRANSIT3│──K34→│CENTRAL│──K40→
└────────┘      └────────┘      └────────┘      └───────┘

See also

add_lag_time