evaluate_expression#
- pharmpy.modeling.evaluate_expression(model, expression, parameter_estimates=None)[source]#
Evaluate expression using model
Calculate the value of expression for each data record. The expression can contain dataset columns, variables in model and population parameters. If the model has parameter estimates these will be used. Initial estimates will be used for non-estimated parameters.
- Parameters:
model (Model) – Pharmpy model
expression (str or TExpr) – Expression to evaluate
parameter_estimates (pd.Series) – Parameter estimates to use instead of initial estimates
- Returns:
pd.Series – A series of one evaluated value for each data record
Examples
>>> from pharmpy.modeling import load_example_model, evaluate_expression >>> from pharmpy.tools import load_example_modelfit_results >>> model = load_example_model("pheno") >>> results = load_example_modelfit_results("pheno") >>> pe = results.parameter_estimates >>> evaluate_expression(model, "TVCL*1000", parameter_estimates=pe) 0 6.573770 1 6.573770 2 6.573770 3 6.573770 4 6.573770 ... 739 5.165105 740 5.165105 741 5.165105 742 5.165105 743 5.165105 Length: 744, dtype: float64