Compute contrast observations for prediction plots

compute_contrast_observations(
  data,
  conc_col,
  dv_col,
  id_col = NULL,
  ntime_col = NULL,
  trt_col = NULL,
  treatment_predictors,
  control_predictors = NULL,
  contrast_method = c("matched", "group")
)

Arguments

data

A data frame containing C-QT analysis dataset

conc_col

An unquoted column name for drug concentration measurements

dv_col

An unquoted column name for dQTC measurements

id_col

An unquoted column name for subject ID, used when control predictors is provided to compute delta delta dv

ntime_col

An unquoted column name for Nominal time data, used when control predictors is provided to compute delta delta dv

trt_col

An unquoted column name for Treatment group data, used when control predictors is provided to compute delta delta dv

treatment_predictors

A list for predictions with model. Should contain a value for each predictor in the model.

control_predictors

An optional list for contrast predictions

contrast_method

A string specifying contrast method: "matched" for individual ID+time matching (crossover studies), "group" for group-wise subtraction (parallel studies)

Value

a tibble with columns: group, conc, dv

Examples

data_proc <- preprocess(cqtkit_data_verapamil)

# Simple case: no control group
obs_data <- compute_contrast_observations(
  data_proc,
  CONC,
  deltaQTCF,
  treatment_predictors = list(TRTG = "Verapamil HCL")
)
obs_data
#> # A tibble: 643 × 3
#>    group         conc     dv
#>    <chr>        <dbl>  <dbl>
#>  1 Observations     0  -6.00
#>  2 Observations     0 -12.1 
#>  3 Observations     0  -5.54
#>  4 Observations     0 -22.5 
#>  5 Observations     0   1.33
#>  6 Observations     0  -6.58
#>  7 Observations     0 -12.4 
#>  8 Observations     0 -11.1 
#>  9 Observations     0  -7.66
#> 10 Observations     0  -2.73
#> # ℹ 633 more rows

# Matched contrast (crossover study)
contrast_data <- compute_contrast_observations(
  data_proc,
  CONC,
  deltaQTCF,
  ID,
  NTLD,
  TRTG,
  treatment_predictors = list(TRTG = "Verapamil HCL"),
  control_predictors = list(TRTG = "Placebo"),
  contrast_method = "matched"
)
#> Warning: Observed data contained NA and are removed in plot
contrast_data
#> # A tibble: 313 × 3
#>    group          conc      dv
#>    <fct>         <dbl>   <dbl>
#>  1 Verapamil HCL 180     1.57 
#>  2 Verapamil HCL  51.5   4.59 
#>  3 Verapamil HCL  46.1   6.69 
#>  4 Verapamil HCL 251    11.0  
#>  5 Verapamil HCL  72.6 -11.7  
#>  6 Verapamil HCL 201     1.36 
#>  7 Verapamil HCL  91.1  -3.85 
#>  8 Verapamil HCL  50     1.43 
#>  9 Verapamil HCL 368     8.08 
#> 10 Verapamil HCL  37.8  -0.910
#> # ℹ 303 more rows