Skip to contents

[Stable]

Function for generating random Adverse Event Analysis Dataset for a given Subject-Level Analysis Dataset.

Usage

radae(
  adsl,
  max_n_aes = 10L,
  lookup = NULL,
  lookup_aag = NULL,
  seed = NULL,
  na_percentage = 0,
  na_vars = list(AEBODSYS = c(NA, 0.1), AEDECOD = c(1234, 0.1), AETOXGR = c(1234, 0.1)),
  cached = FALSE
)

Arguments

adsl

(data.frame)
Subject-Level Analysis Dataset (ADSL).

max_n_aes

(integer)
Maximum number of AEs per patient. Defaults to 10.

lookup

(data.frame)
Additional parameters.

lookup_aag

(data.frame)
Additional metadata parameters.

seed

(numeric)
Seed to use for reproducible random number generation.

na_percentage

(proportion)
Default percentage of values to be replaced by NA.

na_vars

(list)
A named list where the name of each element is a column name of ds. Each element of this list should be a numeric vector with two elements:

  • seed (numeric)
    The seed to be used for this element - can be NA.

  • percentage (proportion)
    Percentage of elements to be replaced with NA. If NA, na_percentage is used as a default.

cached

boolean whether the cached ADAE data cadae should be returned or new data should be generated. If set to TRUE then the other arguments to radae will be ignored.

Value

data.frame

Details

One record per each record in the corresponding SDTM domain.

Keys: STUDYID, USUBJID, ASTDTM, AETERM, AESEQ

Examples

adsl <- radsl(N = 10, study_duration = 2, seed = 1)

adae <- radae(adsl, seed = 2)
adae
#> # A tibble: 51 × 92
#>    STUDYID USUBJID    SUBJID SITEID   AGE AGEU  SEX   RACE  ETHNIC COUNTRY DTHFL
#>    <chr>   <chr>      <chr>  <chr>  <int> <fct> <fct> <fct> <fct>  <fct>   <fct>
#>  1 AB12345 AB12345-B… id-9   BRA-1     35 YEARS F     BLAC… UNKNO… BRA     N    
#>  2 AB12345 AB12345-B… id-9   BRA-1     35 YEARS F     BLAC… UNKNO… BRA     N    
#>  3 AB12345 AB12345-B… id-9   BRA-1     35 YEARS F     BLAC… UNKNO… BRA     N    
#>  4 AB12345 AB12345-B… id-9   BRA-1     35 YEARS F     BLAC… UNKNO… BRA     N    
#>  5 AB12345 AB12345-B… id-9   BRA-1     35 YEARS F     BLAC… UNKNO… BRA     N    
#>  6 AB12345 AB12345-B… id-8   BRA-9     31 YEARS F     ASIAN NOT H… BRA     Y    
#>  7 AB12345 AB12345-B… id-8   BRA-9     31 YEARS F     ASIAN NOT H… BRA     Y    
#>  8 AB12345 AB12345-B… id-8   BRA-9     31 YEARS F     ASIAN NOT H… BRA     Y    
#>  9 AB12345 AB12345-B… id-8   BRA-9     31 YEARS F     ASIAN NOT H… BRA     Y    
#> 10 AB12345 AB12345-B… id-8   BRA-9     31 YEARS F     ASIAN NOT H… BRA     Y    
#> # ℹ 41 more rows
#> # ℹ 81 more variables: INVID <chr>, INVNAM <chr>, ARM <fct>, ARMCD <fct>,
#> #   ACTARM <fct>, ACTARMCD <fct>, TRT01P <fct>, TRT01A <fct>, TRT02P <fct>,
#> #   TRT02A <fct>, REGION1 <fct>, STRATA1 <fct>, STRATA2 <fct>, BMRKR1 <dbl>,
#> #   BMRKR2 <fct>, ITTFL <fct>, SAFFL <fct>, BMEASIFL <fct>, BEP01FL <fct>,
#> #   AEWITHFL <fct>, RANDDT <date>, TRTSDTM <dttm>, TRTEDTM <dttm>,
#> #   TRT01SDTM <dttm>, TRT01EDTM <dttm>, TRT02SDTM <dttm>, TRT02EDTM <dttm>, …

# Add metadata.
aag <- utils::read.table(
  sep = ",", header = TRUE,
  text = paste(
    "NAMVAR,SRCVAR,GRPTYPE,REFNAME,REFTERM,SCOPE",
    "CQ01NAM,AEDECOD,CUSTOM,D.2.1.5.3/A.1.1.1.1 AESI,dcd D.2.1.5.3,",
    "CQ01NAM,AEDECOD,CUSTOM,D.2.1.5.3/A.1.1.1.1 AESI,dcd A.1.1.1.1,",
    "SMQ01NAM,AEDECOD,SMQ,C.1.1.1.3/B.2.2.3.1 AESI,dcd C.1.1.1.3,BROAD",
    "SMQ01NAM,AEDECOD,SMQ,C.1.1.1.3/B.2.2.3.1 AESI,dcd B.2.2.3.1,BROAD",
    "SMQ02NAM,AEDECOD,SMQ,Y.9.9.9.9/Z.9.9.9.9 AESI,dcd Y.9.9.9.9,NARROW",
    "SMQ02NAM,AEDECOD,SMQ,Y.9.9.9.9/Z.9.9.9.9 AESI,dcd Z.9.9.9.9,NARROW",
    sep = "\n"
  ), stringsAsFactors = FALSE
)

adae <- radae(adsl, lookup_aag = aag)

with(
  adae,
  cbind(
    table(AEDECOD, SMQ01NAM),
    table(AEDECOD, CQ01NAM)
  )
)
#>               C.1.1.1.3/B.2.2.3.1 AESI D.2.1.5.3/A.1.1.1.1 AESI
#> dcd A.1.1.1.1                        0                        9
#> dcd A.1.1.1.2                        0                        0
#> dcd B.1.1.1.1                        0                        0
#> dcd B.2.1.2.1                        0                        0
#> dcd B.2.2.3.1                       11                        0
#> dcd C.1.1.1.3                       10                        0
#> dcd C.2.1.2.1                        0                        0
#> dcd D.1.1.1.1                        0                        0
#> dcd D.1.1.4.2                        0                        0
#> dcd D.2.1.5.3                        0                        6