openpharma / brms.mmrm

R package to run Bayesian MMRMs using {brms}
https://openpharma.github.io/brms.mmrm/
Other
18 stars 2 forks source link

Support constrained longitudinal data analysis (cLDA) in some informative prior archetypes #126

Closed wlandau closed 3 months ago

wlandau commented 3 months ago

Constrained longitudinal data analysis (cLDA) is a type of analysis where all treatment groups are pooled together at baseline. cLDA may result in more precise estimates when the time variable has a baseline level and the baseline outcomes are recorded before randomization in a clinical trial.

As noted in https://github.com/openpharma/brms.mmrm/discussions/112, cLDA is hard for discrete time models like MMRMs. It really requires taking manual control of the model matrix. Fortunately, that's exactly what informative prior archetypes already do.

An example, take a simulated dataset with 2 groups and 2 time points.

library(brms.mmrm)
library(dplyr)
set.seed(0L)
data <- brm_simulate_outline(
  n_group = 2,
  n_patient = 100,
  n_time = 2,
  rate_dropout = 0,
  rate_lapse = 0
) |>
  mutate(response = rnorm(n()))
#> # A tibble: 400 × 5
#>    patient     time   group   missing response
#>    <chr>       <chr>  <chr>   <lgl>      <dbl>
#>  1 patient_001 time_1 group_1 FALSE    1.26   
#>  2 patient_001 time_2 group_1 FALSE   -0.326  
#>  3 patient_002 time_1 group_1 FALSE    1.33   
#>  4 patient_002 time_2 group_1 FALSE    1.27   
#>  5 patient_003 time_1 group_1 FALSE    0.415  
#>  6 patient_003 time_2 group_1 FALSE   -1.54   
#>  7 patient_004 time_1 group_1 FALSE   -0.929  
#>  8 patient_004 time_2 group_1 FALSE   -0.295  
#>  9 patient_005 time_1 group_1 FALSE   -0.00577
#> 10 patient_005 time_2 group_1 FALSE    2.40   
#> # ℹ 390 more rows
#> # ℹ Use `print(n = ...)` to see more rows

This is what the treatment effect archetype normally looks like.

summary(brm_archetype_effects(data))
#> # This is the "effects" informative prior archetype in brms.mmrm.
#> # The following equations show the relationships between the
#> # marginal means (left-hand side) and fixed effect parameters
#> # (right-hand side).
#> # 
#> #   group_1:time_1 = x_group_1_time_1
#> #   group_1:time_2 = x_group_1_time_2
#> #   group_2:time_1 = x_group_1_time_1 + x_group_2_time_1
#> #   group_2:time_2 = x_group_1_time_2 + x_group_2_time_2

If we apply the cLDA constraint, then group_1:time_1 and group_2:time_1 are pooled.

summary(brm_archetype_effects(data, clda = TRUE))
# This is the "effects" informative prior archetype in brms.mmrm.
# The following equations show the relationships between the
# marginal means (left-hand side) and fixed effect parameters
# (right-hand side).
# 
#   group_1:time_1 = x_group_1_time_1
#   group_1:time_2 = x_group_1_time_2
#   group_2:time_1 = x_group_1_time_1
#   group_2:time_2 = x_group_1_time_2 + x_group_2_time_2

Other remarks: