openpharma / brms.mmrm

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

Minimum brms version 2.19.0 #65

Closed andrew-bean closed 1 year ago

andrew-bean commented 1 year ago

Unstructured correlation was introduced in brms version 2.19.0 (https://github.com/paul-buerkner/brms/blob/master/NEWS.md)

Since this package depends on brms::unstr, should we not require brms >= 2.19.0? Otherwise, users with older versions of brms will get a warning on package load and then an error when brm_model is called.

# remotes::install_version("brms", version = "2.18.0")
stopifnot(packageVersion("brms") < "2.19.0")

library(brms.mmrm)
# Warning message:
#   object ‘unstr’ is not exported by 'namespace:brms' 
library(dplyr)
library(magrittr)

set.seed(0L)
raw_data <- brm_simulate_simple(
  n_group = 3,
  n_patient = 100,
  n_time = 4
) %>%
  extract2("data") %>%
  brm_simulate_continuous(c("biomarker1", "biomarker2", "biomarker3"))

data <- brm_data(
  data = raw_data,
  outcome = "response",
  role = "response",
  group = "group",
  patient = "patient",
  time = "time",
  covariates = c("biomarker1", "biomarker2"),
  level_control = "group_1",
  level_baseline = "time_1"
)

formula <- brm_formula(
  data = data,
  intercept = TRUE,
  effect_baseline = FALSE,
  effect_group = TRUE,
  effect_time = TRUE,
  interaction_baseline = FALSE,
  interaction_group = TRUE
)

model <- brm_model(data = data, formula = formula, refresh = 0)
# Error in unstr(time = time, gr = patient) :
#   could not find function "unstr"
wlandau commented 1 year ago

Thanks for pointing that out, @andrew-bean. Should be fixed in 1b755b7195e887b5dbd760b9d1a153118907d62e.