calculate_individual_parameter_statistics#

pharmpy.modeling.calculate_individual_parameter_statistics(model, expr_or_exprs, parameter_estimates, covariance_matrix=None, seed=None)[source]#

Calculate statistics for individual parameters

Calculate the mean (expected value of the distribution), variance (variance of the distribution) and standard error for individual parameters described by arbitrary expressions. Any dataset column or variable used in the model can be used in the expression. The exception being that variables that depends on the solution of the ODE system cannot be used. If covariates are used in the expression the statistics of the parameter is calculated at the median value of each covariate as well as at the 5:th and 95:th percentiles. If no parameter uncertainty is available for the model the standard error will not be calculated.

Parameters:
  • model (Model) – A previously estimated model

  • parameter_estimates (pd.Series) – Parameter estimates

  • covariance_matrix (pd.DataFrame) – Parameter uncertainty covariance matrix

  • expr_or_exprs (str) – expression or iterable of str or expressions Expressions or equations for parameters of interest. If equations are used the names of the left hand sides will be used as the names of the parameters.

  • seed (Generator or int) – Random number generator or int seed

Returns:

pd.DataFrame – A DataFrame of statistics indexed on parameter and covariate value.

Examples

>>> from pharmpy.modeling import load_example_model, create_rng
>>> from pharmpy.modeling import calculate_individual_parameter_statistics
>>> from pharmpy.tools import load_example_modelfit_results
>>> model = load_example_model("pheno")
>>> results = load_example_modelfit_results("pheno")
>>> rng = create_rng(23)
>>> pe = results.parameter_estimates
>>> cov = results.covariance_matrix
>>> calculate_individual_parameter_statistics(model, "K=CL/V", pe, cov, seed=rng)
                          mean  variance    stderr
parameter covariates
K         p5          0.004234  0.000001  0.001138
          median      0.004907  0.000001  0.001247
          p95         0.004907  0.000001  0.001247