Combinations of different columns can be generated. Columns will be extended by repeating last value of the column if needed in order to match length of other columns.
Usage
NMcreateDoses(
TIME,
AMT = NULL,
RATE = NULL,
SS = NULL,
CMT = 1,
EVID = 1,
addl = NULL,
as.fun
)
Arguments
- TIME
The time of the dosing events
- AMT
vector or dataa.frame with amounts amount
- RATE
Optional infusion rate
- SS
Optional steady-state flag
- CMT
Compartment number. Default is to dose into CMT=1.
- EVID
The event ID to use for doses. Default is to use EVID=1, but EVID might also be wanted.
- addl
Optinal. A list of ADDL and II that will be applied to last dose
- as.fun
The default is to return data as a data.frame. Pass a function (say `tibble::as_tibble`) in as.fun to convert to something else. If data.tables are wanted, use as.fun="data.table". The default can be configured using NMdataConf.
Details
Experimental. Please check output before use. AMT, RATE, SS, II, CMT are vectors of length 1 or longer. Those not of max length 1 are repeated. If TIME is longer than those, they are extended to match length of TIME. Allowed combinations of AMT, RATE, SS, II here: https://ascpt.onlinelibrary.wiley.com/doi/10.1002/psp4.12404
Examples
library(data.table)
## Users should not use setDTthreads. This is for CRAN to only use 1 core.
data.table::setDTthreads(1)
## arguments are expanded - makes loading easy
NMcreateDoses(TIME=c(0,12,24,36),AMT=c(2,1))
#> ID TIME EVID CMT AMT MDV
#> 1 1 0 1 1 2 1
#> 2 1 12 1 1 1 1
#> 3 1 24 1 1 1 1
#> 4 1 36 1 1 1 1
## Different doses by covariate
NMcreateDoses(TIME=c(0,12,24),AMT=data.table(AMT=c(2,1,4,2),DOSE=c(1,2)))
#> ID TIME EVID CMT AMT MDV DOSE
#> 1 1 0 1 1 2 1 1
#> 2 1 12 1 1 4 1 1
#> 3 1 24 1 1 4 1 1
#> 4 2 0 1 1 1 1 2
#> 5 2 12 1 1 2 1 2
#> 6 2 24 1 1 2 1 2
## Make Nonmem repeat the last dose. This is a total of 20 dosing events.
NMcreateDoses(TIME=c(0,12),AMT=c(2,1),addl=list(ADDL=c(NA,9*2),II=c(NA,12)))
#> ID TIME EVID CMT AMT II ADDL MDV
#> 1 1 0 1 1 2 NA NA 1
#> 2 1 12 1 1 1 12 18 1
dt.amt <- data.table(DOSE=c(100,400))
dt.amt[,AMT:=DOSE*1000]
#> DOSE AMT
#> <num> <num>
#> 1: 100 1e+05
#> 2: 400 4e+05
dt.amt
#> DOSE AMT
#> <num> <num>
#> 1: 100 1e+05
#> 2: 400 4e+05
doses.sd <- NMcreateDoses(TIME=0,AMT=dt.amt)
doses.sd$dose <- paste(doses.sd$DOSE,"mg")
doses.sd$regimen <- "SD"
doses.sd
#> ID TIME EVID CMT AMT MDV DOSE dose regimen
#> 1 1 0 1 1 1e+05 1 100 100 mg SD
#> 2 2 0 1 1 4e+05 1 400 400 mg SD
### multiple dose regimens with loading are easily created with NMcreateDoses too
## Specifying the time points explicitly
dt.amt <- data.table(AMT=c(200,100,800,400)*1000,DOSE=c(100,100,400,400))
doses.md.1 <- NMcreateDoses(TIME=seq(0,by=24,length.out=7),AMT=dt.amt)
doses.md.1$dose <- paste(doses.md.1$DOSE,"mg")
doses.md.1$regimen <- "QD"
doses.md.1
#> ID TIME EVID CMT AMT MDV DOSE dose regimen
#> 1 1 0 1 1 2e+05 1 100 100 mg QD
#> 2 1 24 1 1 1e+05 1 100 100 mg QD
#> 3 1 48 1 1 1e+05 1 100 100 mg QD
#> 4 1 72 1 1 1e+05 1 100 100 mg QD
#> 5 1 96 1 1 1e+05 1 100 100 mg QD
#> 6 1 120 1 1 1e+05 1 100 100 mg QD
#> 7 1 144 1 1 1e+05 1 100 100 mg QD
#> 8 2 0 1 1 8e+05 1 400 400 mg QD
#> 9 2 24 1 1 4e+05 1 400 400 mg QD
#> 10 2 48 1 1 4e+05 1 400 400 mg QD
#> 11 2 72 1 1 4e+05 1 400 400 mg QD
#> 12 2 96 1 1 4e+05 1 400 400 mg QD
#> 13 2 120 1 1 4e+05 1 400 400 mg QD
#> 14 2 144 1 1 4e+05 1 400 400 mg QD
## or using ADDL+II
dt.amt <- data.table(AMT=c(200,100,800,400)*1000,DOSE=c(100,100,400,400))
doses.md.2 <- NMcreateDoses(TIME=c(0,24),AMT=dt.amt,addl=data.table(ADDL=c(0,5),II=c(0,24)))
doses.md.2$dose <- paste(doses.md.2$DOSE,"mg")
doses.md.2$regimen <- "QD"
doses.md.2
#> ID TIME EVID CMT AMT II ADDL MDV DOSE dose regimen
#> 1 1 0 1 1 2e+05 0 0 1 100 100 mg QD
#> 2 1 24 1 1 1e+05 24 5 1 100 100 mg QD
#> 3 2 0 1 1 8e+05 0 0 1 400 400 mg QD
#> 4 2 24 1 1 4e+05 24 5 1 400 400 mg QD