run_covsearch#

pharmpy.tools.run_covsearch(search_space, p_forward=0.01, p_backward=0.001, max_steps=-1, algorithm='scm-forward-then-backward', results=None, model=None, max_eval=False, adaptive_scope_reduction=False, strictness='minimization_successful or (rounding_errors and sigdigs>=0.1)', naming_index_offset=0, nsamples=10, _statsmodels=False, _weighted_linreg=False, _lin_filter=0, **kwargs)#

Run COVsearch tool. For more details, see COVsearch.

Parameters:
  • search_space (str) – MFL of covariate effects to try

  • p_forward (float) – The p-value to use in the likelihood ratio test for forward steps

  • p_backward (float) – The p-value to use in the likelihood ratio test for backward steps

  • max_steps (int) – The maximum number of search steps to make

  • algorithm ({‘scm-forward’, ‘scm-forward-then-backward’, ‘samba’}) – The search algorithm to use. Currently, ‘scm-forward’ and ‘scm-forward-then-backward’ are supported.

  • results (ModelfitResults) – Results of model

  • model (Model) – Pharmpy model

  • max_eval (bool) – Limit the number of function evaluations to 3.1 times that of the base model. Default is False.

  • adaptive_scope_reduction (bool) – Stash all non-significant parameter-covariate effects to be tested after all significant effects have been tested. Once all these have been tested, try adding the stashed effects once more with a regular forward approach. Default is False

  • strictness (str or None) – Strictness criteria

  • naming_index_offset (int) – index offset for naming of runs. Default is 0.

  • nsamples (int) – Number of samples from individual parameter conditional distribution for linear covariate model selection. nsamples=0 uses ETAs to for linear model selection, whereas nsample>=1 generates MCMC samples with an additional SAEM estimation step. When multiple samples are generated, linear mixed effects model will be used to fit the linear models. Default is 10, i.e. generating 10 samples per subject

  • _statsmodels (bool) – NOTE: This is an experimental option. Do not use. Estimation tool for SAMBA linear covariate model fitting. ‘True’ calls statsmodel’s functionalities, whereas ‘False’ calls nonmem.

  • _weighted_linreg (bool) – NOTE: This is an experimental option. Do not use. When using nonmem to run linear covariate models, ‘True’ uses ETC as weight to run WLS.

  • _lin_filter (int) – NOTE: This is an experimental option. Do not use. Option to control the number of covariates passed to nonlinear selection

    0: pass all LRT positive covariate effects from linear selection step 1: pass the ones with the largest drop of OFV within each parameter scope 2: the one with the largest drop of OFV among all parameter-covariate pair

  • kwargs – Arguments to pass to tool

Returns:

COVSearchResults – COVsearch tool result object

Examples

>>> from pharmpy.modeling import load_example_model
>>> from pharmpy.tools import run_covsearch, load_example_modelfit_results
>>> model = load_example_model("pheno")
>>> results = load_example_modelfit_results("pheno")
>>> search_space = 'COVARIATE([CL, V], [AGE, WT], EXP)'
>>> res = run_covsearch(search_space, model=model, results=results)