Overview

Description

Compute and display percentiles of the empiricial distribution of longitudinal data.

Usage

Arguments

r
a data frame with a column id, a column time and a column with values. The times should be the same for each individual.
col
a vector with the three column indexes for id, time and y. Default = c(1, 2, 3).
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 values are returned in a data frame.
color
a color to be used for the plots (default=“#9a35ff”).
col
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
deprecated (use number and level instead) ; a list with fields number and level.

Value

If plot=TRUE: a ggplot object

If plot=FALSE: 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

Some basic examples

We simulate longitudinal data for \(N=2000\) individuals using simulx

## [INFO] The lixoftConnectors package has been successfully initialized:
## lixoftConnectors package version -> 2019.2
## Lixoft softwares suite version   -> 2019R2

res$C is a dataframe with \(2000 \times 241=482000\) rows and 3 columns

##    id time        C
## 1   1  0.0 0.000000
## 2   1  0.5 4.492849
## 3   1  1.0 6.635521
## 4   1  1.5 7.563427
## 5   1  2.0 7.867194
## 6   1  2.5 7.853903
## 7   1  3.0 7.683051
## 8   1  3.5 7.437336
## 9   1  4.0 7.159490
## 10  1  4.5 6.871459

we can compute and display the empirical percentiles of \(C\) using the default settings (i.e. percentiles of order 10%, 20%, … 90%)

The 3 quartiles (i.e. percentiles of order 25%, 50% and 75%) are displayed by selecting a 50% interval splitted into 2 subintervals

A one 90% interval can be displayed using only one interval

or 75 subintervals in order to better represent the continuous distribution of the data within this interval

A List of data frames is returned and the percentiles are not plotted by setting plot=FALSE

## [1] "proba" "color" "y"
## [1] 0.1 0.3 0.5 0.5 0.7 0.9
## [1] "#9A35FF33" "#9A35FF80" "#9A35FFFF" "#9A35FF80" "#9A35FF33"
##   time      10%      30%      50%      50%      70%       90%
## 1  0.0 0.000000 0.000000 0.000000 0.000000 0.000000  0.000000
## 2  0.5 1.856938 2.864419 3.762692 3.762692 4.952836  7.288577
## 3  1.0 3.098585 4.496711 5.764983 5.764983 7.308034 10.269165
## 4  1.5 3.827213 5.444827 6.817854 6.817854 8.429400 11.225729
## 5  2.0 4.276883 5.905203 7.244816 7.244816 8.747637 11.347721


Using prctilemlx with groups

We now define 4 treatment groups:

By default, column “group” is used - if it exists - to make subplots

facet_wrap is used by prctilemlx with the default settings to produce these subplots. These default settings can be modified using facet_wrap explicitely

A single plot is produced with group=“none” as input argument

Covariates, such as the time of dose, or the dose amount can be added to the data frame resC and used as categorical covariates to define groups.

These covariates can now be used separately as factors to make subplots