Skip to contents

This function compiles the subject-level data into a format analogous to an ADaM ADSL dataset (one record per subject). It includes key baseline and outcome variables for each patient.

Usage

export_adam_format(data, study_id = "STUDY1")

Arguments

data

A data frame containing patient-level data (after simulation of allocation, outcomes, etc.). This typically would be the data frame after calling the simulation functions.

study_id

Character, an identifier for the study (used to construct STUDYID and USUBJID). Default is "STUDY1".

Value

A data frame with one row per patient, containing columns such as:

  • STUDYID: Study identifier (all patients have the same value).

  • USUBJID: Unique Subject ID (concatenation of STUDYID and subject ID).

  • ID: Subject numeric ID (from simulation).

  • Country, Site: If present in input, these are included.

  • Arm: Treatment arm.

  • Age, Sex: Demographics.

  • SeriousAE: Indicator of serious adverse event occurrence (if simulated).

  • DropoutTime, Dropped: Dropout time and status (if simulated).

  • EventTime, EventStatus: Time-to-event and event occurrence flag (if simulated).

  • Outcome: Outcome value (continuous or binary) if simulated.

Details

This function gathers all relevant patient-level information (demographics, treatment, dropouts, events, outcomes) into a single dataset. It is analogous to creating an ADSL (Subject-Level Analysis Dataset) in clinical data standards. The USUBJID is generated by combining study_id and the patient's ID. If certain fields (like outcomes or events) were not simulated, they will simply be omitted or contain NA.

Examples

df <- simulate_patients(5)
df <- simulate_allocation(df)
df <- simulate_survival(df, median_time_control = 6, hr = 0.8, study_duration = 12)
df <- simulate_dropout(df, dropout_rate = 0.2, study_duration = 12, p_ae = 0.2, dropout_hr_ae = 2)
df <- simulate_outcomes(df, outcome_type = "continuous", outcome_mean_control = 100, outcome_diff = -5)
adsl <- export_adam_format(df, study_id = "SIMStudy")
head(adsl)
#>    STUDYID    USUBJID ID  Country  Site       Arm Age    Sex SeriousAE
#> 1 SIMStudy SIMStudy-1  1 Country1 Site1   Control  44   Male     FALSE
#> 2 SIMStudy SIMStudy-2  2 Country1 Site1 Treatment  57   Male      TRUE
#> 3 SIMStudy SIMStudy-3  3 Country1 Site1   Control  41 Female     FALSE
#> 4 SIMStudy SIMStudy-4  4 Country1 Site1   Control  45   Male     FALSE
#> 5 SIMStudy SIMStudy-5  5 Country1 Site1 Treatment  41 Female     FALSE
#>   DropoutTime Dropped  EventTime EventStatus  Outcome
#> 1          NA   FALSE  0.5230485           1       NA
#> 2          NA   FALSE  4.2377121           1       NA
#> 3          NA   FALSE  3.2643457           1       NA
#> 4          NA   FALSE 12.0000000           0 100.0792
#> 5          NA   FALSE  4.4673161           1       NA