Title: | Extension of 'lixoftConnectors' for 'Simulx' |
---|---|
Description: | Provides useful tools which supplement the use of 'Simulx' software and 'R' connectors ('Monolix Suite'). 'Simulx' is an easy, efficient and flexible application for clinical trial simulations. You need 'Simulx' software to be installed in order to use 'RsSimulx' package. Among others tasks, 'RsSimulx' provides the same functions as package 'mlxR' does with a compatibility with 'Simulx' software. |
Authors: | Clemence Pinaud [aut], Jonathan Chauvin [aut], Marc Lavielle [aut], Frano Mihaljevic [aut], Chloe Bracis [aut, cre] |
Maintainer: | Chloe Bracis <[email protected]> |
License: | BSD_2_clause + file LICENSE |
Version: | 2024.1 |
Built: | 2024-11-08 06:37:56 UTC |
Source: | CRAN |
Plot the empirical distribution of categorical longitudinal data.
catplotmlx( r, col = NULL, breaks = NULL, plot = TRUE, color = "#194280", group = NULL, facet = TRUE, labels = NULL )
catplotmlx( r, col = NULL, breaks = NULL, plot = TRUE, color = "#194280", group = NULL, facet = TRUE, labels = NULL )
r |
a data frame with a column ‘id’, a column ‘time’, a column with values and possibly Hk[ja column ‘group’. |
col |
a vector of 3 column numbers: (‘id’, ‘time/x’, ‘y’. Default = c(1, 2,3). |
breaks |
one of:
|
plot |
if |
color |
a color to be used for the plots (default="#194280") |
group |
variable to be used for defining groups (by default, ‘group’ is used when it exists) |
facet |
makes subplots for different groups if |
labels |
vector of strings |
See http://simulx.webpopix.org/mlxr/catplotmlx/ for more details.
a ggplot object if plot=TRUE
; otherwise, a list with fields:
color a vector of colors used for the plot
y a data frame with the values of the empirical distribution computed at each time point
## Not run: catModel <- inlineModel(" [LONGITUDINAL] input = {a,b} EQUATION: lp1=a-b*t lp2=a-b*t/2 DEFINITION: y = {type=categorical, categories={1,2,3}, logit(P(y<=1))=lp1, logit(P(y<=2))=lp2} ") y.out <- list(name='y', time=seq(0, 100, by=4)) Ng <- 1000 g1 <- list(size=Ng, parameter=c(a=6,b=0.2)) res <- simulx(model=catModel, output=y.out, group=g1) catplotmlx(res$y) catplotmlx(res$y, breaks=seq(-2,102,by=8), color="purple") catplotmlx(res$y, breaks=5, color="#490917") g2 <- list(size=Ng, parameter=c(a=10,b=0.2)) res <- simulx(model=catModel, output=y.out, group=list(g1,g2)) catplotmlx(res$y) catplotmlx(res$y, group="none") g3 <- list(size=Ng, parameter=c(a=6,b=0.4)) g4 <- list(size=Ng, parameter=c(a=10,b=0.4)) res <- simulx(model=catModel, output=y.out, group=list(g1,g2,g3,g4)) catplotmlx(res$y) cov <- data.frame(id=levels(res$y$id), a=rep(c(6,10,6,10),each=Ng), b=rep(c(0.2,0.2,0.4,0.4),each=Ng)) catplotmlx(res$y, group=cov) ## End(Not run)
## Not run: catModel <- inlineModel(" [LONGITUDINAL] input = {a,b} EQUATION: lp1=a-b*t lp2=a-b*t/2 DEFINITION: y = {type=categorical, categories={1,2,3}, logit(P(y<=1))=lp1, logit(P(y<=2))=lp2} ") y.out <- list(name='y', time=seq(0, 100, by=4)) Ng <- 1000 g1 <- list(size=Ng, parameter=c(a=6,b=0.2)) res <- simulx(model=catModel, output=y.out, group=g1) catplotmlx(res$y) catplotmlx(res$y, breaks=seq(-2,102,by=8), color="purple") catplotmlx(res$y, breaks=5, color="#490917") g2 <- list(size=Ng, parameter=c(a=10,b=0.2)) res <- simulx(model=catModel, output=y.out, group=list(g1,g2)) catplotmlx(res$y) catplotmlx(res$y, group="none") g3 <- list(size=Ng, parameter=c(a=6,b=0.4)) g4 <- list(size=Ng, parameter=c(a=10,b=0.4)) res <- simulx(model=catModel, output=y.out, group=list(g1,g2,g3,g4)) catplotmlx(res$y) cov <- data.frame(id=levels(res$y$id), a=rep(c(6,10,6,10),each=Ng), b=rep(c(0.2,0.2,0.4,0.4),each=Ng)) catplotmlx(res$y, group=cov) ## End(Not run)
Compute the area under the curve, the maximum and minimum values of a function of time over a given interval or at steady state
exposure( model = NULL, output = NULL, group = NULL, treatment = NULL, parameter = NULL, data = NULL, project = NULL, settings = NULL, regressor = NULL, varlevel = NULL )
exposure( model = NULL, output = NULL, group = NULL, treatment = NULL, parameter = NULL, data = NULL, project = NULL, settings = NULL, regressor = NULL, varlevel = NULL )
model |
a |
output |
a list with fields:
|
group |
a list, or a list of lists, with fields:
|
treatment |
a list with fields
|
parameter |
a vector of parameters with their names and values |
data |
a list |
project |
the name of a Monolix project |
settings |
a list of optional settings
|
regressor |
a list, or a list of lists, with fields
|
varlevel |
a list, or a list of lists, with fields
|
Input arguments are the input arguments of Simulx (http://simulx.webpopix.org)
Specific input arguments can be also used for computing the exposure at steady state, i.e. after the administration of an "infinite" number of doses. See http://simulx.webpopix.org/exposure/ for more details.
A list of data frames. One data frame per output is created with columns id
(if number of subject >1),
group
(if number of groups >1), t1
(beginning of time interval), t2
(end of time interval),
step
(time step), auc
(area under the curve), tmax
(time of maximum value), cmax
(maximum value),
tmin
(time of minimum value), cmin
(minimum value).
wrapper around ggplot
with a custom theme
ggplotmlx(...)
ggplotmlx(...)
... |
parameters passed to |
see ggplot
Initialize RsSimulx library
initRsSimulx(path = NULL, ...)
initRsSimulx(path = NULL, ...)
path |
(character) (optional) Path to installation directory of the Lixoft suite. If RsSimulx library is not already loaded and no path is given, the directory written in the lixoft.ini file is used for initialization. |
... |
(optional) Extra arguments passed to lixoftConnectors package when RsSimulx is used with a version of Lixoft(/@) software suite.
|
A list:
software
: the software that is used (should be simulx)
path
: the path to MonolixSuite
version
: the version of MonolixSuite that is used
status
: boolean equaling TRUE if the initialization has been successful.
## Not run: initRsSimulx(path = "/path/to/lixoftRuntime/") ## End(Not run)
## Not run: initRsSimulx(path = "/path/to/lixoftRuntime/") ## End(Not run)
Convert a string in dataframe and save it in a temporary file
inlineDataFrame(str)
inlineDataFrame(str)
str |
(string) Dataframe in string format |
dataframe object
## Not run: occ <- inlineDataFrame(" id time occ 1 0 1 1 12 2 1 24 3 2 0 1 2 24 2 3 0 1 ") ## End(Not run)
## Not run: occ <- inlineDataFrame(" id time occ 1 0 1 1 12 2 1 24 3 2 0 1 2 24 2 3 0 1 ") ## End(Not run)
Save a string in a temporary file to be used as a model file
inlineModel(srtIn, filename = NULL)
inlineModel(srtIn, filename = NULL)
srtIn |
(string) Model in string format, |
filename |
(string) name of the model file (by default the model is saved in a temporary file) |
Name of the model file
## 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} ") ## End(Not run)
## 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} ") ## End(Not run)
Plot empirical survival functions using the Kaplan Meier estimate.
kmplotmlx( r, index = 1, level = NULL, time = NULL, cens = TRUE, plot = TRUE, color = "#e05969", group = NULL, facet = TRUE, labels = NULL )
kmplotmlx( r, index = 1, level = NULL, time = NULL, cens = TRUE, plot = TRUE, color = "#e05969", group = NULL, facet = TRUE, labels = NULL )
r |
a data frame with a column ‘id’, a column ‘time’, a column with values and possibly a column ‘group’. |
index |
an integer: |
level |
a number between 0 and 1: confidence interval level. |
time |
a vector of time points where the survival function is evaluated. |
cens |
if |
plot |
if |
color |
color to be used for the plots (default="#e05969") |
group |
variable to be used for defining groups (by default, ‘group’ is used when it exists) |
facet |
makes subplots for different groups if |
labels |
vector of strings |
See http://simulx.webpopix.org/mlxr/kmplotmlx/ for more details.
a ggplot object if plot=TRUE
; otherwise, a list with fields:
surv
a data frame with columns T
(time), S
(survival), possibly (S1, S2)
(confidence interval) and possibly group
cens
a data frame with columns T0
(time), S0
(survival) and possibly group
## Not run: tteModel1 <- inlineModel(" [LONGITUDINAL] input = {beta,lambda} EQUATION: h=(beta/lambda)*(t/lambda)^(beta-1) DEFINITION: e = {type=event, maxEventNumber=1, rightCensoringTime=70, hazard=h} ") p1 <- c(beta=2.5,lambda=50) e <- list(name='e', time=0) res1 <- simulx(model=tteModel1, parameter=p1, output=e, group=list(size=100)) pl1 <- kmplotmlx(res1$e,level=0.95) print(pl1) p2 <- c(beta=2,lambda=45) g1 <- list(size=50, parameter=p1) g2 <- list(size=100, parameter=p2) res2 <- simulx(model=tteModel1, output=e, group=list(g1,g2)) pl2 <- kmplotmlx(res2$e) print(pl2) ## End(Not run)
## Not run: tteModel1 <- inlineModel(" [LONGITUDINAL] input = {beta,lambda} EQUATION: h=(beta/lambda)*(t/lambda)^(beta-1) DEFINITION: e = {type=event, maxEventNumber=1, rightCensoringTime=70, hazard=h} ") p1 <- c(beta=2.5,lambda=50) e <- list(name='e', time=0) res1 <- simulx(model=tteModel1, parameter=p1, output=e, group=list(size=100)) pl1 <- kmplotmlx(res1$e,level=0.95) print(pl1) p2 <- c(beta=2,lambda=45) g1 <- list(size=50, parameter=p1) g2 <- list(size=100, parameter=p2) res2 <- simulx(model=tteModel1, output=e, group=list(g1,g2)) pl2 <- kmplotmlx(res2$e) print(pl2) ## End(Not run)
Utility function to read Lixoft@ formated input/output files
lixoft.read.table(file, sep = "", ...)
lixoft.read.table(file, sep = "", ...)
file |
file path of the file to read |
sep |
separator |
... |
see |
a dataframe object
Compute and display percentiles of the empiricial distribution of longitudinal data.
prctilemlx( r = NULL, col = NULL, project = NULL, outputVariableName = NULL, number = 8, level = 80, plot = TRUE, color = NULL, group = NULL, facet = TRUE, labels = NULL, band = NULL )
prctilemlx( r = NULL, col = NULL, project = NULL, outputVariableName = NULL, number = 8, level = 80, plot = TRUE, color = NULL, group = NULL, facet = TRUE, labels = NULL, band = NULL )
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/x’ and ‘y’. Default = c(1, 2,3). |
project |
simulx project filename (with extension ".smlx") |
outputVariableName |
name of the output to consider. By default the first output will be consider. You must define either a 'r' dataframe and the associated 'col' argument or a simulx project and the name of the output 'outputVariableName" |
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 |
color |
colors to be used for the plots In case of one group or facet = TRUE, only the first color will be used |
group |
variable to be used for defining groups (by default, ‘group’ is used when it exists) |
facet |
makes subplots for different groups if |
labels |
vector of strings |
band |
is deprecated (use number and level instead) ; a list with two fields
|
See http://simulx.webpopix.org/mlxr/prctilemlx/ for more details.
a ggplot object if plot=TRUE
; otherwise, 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
## Not run: 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.1))) # res$C is a data.frame with 2000x241=482000 rows and 3 columns head(res$C) # we can display the empirical percentiles of C using the default # settings (i.e. percentiles of order 10%, 20%, ... 90%) prctilemlx(res$C) # The 3 quartiles (i.e. percentiles of order 25%, 50% and 75%) are displayed by # selecting a 50% interval splitted into 2 subintervals prctilemlx(res$C, number=2, level=50) # A one 90% interval can be displayed using only one interval prctilemlx(res$C, number=1, level=90) # or 75 subintervals in order to better represent the continuous distribution # of the data within this interval prctilemlx(res$C, number=75, level=90) # prctilemlx produces a ggplot object that can be modified pl <- prctilemlx(res$C, number=4, level=80) pl + ylab("concentration") + ggtitle("predictive distribution") # The percentiles are not plotted by setting plot=FALSE pr.out <- prctilemlx(res$C, number=4, level=80, plot=FALSE) print(pr.out$proba) print(pr.out$color) print(pr.out$y[1:5,]) ## End(Not run)
## Not run: 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.1))) # res$C is a data.frame with 2000x241=482000 rows and 3 columns head(res$C) # we can display the empirical percentiles of C using the default # settings (i.e. percentiles of order 10%, 20%, ... 90%) prctilemlx(res$C) # The 3 quartiles (i.e. percentiles of order 25%, 50% and 75%) are displayed by # selecting a 50% interval splitted into 2 subintervals prctilemlx(res$C, number=2, level=50) # A one 90% interval can be displayed using only one interval prctilemlx(res$C, number=1, level=90) # or 75 subintervals in order to better represent the continuous distribution # of the data within this interval prctilemlx(res$C, number=75, level=90) # prctilemlx produces a ggplot object that can be modified pl <- prctilemlx(res$C, number=4, level=80) pl + ylab("concentration") + ggtitle("predictive distribution") # The percentiles are not plotted by setting plot=FALSE pr.out <- prctilemlx(res$C, number=4, level=80, plot=FALSE) print(pr.out$proba) print(pr.out$color) print(pr.out$y[1:5,]) ## End(Not run)
Reads a table into a vector
read.vector(f, header = FALSE, sep = "", quote = "\"'")
read.vector(f, header = FALSE, sep = "", quote = "\"'")
f |
: path to table file |
header |
: bool, use the header or not |
sep |
: the separator |
quote |
: the quote character |
the vector
Model definition corresponding to rssimulxDemo.smlx project
rssimulxDemo.model
rssimulxDemo.model
A vector of string
Simulx model
rssimulxDemo.smlx is a Simulx project. In this demo three groups with different dose levels are simulated: low, medium and high. Groups have the same number of individuals, population parameters, distribution of covariates and outputs.
rssimulxDemo.project
rssimulxDemo.project
A vector of string
Simulx project
Creates a Shiny application for longitudinal data model
shinymlx( model, parameter = NULL, output = NULL, treatment = NULL, regressor = NULL, group = NULL, data = NULL, appname, style = "basic", settings = NULL, title = " " )
shinymlx( model, parameter = NULL, output = NULL, treatment = NULL, regressor = NULL, group = NULL, data = NULL, appname, style = "basic", settings = NULL, title = " " )
model |
a |
parameter |
a vector, or a list of shiny widgets |
output |
a list - or a list of lists - with fields:
|
treatment |
a list with fields
Input argument of Simulx can also be used, i.e. a list with fields |
regressor |
a list, or a list of lists, with fields
|
group |
a list, or a list of lists, with fields:
|
data |
a datafile to display with the plot |
appname |
the name of the application (and possibly its path) |
style |
the style of the Shiny app
|
settings |
a list of settings
|
title |
the title of the application |
shinymlx automatically generates files ui.R and server.R required for a Shiny application.
Elements of parameters
and treatment
can be either scalars or lists.
A scalar automatically generates a slider with default minimum and maximum values and default step.
A list may contain the type of widget ("slider", "select", "numeric") and the settings defining the widget:
(value, min, max, step) for slider
, (selected, choices) for select
and
value for numeric
.
See http://simulx.webpopix.org/mlxr/shinymlx/ for more details.
A Shiny app with files ui.R, server.R and model.txt
## Not run: PKPDmodel <- inlineModel(" [LONGITUDINAL] input={ka,V,Cl,Imax,IC50,S0,kout} EQUATION: C = pkmodel(ka, V, Cl) E_0 = S0 ddt_E = kout*((1-Imax*C/(C+IC50))*S0- E) ") p1 <- c(ka=0.5, V=10, Cl=1) p2 <- c(Imax=0.5, IC50=0.03, S0=100, kout=0.1) adm <- list(tfd=5, nd=15, ii=12, amount=1) f1 <- list(name = 'C', time = seq(0, 250, by=1)) f2 <- list(name = 'E', time = seq(0, 250, by=1)) f <- list(f1, f2) shinymlx(model=PKPDmodel, treatment=adm, parameter=list(p1,p2), output=f, style="dashboard1", appname=tempdir()) #------------------------------------------------------------------------ p1 <- list( ka = list(widget="slider", value=0.5, min=0.1, max=2, step=0.1), V = list(widget="slider", value=10, min=2, max=20, step=2), Cl = list(widget="slider", value=1, min=0.1, max=2, step=0.1) ) adm <- list( tfd = list(widget="slider", value=5, min=0, max=100, step=5), nd = list(widget="numeric", value=15), ii = list(widget="select", selected=12, choices=c(3,6,12,18,24)), amount = list(widget="slider", value=40, min=0, max=50, step=5) ) s <- list(select.x=FALSE, select.y=FALSE) shinymlx(model=PKPDmodel, treatment=adm, parameter=list(p1,p2), output=f, style="navbar1", settings=s, appname=tempdir()) ## End(Not run)
## Not run: PKPDmodel <- inlineModel(" [LONGITUDINAL] input={ka,V,Cl,Imax,IC50,S0,kout} EQUATION: C = pkmodel(ka, V, Cl) E_0 = S0 ddt_E = kout*((1-Imax*C/(C+IC50))*S0- E) ") p1 <- c(ka=0.5, V=10, Cl=1) p2 <- c(Imax=0.5, IC50=0.03, S0=100, kout=0.1) adm <- list(tfd=5, nd=15, ii=12, amount=1) f1 <- list(name = 'C', time = seq(0, 250, by=1)) f2 <- list(name = 'E', time = seq(0, 250, by=1)) f <- list(f1, f2) shinymlx(model=PKPDmodel, treatment=adm, parameter=list(p1,p2), output=f, style="dashboard1", appname=tempdir()) #------------------------------------------------------------------------ p1 <- list( ka = list(widget="slider", value=0.5, min=0.1, max=2, step=0.1), V = list(widget="slider", value=10, min=2, max=20, step=2), Cl = list(widget="slider", value=1, min=0.1, max=2, step=0.1) ) adm <- list( tfd = list(widget="slider", value=5, min=0, max=100, step=5), nd = list(widget="numeric", value=15), ii = list(widget="select", selected=12, choices=c(3,6,12,18,24)), amount = list(widget="slider", value=40, min=0, max=50, step=5) ) s <- list(select.x=FALSE, select.y=FALSE) shinymlx(model=PKPDmodel, treatment=adm, parameter=list(p1,p2), output=f, style="navbar1", settings=s, appname=tempdir()) ## End(Not run)
Draw population parameters using the covariance matrix of the estimates
simpopmlx( n = 1, project = NULL, fim = NULL, parameter = NULL, corr = NULL, kw.max = 100, outputFilename = NULL, sep = ",", seed = NULL )
simpopmlx( n = 1, project = NULL, fim = NULL, parameter = NULL, corr = NULL, kw.max = 100, outputFilename = NULL, sep = ",", seed = NULL )
n |
(integer) the number of vectors of population parameters (default = 1), |
project |
(string) a Monolix project, assuming that the Fisher information Matrix was estimated by Monolix. |
fim |
the (string) Fisher Information Matrix estimated by Monolix. fim = c("sa", "lin") (default="sa") |
parameter |
(data.frame) a data frame with the following columns
Only when project is not used. |
corr |
(matrix) correlation matrix of the population parameters (default = identity). Only when project is not used. |
kw.max |
(integer) maximum number of trials for generating a positive definite covariance matrix (default = 100) |
outputFilename |
(string) when defined, path where the population parameters dataframe will be saved It must be a a file with a csv or txt extension. If no extension is specified, file will be saved by default in csv format |
sep |
(string) file separator when outputFilename is defined (default = ",") |
seed |
(integer) initialization of the random number generator (integer) (by default a random seed will be generated) |
See http://simulx.webpopix.org/mlxr/simpopmlx/ for more details.
dataframe object with generated population parameters
## Not run: param <- data.frame(pop.param=c(1.5, 0.5, 0.02, 0.4, 0.15, 0.2, 0.7), sd=c(0.2, 0.05, 0.004, 0.05, 0.02, 0.02, 0.05), trans=c('N','N','N','L','L','L','N')) pop <- simpopmlx(n=3, parameter=param) ## End(Not run)
## Not run: param <- data.frame(pop.param=c(1.5, 0.5, 0.02, 0.4, 0.15, 0.2, 0.7), sd=c(0.2, 0.05, 0.004, 0.05, 0.02, 0.02, 0.05), trans=c('N','N','N','L','L','L','N')) pop <- simpopmlx(n=3, parameter=param) ## End(Not run)
Compute predictions and sample data from Mlxtran
and R
models
simulx( model = NULL, parameter = NULL, covariate = NULL, output = NULL, treatment = NULL, regressor = NULL, occasion = NULL, varlevel = NULL, group = NULL, project = NULL, nrep = 1, npop = NULL, fim = NULL, saveSmlxProject = NULL, result.file = NULL, addlines = NULL, settings = NULL )
simulx( model = NULL, parameter = NULL, covariate = NULL, output = NULL, treatment = NULL, regressor = NULL, occasion = NULL, varlevel = NULL, group = NULL, project = NULL, nrep = 1, npop = NULL, fim = NULL, saveSmlxProject = NULL, result.file = NULL, addlines = NULL, settings = NULL )
model |
a |
parameter |
One of
|
covariate |
One of
|
output |
output or list of outputs. An output can be defined by
|
treatment |
treatment or list of treatments. A treatment can be defined by
|
regressor |
treatment or list of treatments. A treatment can be defined by
|
occasion |
An occasion can be defined by
|
varlevel |
deprecated, use occasion instead. |
group |
a list, or a list of lists, with fields:
"level" field is not supported anymore in RsSimulx. |
project |
the name of a Monolix project |
nrep |
Samples with or without uncertainty depending which element is given as "parameter". |
npop |
deprecated, Set parameter = "mlx_popUncertainSA" or "mlx_popUncertainLin" instead. |
fim |
deprecated, Set parameter = "mlx_popUncertainSA" or "mlx_popUncertainLin" instead. |
saveSmlxProject |
If specified, smlx project will be save in the path location (by default smlx project is not saved) |
result.file |
deprecated |
addlines |
a list with fields:
"section", "block" field are not supported anymore in RsSimulx. You only need to specify a formula. The additional lines will be added in a new section EQUATION. |
settings |
a list of optional settings
|
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’. ‘Mlxtran’ models are automatically converted into C++ codes, compiled on the fly and linked to R using the ‘RJSONIO’ 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.lixoft.com for more details.
A list of data frames. Each data frame is an output of simulx
## 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)) parameter <- c(A=100, k_pop=6, omega=0.3, c=10, a=2) res <- simulx(model = myModel, parameter = parameter, occasion = data.frame(time=c(0, 0), occ=c(1, 2)), output = list(f,y), group = list(size=4), saveSmlxProject = "./project.smlx") res <- simulx(model = myModel, parameter = parameter, occasion = data.frame(time = c(0, 0, 0, 0), occ1 = c(1, 1, 2, 2), occ2 = c(1, 2, 3, 4)), output = list(f,y), group = list(size=4)) res <- simulx(model = myModel, parameter = parameter, output = list(f,y), group = list(size=4)) 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)
## 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)) parameter <- c(A=100, k_pop=6, omega=0.3, c=10, a=2) res <- simulx(model = myModel, parameter = parameter, occasion = data.frame(time=c(0, 0), occ=c(1, 2)), output = list(f,y), group = list(size=4), saveSmlxProject = "./project.smlx") res <- simulx(model = myModel, parameter = parameter, occasion = data.frame(time = c(0, 0, 0, 0), occ1 = c(1, 1, 2, 2), occ2 = c(1, 2, 3, 4)), output = list(f,y), group = list(size=4)) res <- simulx(model = myModel, parameter = parameter, output = list(f,y), group = list(size=4)) 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)
Compute statistical summaries (mean, quantile, variance, survival rate,...)
statmlx(r, FUN = "mean", probs = c(0.05, 0.5, 0.95), surv.time = NULL)
statmlx(r, FUN = "mean", probs = c(0.05, 0.5, 0.95), surv.time = NULL)
r |
a data frame |
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 |
surv.time |
a scalar or a vector of times. Only used when "event" has been defined in |
See http://simulx.webpopix.org/stamlx for more details.
A data frame.
## Not run: 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} ") adm <- list(amount=100, time=0) 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 <- list(out.y, out.e) g <- list(size=100) 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)) statmlx(res1$parameter, FUN = "quantile", probs = c(0.05, 0.5, 0.95)) statmlx(res1$parameter, FUN = c("sd", "quantile"), probs = c(0.05, 0.95)) statmlx(res1$y, FUN = c("mean", "sd", "quantile"), probs = c(0.05, 0.95)) statmlx(res1$e, surv.time=c(10,20)) 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)) statmlx(res2$y, FUN = c("mean", "sd", "quantile"), probs = c(0.05, 0.95)) statmlx(res2$e, surv.time=c(10,20,30)) ## End(Not run)
## Not run: 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} ") adm <- list(amount=100, time=0) 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 <- list(out.y, out.e) g <- list(size=100) 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)) statmlx(res1$parameter, FUN = "quantile", probs = c(0.05, 0.5, 0.95)) statmlx(res1$parameter, FUN = c("sd", "quantile"), probs = c(0.05, 0.95)) statmlx(res1$y, FUN = c("mean", "sd", "quantile"), probs = c(0.05, 0.95)) statmlx(res1$e, surv.time=c(10,20)) 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)) statmlx(res2$y, FUN = c("mean", "sd", "quantile"), probs = c(0.05, 0.95)) statmlx(res2$e, surv.time=c(10,20,30)) ## End(Not run)