run_covsearch#
- pharmpy.tools.run_covsearch(model, results, search_space, p_forward=0.01, p_backward=0.001, max_steps=-1, algorithm='scm-forward-then-backward', max_eval=False, adaptive_scope_reduction=False, strictness='minimization_successful or (rounding_errors and sigdigs>=0.1)', naming_index_offset=0, nsamples=10, _samba_max_covariates=3, _samba_selection_criterion='bic', _samba_linreg_method='ols', _samba_stepwise_lcs=None, **kwargs)#
Run COVsearch tool. For more details, see COVsearch.
- Parameters:
model (Model) – Pharmpy model
results (ModelfitResults) – Results of model
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.
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) – 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. Default is 10, i.e. generating 10 samples per subject
_samba_max_covariates (int or None) – Maximum number of covariate inclusion allowed in linear covariate screening for each parameter.
_samba_linreg_method (str) – Method used to fit linear covariate models. Currently, Ordinary Least Squares (ols), Weighted Least Squares (wls), and Linear Mixed-Effects (lme) are supported.
_samba_selection_criterion (str) – Method used for linear and nonlinear model selection in SAMBA methods. Currently, BIC and LRT are supported.
_samba_stepwise_lcs (bool or None) – Use stepwise linear covariate screening or not. By default, SAMBA methods use stepwise LCS whereas SCM-LCS uses non-stepwise LCS
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(model=model, results=results, search_space=search_space)