add_allometry#

pharmpy.modeling.add_allometry(model, allometric_variable=None, reference_value=70, parameters=None, initials=None, lower_bounds=None, upper_bounds=None, fixed=True)[source]#

Add allometric scaling of parameters

Add an allometric function to each listed parameter. The function will be P=P*(X/Z)**T where P is the parameter, X the allometric_variable, Z the reference_value and T is a theta. Default is to automatically use clearance and volume parameters.

If there already exists a covariate effect (or allometric scaling) on a parameter with the specified allometric variable, nothing will be added.

If no allometric variable is specified, it will be extracted from the dataset based on the descriptor “body weight”.

Parameters:
  • model (Model) – Pharmpy model

  • allometric_variable (str or TExpr) – Value to use for allometry (X above)

  • reference_value (str, int, float or TExpr) – Reference value (Z above)

  • parameters (list) – Parameters to use or None (default) for all available CL, Q and V parameters

  • initials (list) – Initial estimates for the exponents. Default is to use 0.75 for CL and Qs and 1 for Vs

  • lower_bounds (list) – Lower bounds for the exponents. Default is 0 for all parameters

  • upper_bounds (list) – Upper bounds for the exponents. Default is 2 for all parameters

  • fixed (bool) – Whether the exponents should be fixed

Returns:

Model – Pharmpy model object

Examples

>>> from pharmpy.modeling import load_example_model, add_allometry, remove_covariate_effect
>>> model = load_example_model("pheno")
>>> model = remove_covariate_effect(model, 'CL', 'WGT')
>>> model = remove_covariate_effect(model, 'V', 'WGT')
>>> model = add_allometry(model, allometric_variable='WGT')
>>> model.statements.before_odes
BTIME = {TIME  for AMT > 0
TAD = -BTIME + TIME
TVCL = PTVCL
TVV = PTVV
      ⎧TVV⋅(THETA₃ + 1)  for APGR < 5

TVV = ⎩      TVV           otherwise
           ETA₁
CL = TVCL⋅ℯ
             ALLO_CL
        ⎛WGT⎞
     CL⋅⎜───⎟
CL =    ⎝ 70⎠
         ETA₂
V = TVV⋅ℯ
           ALLO_V
      ⎛WGT⎞
    V⋅⎜───⎟
V =   ⎝ 70⎠
S₁ = V