make_poppk.RdInterleaves dosing and observation records in time order per subject and
returns them in the column structure a population PK estimation tool expects
— ID, TIME, TAD, AMT, DV, MDV, EVID, CMT and the
subject-level covariates.
make_poppk(pc, ex, adsl, covariates = NULL)Concentration data with USUBJID, PARAMCD, AVAL and AFRLT.
The output of make_adpc() is a valid input, and is the recommended one:
the BLQ policy has then already been applied and recorded.
Dosing data with USUBJID, EXDOSE and AFRLT (dose time in
hours from first dose). NFRLT is used for NTIM when present.
Subject-level dataset with USUBJID, source of the covariates.
Character vector of adsl columns to carry onto every
record. NULL (the default) carries none.
An eradam_poppk object: a tibble::tibble of interleaved dosing
and observation records.
Records are sorted by ID, then TIME, then EVID descending. The last key
is what makes a dose administered at the same nominal instant as a sample
come first, which is the ordering the estimation software requires: a
concentration recorded at TIME reflects the dose already given. A trough
sample intended to be taken before a dose must therefore carry a TIME
strictly less than the dose time, which is exactly what actual (rather than
nominal) sampling times give you.
ID, TIME, AMT, DV, MDV, EVID and CMT are NONMEM data items and
carry their NONMEM meanings (see the NONMEM Users Guide, Beal, Sheiner,
Boeckmann & Bauer): EVID = 1 is a dose, EVID = 0 an observation, MDV = 1 marks a record with no dependent variable. TAD and BLQ are not NONMEM
data items but are near-universal additions; NTIM, USUBJID and PARAMCD
are carried by this package so a record can be traced back to its source.
The compartment numbering — 1 for dosing, 2 and upwards for each analyte
in sorted order — is a convention chosen by this package, not a standard. It
matches the usual first-order absorption layout for a single analyte and is
deterministic for more than one. Renumber it if your model differs.
DV is left as NA where it is missing. Write the dataset out with
write.csv(x, na = ".") for tools that require a dot.
| Variable | Meaning | Source |
ID | Sequential integer subject identifier (1..n), the estimation tools' key | Derived from USUBJID |
USUBJID | Unique subject identifier, retained for traceability | pc / ex |
TIME | Actual time from first dose (h) | pc$AFRLT / ex$AFRLT |
NTIM | Nominal time from first dose (h) | pc$NFRLT / ex$NFRLT |
TAD | Actual time after the most recent dose (h) | Derived |
AMT | Dose amount on dosing records, NA on observation records | ex |
DV | Dependent variable (observed concentration); NA on dosing and BLQ records | pc |
MDV | Missing dependent variable flag: 1 when DV is missing, else 0 | Derived |
EVID | Event identifier: 1 = dosing record, 0 = observation record | Derived |
CMT | Compartment: 1 = dosing, 2.. = one per analyte in sorted order | Derived |
BLQ | 1 when the observation was below the limit of quantification, else 0 | Derived |
PARAMCD | Analyte code for observation records, NA for dosing records | pc |
<covariates> | Subject-level covariates carried from ADSL | adsl (argument covariates) |
pc <- eradam_example("pc")
ex <- eradam_example("ex")
adsl <- eradam_example("adsl")
pk <- make_poppk(pc, ex, adsl, covariates = c("AGE", "SEX", "WTBL", "CRCL"))
pk
#>
#> ── eradam population PK dataset ────────────────────────────────────────────────
#> ℹ 624 record(s): 48 dosing, 576 observation
#> ℹ 24 subject(s) | TIME 0 to 48.079 h | 48 observation(s) with MDV=1
#> ℹ Compartments: 1 = dosing, 2 = DRUGX, 3 = DRUGXM1
#> # A tibble: 624 × 16
#> ID USUBJID TIME NTIM TAD AMT DV MDV EVID CMT BLQ PARAMCD
#> <int> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <int> <int> <int> <chr>
#> 1 1 ERADAM01… 0 0 0 25 NA 1 1 1 0 NA
#> 2 1 ERADAM01… 0 0 0 NA NA 1 0 2 1 DRUGX
#> 3 1 ERADAM01… 0 0 0 NA NA 1 0 3 1 DRUGXM1
#> 4 1 ERADAM01… 0.497 0.5 0.497 NA 79.6 0 0 3 0 DRUGXM1
#> 5 1 ERADAM01… 0.58 0.5 0.58 NA 230. 0 0 2 0 DRUGX
#> 6 1 ERADAM01… 1.01 1 1.01 NA 348. 0 0 2 0 DRUGX
#> 7 1 ERADAM01… 1.07 1 1.07 NA 127. 0 0 3 0 DRUGXM1
#> 8 1 ERADAM01… 2.03 2 2.03 NA 378. 0 0 2 0 DRUGX
#> 9 1 ERADAM01… 2.04 2 2.04 NA 141. 0 0 3 0 DRUGXM1
#> 10 1 ERADAM01… 4.03 4 4.03 NA 355. 0 0 2 0 DRUGX
#> # ℹ 614 more rows
#> # ℹ 4 more variables: AGE <int>, SEX <chr>, WTBL <dbl>, CRCL <dbl>
# one subject, showing the dose / observation interleave
head(pk[pk$ID == 1, c("ID", "TIME", "TAD", "AMT", "DV", "MDV", "EVID", "CMT")], 12)
#>
#> ── eradam population PK dataset ────────────────────────────────────────────────
#> ℹ 12 record(s): 1 dosing, 11 observation
#> ℹ 1 subject(s) | TIME 0 to 7.969 h | 2 observation(s) with MDV=1
#> ℹ Compartments: 1 = dosing, 2 = DRUGX, 3 = DRUGXM1
#> # A tibble: 12 × 8
#> ID TIME TAD AMT DV MDV EVID CMT
#> <int> <dbl> <dbl> <dbl> <dbl> <int> <int> <int>
#> 1 1 0 0 25 NA 1 1 1
#> 2 1 0 0 NA NA 1 0 2
#> 3 1 0 0 NA NA 1 0 3
#> 4 1 0.497 0.497 NA 79.6 0 0 3
#> 5 1 0.58 0.58 NA 230. 0 0 2
#> 6 1 1.01 1.01 NA 348. 0 0 2
#> 7 1 1.07 1.07 NA 127. 0 0 3
#> 8 1 2.03 2.03 NA 378. 0 0 2
#> 9 1 2.04 2.04 NA 141. 0 0 3
#> 10 1 4.03 4.03 NA 355. 0 0 2
#> 11 1 4.08 4.08 NA 136. 0 0 3
#> 12 1 7.97 7.97 NA 87.8 0 0 3