Learn R Programming

mlxR (version 4.2.0)

simulx: Simulation of mixed effects models and longitudinal data

Description

Compute predictions and sample data from Mlxtran and R models

Usage

simulx(
  model = NULL,
  parameter = NULL,
  output = NULL,
  treatment = NULL,
  regressor = NULL,
  varlevel = NULL,
  group = NULL,
  data = NULL,
  project = NULL,
  nrep = 1,
  npop = NULL,
  fim = NULL,
  result.folder = NULL,
  result.file = NULL,
  stat.f = "statmlx",
  addlines = NULL,
  settings = NULL
)

Arguments

model

a Mlxtran, or R model used for the simulation

parameter

a vector of parameters with their names and values

output

a list (or list of lists) with fields:

  • name: a vector of output names

  • time: a vector of times (only for the longitudinal outputs)

  • lloq: lower limit of quantification (only for the longitudinal outputs)

  • uloq: upper limit of quantification (only for the longitudinal outputs)

  • limit: lower bound of the censoring interval (only for the longitudinal outputs)

treatment

a list with fields

  • time : a vector of input times,

  • amount : a scalar or a vector of amounts,

  • rate : a scalar or a vector of infusion rates (default=Inf),

  • tinf : a scalar or a vector of infusion times (default=0),

  • type : the type of input (default=1),

  • target : the target compartment (default=NULL).

regressor

a list, or a list of lists, with fields

  • name : a vector of regressor names,

  • time : a vector of times,

  • value : a vector of values.

varlevel

(IOV supported by mlxR >= 3.2.2) a list (or a dataframe) with fields:

  • name : name of the variable which defines the occasions,

  • time : a vector of times (beginnings of occasions) ,

group

a list, or a list of lists, with fields:

  • size : size of the group (default=1),

  • level : level(s) of randomization,

  • parameter : if different parameters per group are defined,

  • output : if different outputs per group are defined,

  • treatment : if different treatements per group are defined,

  • regressor : if different regression variables per group are defined.

data

a list (output of simulx when settings$data.in==TRUE)

project

the name of a Monolix project

nrep

number of replicates

npop

number of population parameters to draw randomly

fim

a string with the Fisher Information Matrix to be used

result.folder

the name of the folder where the outputs of simulx should be stored

result.file

the name of the single file where the outputs of simulx should be saved

stat.f

a R function for computing some summary (mean, quantiles, survival,...) of the simulated data. Default = "statmlx".

addlines

a list with fields:

  • section: a string (default = "[LONGITUDINAL]"),

  • block: a string (default = "EQUATION:"),

  • formula: string, or vector of strings, to be inserted .

settings

a list of optional settings

  • seed : initialization of the random number generator (integer),

  • load.design : TRUE/FALSE (if load.design is not defined, a test is automatically performed to check if a new design has been defined),

  • data.in : TRUE/FALSE (default=FALSE)

  • id.out : add columns id (when N=1) and group (when #group=1), TRUE/FALSE (default=FALSE)

  • kw.max : maximum number of trials for generating a positive definite covariance matrix (default = 100)

  • sep : the field separator character (default = ",")

  • digits : number of decimal digits in output files (default = 5)

  • disp.iter : TRUE/FALSE (default = FALSE) display replicate and population numbers

  • replacement : TRUE/FALSE (default = FALSE) sample id's with/without replacement

  • out.trt : TRUE/FALSE (default = TRUE) output of simulx includes treatment

  • format.original : TRUE/FALSE (default = FALSE) with a Monolix project, write data in result.file using the original format of the data file

Value

A list of data frames. Each data frame is an output of simulx

Details

simulx takes advantage of the modularity of hierarchical models for simulating different components of a model: models for population parameters, individual covariates, individual parameters and longitudinal data.

Furthermore, simulx allows to draw different types of longitudinal data, including continuous, count, categorical, and time-to-event data.

The models are encoded using either the model coding language Mlxtran, or R. Mlxtran models are automatically converted into C++ codes, compiled on the fly and linked to R using the Rcpp package. That allows one to implement very easily complex models and to take advantage of the numerical sovers used by the C++ mlxLibrary.

See http://simulx.webpopix.org for more details.

Examples

Run this code
# NOT RUN {
myModel <- inlineModel("
[LONGITUDINAL]
input = {A, k, c, a}
EQUATION:
t0    = 0 
f_0   = A
ddt_f = -k*f/(c+f)
DEFINITION:
y = {distribution=normal, prediction=f, sd=a}
[INDIVIDUAL]
input = {k_pop, omega}
DEFINITION:
k = {distribution=lognormal, prediction=k_pop, sd=omega}
")
f <- list(name='f', time=seq(0, 30, by=0.1))
y <- list(name='y', time=seq(0, 30, by=2))
res <- simulx(model     = 'model/home.txt', 
              parameter = c(A=100, k_pop=6, omega=0.3, c=10, a=2), 
              output    = list(f,y,"k"),
              group     = list(size=4, level='individual'))

plot(ggplotmlx() + geom_line(data=res$f, aes(x=time, y=f, colour=id)) +
     geom_point(data=res$y, aes(x=time, y=y, colour=id)))
print(res$parameter)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab