# Overview

### Description

Compute statistical summaries (mean, quantile, variance, survival rate,…).

### Usage

statmlx(r, FUN = "mean", probs = c(0.05, 0.5, 0.95), surv.time = NULL)

### Arguments

r

a data frame with a column id

FUN
a string, or a vector of strings, with the name of the functions to apply to the result of the simulation
probs
a vector of quantiles between 0 and 1. Only used when “quantile” has been defined in FUN
surv.time
a scalar or a vector of times. Only used when “event” has been defined in type

a data frame.

# Example

modelPK <- inlineModel("
[LONGITUDINAL]
input={V,Cl,alpha, beta,b}

EQUATION:
C = pkmodel(V, Cl)
h = alpha*exp(beta*C)
g = b*C

DEFINITION:
y = {distribution=normal, prediction=C, sd=g}
e = {type=event, maxEventNumber=1, rightCensoringTime=30, hazard=h}

[INDIVIDUAL]
input={V_pop,Cl_pop,omega_V,omega_Cl}

DEFINITION:
V     = {distribution=lognormal,   prediction=V_pop,    sd=omega_V}
Cl    = {distribution=lognormal,   prediction=Cl_pop,   sd=omega_Cl}
")

p <- c(V_pop=10, Cl_pop=1, omega_V=0.2, omega_Cl=0.2, alpha=0.02, beta=0.1, b=0.1)
out.y <- list(name=c('y'), time=seq(0,to=25,by=5))
out.e <- list(name=c('e'), time=0)
out.p <- c("V", "Cl")
out   <- list(out.y, out.e, out.p)
g <- list(size=100, level='individual')
res1 <- simulx(model=modelPK, treatment=adm, parameter=p, output=out, group=g)

statmlx(res1$parameter, FUN = "mean", probs = c(0.05, 0.5, 0.95)) ## V.mean Cl.mean ## 1 9.969501 1.036478 statmlx(res1$parameter, FUN = "quantile", probs = c(0.05, 0.5, 0.95))
##       V.p5    V.p50    V.p95     Cl.p5   Cl.p50  Cl.p95
## 1 7.019093 9.793523 13.63576 0.7178817 1.009096 1.35869
statmlx(res1$parameter, FUN = c("sd", "quantile"), probs = c(0.05, 0.95)) ## V.sd Cl.sd V.p5 V.p95 Cl.p5 Cl.p95 ## 1 2.043081 0.2077799 7.019093 13.63576 0.7178817 1.35869 statmlx(res1$y, FUN = c("mean", "sd", "quantile"), probs = c(0.05, 0.95))
##   time    y.mean      y.sd      y.p5     y.p95
## 1    0 10.535686 2.6212657 7.1130011 15.550966
## 2    5  5.952406 1.1044299 4.4479002  7.937862
## 3   10  3.562256 0.8502199 2.1583114  4.846527
## 4   15  2.164859 0.7152647 0.9690118  3.277802
## 5   20  1.346530 0.6300538 0.4959100  2.444517
## 6   25  0.821922 0.4661239 0.2003308  1.659805
statmlx(res1$e, surv.time=c(10,20)) ## nbEv.mean S10.mean S20.mean ## 1 0.54 0.66 0.55 res2 <- simulx(model=modelPK, treatment=adm, parameter=p, output=out, group=g, nrep=3) statmlx(res2$parameter, FUN = c("sd", "quantile"), probs = c(0.05, 0.95))
##   rep     V.sd     Cl.sd     V.p5    V.p95     Cl.p5   Cl.p95
## 1   1 1.939749 0.2037007 7.306562 13.66448 0.6888649 1.385989
## 2   2 1.893999 0.1906323 7.132597 13.35825 0.7621168 1.337626
## 3   3 2.199653 0.2185287 6.768731 14.30711 0.7286057 1.392313
statmlx(res2$y, FUN = c("mean", "sd", "quantile"), probs = c(0.05, 0.95)) ## rep time y.mean y.sd y.p5 y.p95 ## 1 1 0 10.1144277 2.2243339 7.1335559 14.180775 ## 6 1 5 5.9394820 1.0273917 4.4452792 7.638762 ## 2 1 10 3.5763951 0.8414190 2.4475447 5.231923 ## 3 1 15 2.2278511 0.7101219 1.2328961 3.392880 ## 4 1 20 1.4259167 0.6571777 0.5217088 2.568685 ## 5 1 25 0.8935595 0.4855395 0.2335966 1.893633 ## 7 2 0 10.2574542 2.3028597 7.5312769 14.363056 ## 12 2 5 5.8818721 0.9480403 4.5388938 7.415848 ## 8 2 10 3.5073769 0.7534486 2.3795024 4.870014 ## 9 2 15 2.0984433 0.6427705 1.1985939 3.318352 ## 10 2 20 1.2929610 0.5380213 0.5807938 2.145744 ## 11 2 25 0.8046209 0.4389352 0.2471807 1.659595 ## 13 3 0 10.4919131 2.6750420 6.8879726 16.316569 ## 18 3 5 5.8996841 1.0455990 4.3416591 7.340654 ## 14 3 10 3.4425944 0.8919046 2.1941400 4.935049 ## 15 3 15 2.1084913 0.7488834 0.8973219 3.254879 ## 16 3 20 1.2889323 0.6453135 0.3735315 2.436942 ## 17 3 25 0.8145553 0.4857325 0.1610931 1.772640 statmlx(res2$e, surv.time=c(10,20,30))
##   rep nbEv.mean S10.mean S20.mean S30.mean
## 1   1      0.62     0.60     0.46     0.38
## 2   2      0.53     0.68     0.52     0.47
## 3   3      0.51     0.69     0.59     0.49