Skip to content

Commit

Permalink
brm_plot_compare()
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Jun 8, 2023
1 parent 59ef917 commit 4cd50d0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 34 deletions.
29 changes: 12 additions & 17 deletions R/brm_plot_compare.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
#' response variable.
#' @examples
#' set.seed(0L)
#' sim <- brm_simulate()
#' data <- sim$data
#' data <- brm_data(
#' data = tibble::as_tibble(brm_simulate()$data),
#' outcome = "response",
#' role = "response",
#' group = "group",
#' time = "time",
#' patient = "patient"
#' )
#' data$group <- paste("treatment", data$group)
#' data$time <- paste("visit", data$time)
#' formula <- brm_formula(
#' response = "response",
#' group = "group",
#' time = "time",
#' patient = "patient",
#' data = data,
#' effect_base = FALSE,
#' interaction_base = FALSE
#' )
Expand All @@ -38,20 +41,12 @@
#' )
#' draws <- brm_marginal_draws(
#' model = model,
#' group = "group",
#' time = "time",
#' patient = "patient",
#' data = data,
#' control = "treatment 1",
#' baseline = "visit 1",
#' outcome = "response"
#' baseline = "visit 1"
#' )
#' suppressWarnings(summaries_draws <- brm_marginal_summaries(draws))
#' summaries_data <- brm_marginal_data(
#' data,
#' response = "response",
#' group = "group",
#' time = "time"
#' )
#' summaries_data <- brm_marginal_data(data)
#' brm_plot_compare(
#' model1 = summaries_draws,
#' model2 = summaries_draws,
Expand Down
29 changes: 12 additions & 17 deletions tests/testthat/test-brm_plot_compare.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
test_that("brm_plot_compare()", {
set.seed(0L)
sim <- brm_simulate()
data <- sim$data
data <- brm_data(
data = tibble::as_tibble(brm_simulate()$data),
outcome = "response",
role = "response",
group = "group",
time = "time",
patient = "patient"
)
data$group <- paste("treatment", data$group)
data$time <- paste("visit", data$time)
formula <- brm_formula(
response = "response",
group = "group",
time = "time",
patient = "patient",
data = data,
effect_base = FALSE,
interaction_base = FALSE
)
Expand All @@ -27,20 +30,12 @@ test_that("brm_plot_compare()", {
)
draws <- brm_marginal_draws(
model = model,
group = "group",
time = "time",
patient = "patient",
data = data,
control = "treatment 1",
baseline = "visit 1",
outcome = "response"
baseline = "visit 1"
)
suppressWarnings(summaries_draws <- brm_marginal_summaries(draws))
summaries_data <- brm_marginal_data(
data,
response = "response",
group = "group",
time = "time"
)
summaries_data <- brm_marginal_data(data)
out <- brm_plot_compare(
summaries_draws = summaries_draws,
summaries_data = summaries_data
Expand Down

0 comments on commit 4cd50d0

Please sign in to comment.