simulx {mlxR} | R Documentation |
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 |
parameter |
a vector of parameters with their names and values |
output |
a list (or list of lists) with fields:
|
treatment |
a list with fields
|
regressor |
a list, or a list of lists, with fields
|
varlevel |
(IOV supported by mlxR >= 3.2.2) a list (or a dataframe) with fields:
|
group |
a list, or a list of lists, with fields:
|
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:
|
settings |
a list of optional settings
|
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.
Value
A list of data frames. Each data frame is an output of simulx
Examples
## 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)
## End(Not run)