Skip to contents

Columns will be extended by repeating last value of the column if needed in order to match length of other columns. Combinations of different columns can be generated by specifying covariates on the columns where the regimens differ.

Usage

NMcreateDoses(
  TIME,
  AMT = NULL,
  EVID = 1,
  CMT = 1,
  ADDL = NULL,
  II = NULL,
  RATE = NULL,
  SS = NULL,
  addl = NULL,
  addl.lastonly = TRUE,
  col.id = "ID",
  as.fun
)

Arguments

TIME

The time of the dosing events. Required.

AMT

vector or data.frame with amounts amount. Required.

EVID

The event ID to use for doses. Default is to use EVID=1, but EVID might also be wanted.

CMT

Compartment number. Default is to dose into CMT=1. Use `CMT=NA` to omit in result.

ADDL

Number of additional dose events. Must be in combination with and consistent with II. Notice if of length 1, only applied to last event in each regimen.

II

Dosing frequency of additional events specified in `ADDL`. See `ADDL` too.

RATE

Infusion rate. Optional.

SS

steady-state flag. Optional.

addl

A list of ADDL and II that will be applied to last dose. This may be prefered if II and ADDL depend on covariates - see examples. Optional.

addl.lastonly

If ADDL and II are of length 1, apply only to last event of a regimen? The default is `TRUE`.

col.id

Default is to denote the dosing regimens by an ID column. The name of the column can be modified using this argument. Use `col.id=NA` to omit the column altogether. The latter may be wanted if repeating the regimen for a number of subjects after running `NMcreateDoses()`.

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.

Value

A data.frame with dosing events

Details

Only TIME and AMT are required. AMT, RATE, SS, II, ADDL, CMT are 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. All these arguments can be data.frames with additional columns that define distinct dosing regimens - with distinct subject ids. However, if covariates are applied to ADDL+II, see the addl argument and see examples.

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.
## The default, addl.lastonly=TRUE means if ADDL and II are of
## length 1, they only apply to last event.
NMcreateDoses(TIME=c(0,12),AMT=c(2,1),ADDL=9*2,II=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))
## multiple dose regimens. 
## 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
## ADDL and II can be wrapped in a data.frame. This allows including covariates
NMcreateDoses(TIME=c(0,12),AMT=c(2,1),addl=data.frame(ADDL=c(NA,9*2),II=c(NA,12),trt=c("A","B")))
#>   ID TIME EVID CMT AMT II ADDL MDV trt
#> 1  1    0    1   1   2 NA   NA   1   A
#> 2  1   12    1   1   1 NA   NA   1   A
#> 3  2    0    1   1   2 NA   NA   1   B
#> 4  2   12    1   1   1 12   18   1   B