set_initial_estimates#
- pharmpy.modeling.set_initial_estimates(model, inits, move_est_close_to_bounds=False, strict=True)[source]#
Update initial parameter estimate for a model
Updates initial estimates of population parameters for a model. If the new initial estimates are out of bounds or NaN this function will raise.
- Parameters:
model (Model) – Pharmpy model
inits (pd.Series or dict) – Initial parameter estimates to update
move_est_close_to_bounds (bool) – Move estimates that are close to bounds. If correlation >0.99 the correlation will be set to 0.9, if variance is <0.001 the variance will be set to 0.01.
strict (bool) – Whether all parameters in input need to exist in the model. Default is True Setting strict to False will also disregard any initial estimate being NaN and keep the original value for these parameters.
- Returns:
Model – Updated Pharmpy model
Example
>>> from pharmpy.modeling import load_example_model, set_initial_estimates >>> from pharmpy.tools import load_example_modelfit_results >>> model = load_example_model("pheno") >>> results = load_example_modelfit_results("pheno") >>> model.parameters.inits {'POP_CL': 0.00469307, 'POP_VC': 1.00916, 'COVAPGR': 0.1, 'IIV_CL': 0.0309626, 'IIV_VC': ...} >>> model = set_initial_estimates(model, results.parameter_estimates) >>> model.parameters.inits {'POP_CL': 0.00469555, 'POP_VC': 0.984258, 'COVAPGR': 0.15892, 'IIV_CL': 0.0293508, ...} >>> model = load_example_model("pheno") >>> model = set_initial_estimates(model, {'POP_CL': 2.0}) >>> model.parameters['POP_CL'] Parameter("POP_CL", 2.0, lower=0.0, upper=∞, fix=False)
See also
fix_parameters_to
Fixing and setting parameter initial estimates in the same function
unfix_paramaters_to
Unfixing parameters and setting a new initial estimate in the same