sample_individual_estimates#
- pharmpy.modeling.sample_individual_estimates(model, individual_estimates, individual_estimates_covariance, parameters=None, samples_per_id=100, seed=None)[source]#
Sample individual estimates given their covariance.
- Parameters:
model (Model) – Pharmpy model
individual_estimates (pd.DataFrame) – Individual estimates to use
individual_estimates_covariance (pd.DataFrame) – Uncertainty covariance of the individual estimates
parameters (list) – A list of a subset of individual parameters to sample. Default is None, which means all.
samples_per_id (int) – Number of samples per individual
seed (rng or int) – Random number generator or seed
- Returns:
pd.DataFrame – Pool of samples in a DataFrame
Example
>>> from pharmpy.modeling import create_rng, load_example_model, sample_individual_estimates >>> from pharmpy.tools import load_example_modelfit_results >>> model = load_example_model("pheno") >>> results = load_example_modelfit_results("pheno") >>> rng = create_rng(23) >>> ie = results.individual_estimates >>> iec = results.individual_estimates_covariance >>> sample_individual_estimates(model, ie, iec, samples_per_id=2, seed=rng) ETA_CL ETA_VC ID sample 1 0 -0.127941 0.037273 1 -0.065492 -0.182851 2 0 -0.263323 -0.265849 1 -0.295883 -0.060346 3 0 -0.012108 0.219967 ... ... ... 57 1 -0.034279 -0.040988 58 0 -0.187879 -0.143184 1 -0.088845 -0.034655 59 0 -0.187779 -0.014214 1 -0.019953 -0.151151 [118 rows x 2 columns]
See also
sample_parameters_from_covariance_matrix
Sample parameter vectors using the uncertainty covariance matrix
sample_parameters_uniformly
Sample parameter vectors using uniform distribution