MonolixSuite in R
Auto Light Dark
Auto Light Dark

prctilemlx

prctilemlx: prediction interval plots

Description

Compute and plot percentiles of the empirical distribution of longitudinal data. When several groups are present, the groups can be plotted as subplots or as different colors on one plot. The input can be a R object (parameter r) or a Monolix project and a variable name (arguments project and outputVariableName).

Usage

prctilemlx(
  r = NULL,
  col = NULL,
  project = NULL,
  outputVariableName = NULL,
  number = 8,
  level = 80,
  plot = TRUE,
  color = NULL,
  group = NULL,
  facet = TRUE,
  labels = NULL,
  band = NULL
)

Arguments

r

a data frame with a column id, a column time and a column with values.
The times should be the same for all individuals.

col

a vector with the three column indexes for id, time and y. Default = c(1,2,3).

project

simulx project filename (with extension “.smlx”)

outputVariableName

name of the output to consider. By default the first output will be consider.
You must define either a ‘r’ dataframe (and the associated ‘col’ argument) or a simulx project and the name of the output ‘outputVariableName”

number

the number of intervals (i.e. the number of percentiles minus 1).

level

the largest interval (i.e. the difference between the lowest and the highest percentile).

plot

if TRUE the empirical distribution is displayed, if FALSE the values are returned

color

colors to be used for the plots
In case of one group or facet = TRUE, only the first color will be used

group

variable to be used for defining groups (by default, ‘group’ is used when it exists)

facet

makes subplots for different groups if TRUE

labels

vector of strings

band

is deprecated (use number and level instead) ; a list with two fields


  • number the number of intervals (i.e. the number of percentiles minus 1).

  • level the largest interval (i.e. the difference between the lowest and the highest percentile).

Details

You must define either a dataframe r (and if needed the associated col argument) or a Simulx project and the name of the output outputVariableName. The outputVariableName corresponds to the name of the model variable, not to the output element name.

Value

a ggplot object if plot=TRUE ; otherwise, a list with fields:

  • proba: a vector of probabilities of length band$number+1

  • color: a vector of colors used for the plot of length band$number

  • y: a data frame with the values of the empirical percentiles computed at each time point

Examples

This simulx-GUI demo project contains 3 simulation groups, with a low, medium or high dose. In the Simulation tab, the output element ‘regularCc’ is selected, to output the variable ‘Cc’ on a regular time grid.

With facet=T (default), each group is displayed on a separate subplot with the different shades representing different percentiles. The largest band represents the 90% prediction interval.

project.file <- "~/../lixoft/simulx/simulx2020R1/demos/5.simulation/simulationGroups_treatment.smlx"
prctilemlx(project=project.file, outputVariableName = "Cc")


Plot from prctilemlx with the default facet, showing Cc versus time 0 to 100 in three subplots, high_dose, low_dose and medium_dose. Red shaded bands of different intensities show percentile intervals with proba from 0.1 to 0.9 around the median line. Median peaks are about 0.85 for high dose, 0.43 for medium dose and below 0.1 for low dose.


With number=2 and level=95, we can select to display only the median and the 95% prediction interval.

project.file <- "~/../lixoft/simulx/simulx2020R1/demos/5.simulation/simulationGroups_treatment.smlx"
prctilemlx(project=project.file, outputVariableName = "Cc", number=2, level=95)


Plot from prctilemlx with number 2 and level 95, with the same three subplots high_dose, low_dose and medium_dose of Cc versus time 0 to 100. Each subplot now shows only the median line and a single light red band for the 95 percent prediction interval, with legend proba values 0.03, 0.5 and 0.98.


To display the prediction intervals on top of each other, use facet=F. As a ggplot object is returned, additional ggplot functions can be used to overlay additional features or modify the legend, etc.

prctilemlx(project=project.file, outputVariableName = "Cc", facet=F, number=2, level=95) + ylab("Concentration (ug/mL)") + xlab("Time (hr)") + geom_hline(yintercept = 0.25)


Plot from prctilemlx with facet false, number 2 and level 95, overlaying the three groups in one panel. Concentration in ug per mL versus time in hr from 0 to 100, with red high_dose, blue medium_dose and green low_dose median lines and their 95 percent bands. A horizontal black line at 0.25 was added with geom_hline.


Last updated: