calculate_bic#
- pharmpy.modeling.calculate_bic(model, likelihood, type='mixed', multiple_testing=False, mult_test_p=1, mult_test_e=1)[source]#
Calculate BIC
Different variations of the BIC can be calculated:
- mixed (default)BIC = -2LL + n_random_parameters * log(n_individuals) +n_fixed_parameters * log(n_observations)
- fixedBIC = -2LL + n_estimated_parameters * log(n_observations)
- randomBIC = -2LL + n_estimated_parameters * log(n_individuals)
- iivBIC = -2LL + n_estimated_iiv_omega_parameters * log(n_individuals)
If multiple_testing option is set to true an additional penalty will be added:
- mBIC = BIC + 2*(n_estimated_parameters)*log(n_predictors/n_expected_models)
- Parameters:
model (Model) – Pharmpy model object
likelihood (float) – -2LL to use
type ({‘mixed’, ‘fixed’, ‘random’, ‘iiv’}) – Type of BIC to calculate. Default is the mixed effects.
multiple_testing (bool) – Whether to use penalty for multiple testing (default is False)
mult_test_p (int) – Number of expected models if using type multiple_testing
mult_test_e (int) – E value if using type mult_test
- Returns:
float – BIC of model fit
Examples
>>> from pharmpy.modeling import * >>> from pharmpy.tools import load_example_modelfit_results >>> model = load_example_model("pheno") >>> results = load_example_modelfit_results("pheno") >>> ofv = results.ofv >>> calculate_bic(model, ofv) 611.7071686183284 >>> calculate_bic(model, ofv, type='fixed') 616.536606983396 >>> calculate_bic(model, ofv, type='random') 610.7412809453149 >>> calculate_bic(model, ofv, type='iiv') 594.431131169692