rank_models#

pharmpy.tools.rank_models(base_model, base_model_res, models, models_res, parent_dict=None, strictness='minimization_successful', rank_type='ofv', cutoff=None, bic_type='mixed', **kwargs)[source]#

Ranks a list of models

Ranks a list of models with a given ranking function

Parameters:
  • base_model (Model) – Base model to compare to

  • base_model_res (ModelfitResults) – Results of base model

  • models (list) – List of models

  • models_res (list) – List of modelfit results

  • parent_dict (dict) – Dict where key is child and value is parent. Only relevant for LRT, if None base will be set as parent

  • strictness (str or None) – Strictness criteria that are allowed for ranking. Default is “minimization_successful”.

  • rank_type (str) – Name of ranking type. Available options are ‘ofv’, ‘aic’, ‘bic’, ‘lrt’ (OFV with LRT)

  • cutoff (float or None) – Value to use as cutoff. If using LRT, cutoff denotes p-value. Default is None

  • bic_type (str) – Type of BIC to calculate. Default is the mixed effects.

  • kwargs – Arguments to pass to calculate BIC (such as mult_test_p and mult_test_p)

Returns:

pd.DataFrame – DataFrame of the ranked models

Examples

>>> from pharmpy.modeling import load_example_model
>>> from pharmpy.tools import rank_models
>>> model_1 = load_example_model("pheno")
>>> model_2 = load_example_model("pheno_linear")
>>> rank_models(model_1, [model_2],
...             rank_type='lrt')