Select and modify a idata set for simulation
The individual data set (idata_set
) is a data frame with one
row for each individual in a population, specifying parameters and
other individual-level data.
idata_set(x, data, ...) ## S4 method for signature 'mrgmod,data.frame' idata_set( x, data, .subset = TRUE, .select = TRUE, object = NULL, need = NULL, ... ) ## S4 method for signature 'mrgmod,ANY' idata_set(x, data, ...) ## S4 method for signature 'mrgmod,missing' idata_set(x, object, ...)
x |
model object |
data |
a data set that can be coerced to data.frame |
... |
passed along |
.subset |
an unquoted expression passed to
|
.select |
passed to |
object |
character name of an object existing in |
need |
passed to |
The idata_set
is a data.frame that specifies individual-level
data for the problem. An ID
column is required and there
can be no more than one row in the data frame for each individual.
In most cases, the columns in the idata_set
have the same names
as parameters in the param
list. When this is the case,
the parameter set is updated as the simulation proceeds once at the
start of each individual. The 'idata_set' can also be used to
set initial conditions for each individual: for a compartment called
CMT
, make a column in idata_set
called CMT_0
and
make the value the desired initial value for that compartment. Note that
this initial condition will be over-ridden if you also set the CMT_0
in $MAIN
.
It is also possible to provide both a data_set
and a idata_set
.
In this case, the idata_set
is used as a parameter lookup for IDs
found in the data_set
. Remember in this case, it is the data_set
(not the idata_set
) that determines the number of individuals in the
simulation.
An error will be generated if any parameter columns in the
input idata set contain NA
.
mod <- mrgsolve::house() data(exidata) exidata mod %>% idata_set(exidata, ID <= 2) %>% ev(amt = 100) %>% mrgsim() %>% plot() mod %>% idata_set(exidata) %>% ev(amt = 100) %>% mrgsim() mod %>% ev(amt = 100) %>% mrgsim(idata=exidata)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.