Compute and display percentiles of the empiricial distribution of longitudinal data.
If plot=TRUE: a ggplot object
If plot=FALSE: a list with fields
We simulate longitudinal data for \(N=2000\) individuals using simulx
myModel <- inlineModel("
[LONGITUDINAL]
input = {ka, V, Cl}
EQUATION:
C = pkmodel(ka,V,Cl)
[INDIVIDUAL]
input = {ka_pop, V_pop, Cl_pop, omega_ka, omega_V, omega_Cl}
DEFINITION:
ka = {distribution=lognormal, reference=ka_pop, sd=omega_ka}
V = {distribution=lognormal, reference=V_pop, sd=omega_V }
Cl = {distribution=lognormal, reference=Cl_pop, sd=omega_Cl}
")
N=2000
pop.param <- c(
ka_pop = 1, omega_ka = 0.5,
V_pop = 10, omega_V = 0.4,
Cl_pop = 1, omega_Cl = 0.3)
res <- simulx(model = myModel,
parameter = pop.param,
treatment = list(time=0, amount=100),
group = list(size=N, level='individual'),
output = list(name='C', time=seq(0,24,by=0.5)))
## [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
We now define 4 treatment groups:
Ng=400
g1 <- list(size=Ng, level='individual', treatment = list(time=0, amount=60))
g2 <- list(size=Ng, level='individual', treatment = list(time=0, amount=100))
g3 <- list(size=Ng, level='individual', treatment = list(time=3, amount=60))
g4 <- list(size=Ng, level='individual', treatment = list(time=3, amount=100))
t.out <- seq(0,24,by=0.5)
res <- simulx(model = myModel,
parameter = pop.param,
group = list(g1, g2, g3, g4),
output = list(name='C', time=t.out))
By default, column
labels <- c("60 mg - 0h ", "100 mg - 0h", "60 mg - 3h ", "100 mg - 3h")
resC <- res$C
prctilemlx(resC, label=labels) + theme(legend.position = "none")
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
Covariates, such as the time of dose, or the dose amount can be added to the data frame
resC$doseTime <- 0
resC$doseTime[res$C$group %in% c(3,4)] <- 3
resC$doseAmount <- 60
resC$doseAmount[res$C$group %in% c(2,4)] <- 100
These covariates can now be used separately as factors to make subplots