documents many of the default priors set by `brms`. In particular, `"(flat)"` denotes an improper uniform prior over all the real numbers.
## Modeling and analysis
The downstream methods in `brms.mmrm` automatically understand how to work with informative prior archetypes. Notably, the formula uses custom interest and nuisance variables instead of the original variables in the data.
``` r
formula <- brm_formula(archetype)
formula
#> FEV1 ~ 0 + x_PBO_VIS1 + x_PBO_VIS2 + x_PBO_VIS3 + x_PBO_VIS4 + x_TRT_VIS1 + x_TRT_VIS2 + x_TRT_VIS3 + x_TRT_VIS4 + nuisance_WEIGHT + nuisance_SEX_Male + unstr(time = AVISIT, gr = USUBJID)
#> sigma ~ 0 + AVISIT
```
The model can accept the archetype, formula, and prior. Usage is the same as in non-archetype workflows.
``` r
model <- brm_model(
data = archetype,
formula = formula,
prior = prior,
refresh = 0
)
#> Compiling Stan program...
#> Start sampling
brms::prior_summary(model)
#> prior class coef group resp dpar nlpar lb ub
#> (flat) b
#> (flat) b nuisance_SEX_Male
#> (flat) b nuisance_WEIGHT
#> student_t(4, -7.57, 4.96) b x_PBO_VIS1
#> student_t(4, 3.14, 7.86) b x_PBO_VIS2
#> student_t(4, 8.78, 8.18) b x_PBO_VIS3
#> student_t(4, 3.36, 8.10) b x_PBO_VIS4
#> student_t(4, -2.96, 4.78) b x_TRT_VIS1
#> student_t(4, 3.13, 7.64) b x_TRT_VIS2
#> student_t(4, 7.65, 8.24) b x_TRT_VIS3
#> student_t(4, 4.64, 8.21) b x_TRT_VIS4
#> (flat) b sigma
#> (flat) b AVISITVIS1 sigma
#> (flat) b AVISITVIS2 sigma
#> (flat) b AVISITVIS3 sigma
#> (flat) b AVISITVIS4 sigma
#> lkj_corr_cholesky(1) Lcortime
#> source
#> default
#> (vectorized)
#> (vectorized)
#> user
#> user
#> user
#> user
#> user
#> user
#> user
#> user
#> default
#> (vectorized)
#> (vectorized)
#> (vectorized)
#> (vectorized)
#> default
```
Marginal mean estimation, post-processing, and visualization automatically understand the archetype without any user intervention.
``` r
draws <- brm_marginal_draws(
data = archetype,
formula = formula,
model = model
)
summaries_model <- brm_marginal_summaries(draws)
summaries_data <- brm_marginal_data(archetype)
brm_plot_compare(model = summaries_model, data = summaries_data)
```
## All archetypes
`brms.mmrm` supports a variety of informative prior archetypes with different kinds of fixed effects. For example, `brms.mmrm` supports simple cell mean and treatment effect parameterizations.
``` r
summary(brm_archetype_cells(data, intercept = FALSE))
#> # This is the "cells" 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).
#> #
#> # PBO:VIS1 = x_PBO_VIS1
#> # PBO:VIS2 = x_PBO_VIS2
#> # PBO:VIS3 = x_PBO_VIS3
#> # PBO:VIS4 = x_PBO_VIS4
#> # TRT:VIS1 = x_TRT_VIS1
#> # TRT:VIS2 = x_TRT_VIS2
#> # TRT:VIS3 = x_TRT_VIS3
#> # TRT:VIS4 = x_TRT_VIS4
```
``` r
summary(brm_archetype_effects(data, intercept = FALSE))
#> # 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).
#> #
#> # PBO:VIS1 = x_PBO_VIS1
#> # PBO:VIS2 = x_PBO_VIS2
#> # PBO:VIS3 = x_PBO_VIS3
#> # PBO:VIS4 = x_PBO_VIS4
#> # TRT:VIS1 = x_PBO_VIS1 + x_TRT_VIS1
#> # TRT:VIS2 = x_PBO_VIS2 + x_TRT_VIS2
#> # TRT:VIS3 = x_PBO_VIS3 + x_TRT_VIS3
#> # TRT:VIS4 = x_PBO_VIS4 + x_TRT_VIS4
```
There are archetypes to parameterize the average across all time points in the data. Below, `x_group_1_time_2` is the average across time points for group 1 because it is the algebraic result of simplifying `(group_1:time_2 + group_1:time_3 + group_1:time_3) / 3`.
``` r
summary(brm_archetype_average_cells(data, intercept = FALSE))
#> # This is the "average cells" 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).
#> #
#> # PBO:VIS1 = 4*x_PBO_VIS1 - x_PBO_VIS2 - x_PBO_VIS3 - x_PBO_VIS4
#> # PBO:VIS2 = x_PBO_VIS2
#> # PBO:VIS3 = x_PBO_VIS3
#> # PBO:VIS4 = x_PBO_VIS4
#> # TRT:VIS1 = 4*x_TRT_VIS1 - x_TRT_VIS2 - x_TRT_VIS3 - x_TRT_VIS4
#> # TRT:VIS2 = x_TRT_VIS2
#> # TRT:VIS3 = x_TRT_VIS3
#> # TRT:VIS4 = x_TRT_VIS4
```
There is also a treatment effect version where `x_group_2_time_2` becomes the time-averaged treatment effect of group 2 relative to group 1.
``` r
summary(brm_archetype_average_effects(data, intercept = FALSE))
#> # This is the "average 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).
#> #
#> # PBO:VIS1 = 4*x_PBO_VIS1 - x_PBO_VIS2 - x_PBO_VIS3 - x_PBO_VIS4
#> # PBO:VIS2 = x_PBO_VIS2
#> # PBO:VIS3 = x_PBO_VIS3
#> # PBO:VIS4 = x_PBO_VIS4
#> # TRT:VIS1 = 4*x_PBO_VIS1 - x_PBO_VIS2 - x_PBO_VIS3 - x_PBO_VIS4 + 4*x_TRT_VIS1 - x_TRT_VIS2 - x_TRT_VIS3 - x_TRT_VIS4
#> # TRT:VIS2 = x_PBO_VIS2 + x_TRT_VIS2
#> # TRT:VIS3 = x_PBO_VIS3 + x_TRT_VIS3
#> # TRT:VIS4 = x_PBO_VIS4 + x_TRT_VIS4
```
The example in this vignette uses the "successive cells" archetype, where fixed effects represent successive differences between adjacent time points.
``` r
summary(brm_archetype_successive_cells(data, intercept = FALSE))
#> # This is the "successive cells" 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).
#> #
#> # PBO:VIS1 = x_PBO_VIS1
#> # PBO:VIS2 = x_PBO_VIS1 + x_PBO_VIS2
#> # PBO:VIS3 = x_PBO_VIS1 + x_PBO_VIS2 + x_PBO_VIS3
#> # PBO:VIS4 = x_PBO_VIS1 + x_PBO_VIS2 + x_PBO_VIS3 + x_PBO_VIS4
#> # TRT:VIS1 = x_TRT_VIS1
#> # TRT:VIS2 = x_TRT_VIS1 + x_TRT_VIS2
#> # TRT:VIS3 = x_TRT_VIS1 + x_TRT_VIS2 + x_TRT_VIS3
#> # TRT:VIS4 = x_TRT_VIS1 + x_TRT_VIS2 + x_TRT_VIS3 + x_TRT_VIS4
```
There is also a treatment effect version of the successive differences archetype:
``` r
summary(brm_archetype_successive_effects(data, intercept = FALSE))
#> # This is the "successive 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).
#> #
#> # PBO:VIS1 = x_PBO_VIS1
#> # PBO:VIS2 = x_PBO_VIS1 + x_PBO_VIS2
#> # PBO:VIS3 = x_PBO_VIS1 + x_PBO_VIS2 + x_PBO_VIS3
#> # PBO:VIS4 = x_PBO_VIS1 + x_PBO_VIS2 + x_PBO_VIS3 + x_PBO_VIS4
#> # TRT:VIS1 = x_PBO_VIS1 + x_TRT_VIS1
#> # TRT:VIS2 = x_PBO_VIS1 + x_PBO_VIS2 + x_TRT_VIS1 + x_TRT_VIS2
#> # TRT:VIS3 = x_PBO_VIS1 + x_PBO_VIS2 + x_PBO_VIS3 + x_TRT_VIS1 + x_TRT_VIS2 + x_TRT_VIS3
#> # TRT:VIS4 = x_PBO_VIS1 + x_PBO_VIS2 + x_PBO_VIS3 + x_PBO_VIS4 + x_TRT_VIS1 + x_TRT_VIS2 + x_TRT_VIS3 + x_TRT_VIS4
```
## Variations on archetypes
Archetypes can be customized. As an example, consider the simple cell means archetype.
``` r
summary(brm_archetype_cells(data))
#> # This is the "cells" 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).
#> #
#> # PBO:VIS1 = x_PBO_VIS1
#> # PBO:VIS2 = x_PBO_VIS2
#> # PBO:VIS3 = x_PBO_VIS3
#> # PBO:VIS4 = x_PBO_VIS4
#> # TRT:VIS1 = x_TRT_VIS1
#> # TRT:VIS2 = x_TRT_VIS2
#> # TRT:VIS3 = x_TRT_VIS3
#> # TRT:VIS4 = x_TRT_VIS4
```
To include an intercept term which all the marginal means share, set `intercept = TRUE`.
``` r
summary(brm_archetype_cells(data, intercept = TRUE))
#> # This is the "cells" 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).
#> #
#> # PBO:VIS1 = x_PBO_VIS1
#> # PBO:VIS2 = x_PBO_VIS1 + x_PBO_VIS2
#> # PBO:VIS3 = x_PBO_VIS1 + x_PBO_VIS3
#> # PBO:VIS4 = x_PBO_VIS1 + x_PBO_VIS4
#> # TRT:VIS1 = x_PBO_VIS1 + x_TRT_VIS1
#> # TRT:VIS2 = x_PBO_VIS1 + x_TRT_VIS2
#> # TRT:VIS3 = x_PBO_VIS1 + x_TRT_VIS3
#> # TRT:VIS4 = x_PBO_VIS1 + x_TRT_VIS4
```
To set up constrained longitudinal data analysis (cLDA), set `clda = TRUE`. This constraint pools all treatment groups at baseline, and it can help model clinical trials where a baseline measurement is observed before randomization. Some archetypes cannot support cLDA (e.g. `brm_archetype_average_cells()` and `brm_archetype_average_effects()`).
``` r
summary(brm_archetype_cells(data, clda = TRUE))
#> # This is the "cells" 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).
#> #
#> # PBO:VIS1 = x_PBO_VIS1
#> # PBO:VIS2 = x_PBO_VIS2
#> # PBO:VIS3 = x_PBO_VIS3
#> # PBO:VIS4 = x_PBO_VIS4
#> # TRT:VIS1 = x_PBO_VIS1
#> # TRT:VIS2 = x_TRT_VIS2
#> # TRT:VIS3 = x_TRT_VIS3
#> # TRT:VIS4 = x_TRT_VIS4
```