Skip to content

Commit 55f598a

Browse files
Multivariate response models (#687)
* Multivariate response models Fixes #31 * less verbose --------- Co-authored-by: Dominique Makowski <dom.mak19@gmail.com>
1 parent 528b838 commit 55f598a

5 files changed

Lines changed: 72 additions & 34 deletions

File tree

R/rope.R

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
#' names. In this case, all parameters that have no matching name in `range`
1717
#' will be set to `"default"`.
1818
#'
19-
#' In multivariate models, `range` should be a list with a numeric vectors for
20-
#' each response variable. Vector names should correspond to the name of the
21-
#' response variables. If `"default"` and input is a vector, the range is set to
22-
#' `c(-0.1, 0.1)`. If `"default"` and input is a Bayesian model,
23-
#' [`rope_range()`] is used.
19+
#' In multivariate models, `range` should be a list with another list (one for
20+
#' each response variable) of numeric vectors . Vector names should correspond to
21+
#' the name of the response variables. If `"default"` and input is a vector, the
22+
#' range is set to `c(-0.1, 0.1)`. If `"default"` and input is a Bayesian model,
23+
#' [`rope_range()`] is used. See 'Examples'.
2424
#' @param ci The Credible Interval (CI) probability, corresponding to the
2525
#' proportion of HDI, to use for the percentage in ROPE.
2626
#' @param ci_method The type of interval to use to quantify the percentage in
@@ -128,18 +128,30 @@
128128
#' rope(emtrends(model, ~1, "wt"), ci = c(0.90, 0.95))
129129
#'
130130
#' library(brms)
131-
#' model <- brm(mpg ~ wt + cyl, data = mtcars)
131+
#' model <- brm(mpg ~ wt + cyl, data = mtcars, refresh = 0)
132132
#' rope(model)
133133
#' rope(model, ci = c(0.90, 0.95))
134134
#'
135135
#' library(brms)
136136
#' model <- brm(
137137
#' bf(mvbind(mpg, disp) ~ wt + cyl) + set_rescor(rescor = TRUE),
138-
#' data = mtcars
138+
#' data = mtcars,
139+
#' refresh = 0
139140
#' )
140141
#' rope(model)
141142
#' rope(model, ci = c(0.90, 0.95))
142143
#'
144+
#' # different ROPE ranges for model parameters. For each response, a named
145+
#' # list (with the name of the response variable) is required as list-element
146+
#' # for the `range` argument.
147+
#' rope(
148+
#' model,
149+
#' range = list(
150+
#' mpg = list(b_mpg_wt = c(-1, 1), b_mpg_cyl = c(-2, 2)),
151+
#' disp = list(b_disp_wt = c(-5, 5), b_disp_cyl = c(-4, 4))
152+
#' )
153+
#' )
154+
#'
143155
#' library(BayesFactor)
144156
#' bf <- ttestBF(x = rnorm(100, 1, 1))
145157
#' rope(bf)
@@ -453,7 +465,7 @@ rope.brmsfit <- function(x,
453465
!all(names(range) %in% insight::find_response(x))
454466
) {
455467
insight::format_error(
456-
"With a multivariate model, `range` should be 'default' or a list of named numeric vectors with length 2."
468+
"With a multivariate model, `range` should be 'default' or a list with multiple lists (one for each response) of named numeric vectors with length 2."
457469
)
458470
}
459471
} else if (!is.list(range) && (!all(is.numeric(range)) || length(range) != 2)) {

man/diagnostic_posterior.Rd

Lines changed: 23 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/equivalence_test.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/p_rope.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rope.Rd

Lines changed: 19 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)