Skip to content

Commit

Permalink
pkgdown
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Jul 22, 2024
1 parent b25c348 commit d53dcb9
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 4 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ S3method(brm_has_nuisance,brms_mmrm_archetype)
S3method(brm_has_nuisance,brms_mmrm_data)
S3method(brm_has_subgroup,brms_mmrm_archetype)
S3method(brm_has_subgroup,brms_mmrm_data)
S3method(print,brms_mmrm_transform_marginal)
S3method(summary,brms_mmrm_archetype)
S3method(summary,brms_mmrm_transform_marginal)
S3method(transform_marginal_names_continuous,brms_mmrm_archetype)
Expand Down
28 changes: 28 additions & 0 deletions R/brm_archetype.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ brm_archetype_attributes <- function(data) {

#' @title Summarize an informative prior archetype.
#' @export
#' @keywords internal
#' @description For an informative prior archetype, show
#' the transformation from model parameters to marginal means.
#' @return Return a character vector with linear equations
Expand All @@ -181,6 +182,33 @@ brm_archetype_attributes <- function(data) {
#' to forgo verbose messages and non-invisibly return the equations.
#' @param ... Not used, but required for S3 methods that inherit from
#' the base generic [summary()].
#' @examples
#' data <- brm_simulate_outline(
#' n_group = 2,
#' n_patient = 100,
#' n_time = 4,
#' rate_dropout = 0,
#' rate_lapse = 0
#' ) |>
#' dplyr::mutate(response = rnorm(n = dplyr::n())) |>
#' brm_data_change() |>
#' brm_simulate_continuous(names = c("biomarker1", "biomarker2")) |>
#' brm_simulate_categorical(
#' names = c("status1", "status2"),
#' levels = c("present", "absent")
#' )
#' dplyr::select(
#' data,
#' group,
#' time,
#' patient,
#' starts_with("biomarker"),
#' starts_with("status")
#' )
#' archetype <- brm_archetype_successive_cells(data)
#' equations <- summary(archetype)
#' print(equations)
#' summary(archetype, message = FALSE)
summary.brms_mmrm_archetype <- function(object, message = TRUE, ...) {
formula <- brm_formula(object)
transform <- brm_transform_marginal(
Expand Down
31 changes: 29 additions & 2 deletions R/brm_transform_marginal.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#' reconstruct the `brms` model parameter names. This argument should
#' only be modified for testing purposes.
#' @examples
#' if (identical(Sys.getenv("BRM_EXAMPLES", unset = ""), "true")) {
#' set.seed(0L)
#' data <- brm_data(
#' data = brm_simulate_simple()$data,
Expand All @@ -74,7 +73,6 @@
#' summary(transform, message = FALSE)
#' class(transform)
#' print(transform)
#' }
brm_transform_marginal <- function(
data,
formula,
Expand Down Expand Up @@ -293,6 +291,7 @@ brm_transform_marginal_names_rows <- function(data, formula, grid) {

#' @title Summarize marginal transform.
#' @export
#' @keywords internal
#' @description Summarize a transformation from model parameters to
#' marginal means.
#' @return Return a character vector with linear equations
Expand All @@ -305,6 +304,28 @@ brm_transform_marginal_names_rows <- function(data, formula, grid) {
#' to forgo verbose messages and non-invisibly return the equations.
#' @param ... Not used, but required for S3 methods that inherit from
#' the base generic [summary()].
#' @examples
#' set.seed(0L)
#' data <- brm_data(
#' data = brm_simulate_simple()$data,
#' outcome = "response",
#' group = "group",
#' time = "time",
#' patient = "patient",
#' reference_group = "group_1",
#' reference_time = "time_1"
#' )
#' formula <- brm_formula(
#' data = data,
#' baseline = FALSE,
#' baseline_time = FALSE
#' )
#' transform <- brm_transform_marginal(data = data, formula = formula)
#' equations <- summary(transform)
#' print(equations)
#' summary(transform, message = FALSE)
#' class(transform)
#' print(transform)
summary.brms_mmrm_transform_marginal <- function(
object,
message = TRUE,
Expand All @@ -328,6 +349,12 @@ summary.brms_mmrm_transform_marginal <- function(
}
}

#' @export
print.brms_mmrm_transform_marginal <- function(x, ...) {
class(x) <- c("matrix", "array")
NextMethod()
}

brm_transform_marginal_lines <- function(transform) {
lines <- character(0L)
marginals <- gsub(brm_sep(), ":", rownames(transform), fixed = TRUE)
Expand Down
2 changes: 0 additions & 2 deletions man/brm_transform_marginal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions man/summary.brms_mmrm_archetype.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/summary.brms_mmrm_transform_marginal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/testthat/test-brm_transform_marginal.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ test_that("brm_transform_marginal(), response, non-subgroup", {
expect_true(is.character(summary(transform, message = TRUE)))
)
expect_true(is.character(summary(transform, message = FALSE)))
tmp <- capture.output(print(transform))
model_matrix <- brms::make_standata(
formula = formula,
data = dplyr::mutate(data, FEV1 = 0)
Expand Down

0 comments on commit d53dcb9

Please sign in to comment.