plot_vpc#

pharmpy.modeling.plot_vpc(model, simulations, binning='equal_number', nbins=8, qi=0.95, ci=0.95, stratify_on=None)[source]#

Creates a VPC plot for a model

Parameters:
  • model (Model) – Pharmpy model

  • simulations (Path or pd.DataFrame) – DataFrame containing the simulation data or path to dataset. The dataset has to have one (index) column named “SIM” containing the simulation number, one (index) column named “index” containing the data indices and one dv column. See below for more information.

  • binning ([“equal_number”, “equal_width”]) – Binning method. Can be “equal_number” or “equal_width”. The default is “equal_number”.

  • nbins (int) – Number of bins. Default is 8.

  • qi (float) – Upper quantile. Default is 0.95.

  • ci (float) – Confidence interval. Default is 0.95.

  • stratify_on (str) – Parameter to use for stratification. Optional.

Returns:

alt.Chart – Plot

The simulation data should have the following format:

SIM

index

DV

1

0

0.000

1

1

34.080

1

2

28.858

1

3

0.000

1

4

12.157

2

0

23.834

2

1

0.000

20

2

0.000

20

3

31.342

20

4

29.983

Examples

>>> from pharmpy.modeling import set_simulation, plot_vpc, load_example_model
>>> from pharmpy.tools import run_simulation
>>> model = load_example_model("pheno")
>>> sim_model = set_simulation(model, n=100)
>>> sim_data = run_simulation(sim_model) 
>>> plot_vpc(model, sim_data)