Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 2, 2023
1 parent fdd2512 commit 046d0eb
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 115 deletions.
99 changes: 44 additions & 55 deletions R/rope_range.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,63 @@
#' @description This function attempts at automatically finding suitable "default"
#' values for the Region Of Practical Equivalence (ROPE).
#'
#' @details \cite{Kruschke (2018)} suggests that the region of practical
#' equivalence could be set, by default, to a range from `-0.1` to
#' `0.1` of a standardized parameter (negligible effect size
#' according to Cohen, 1988).
#' @details _Kruschke (2018)_ suggests that the region of practical equivalence
#' could be set, by default, to a range from `-0.1` to `0.1` of a standardized
#' parameter (negligible effect size according to _Cohen, 1988_).
#'
#' \itemize{
#' \item For **linear models (lm)**, this can be generalised to
#' \ifelse{html}{\out{-0.1 * SD<sub>y</sub>, 0.1 *
#' SD<sub>y</sub>}}{\eqn{[-0.1*SD_{y}, 0.1*SD_{y}]}}.
#' - For **linear models (lm)**, this can be generalised to
#' \ifelse{html}{\out{-0.1 * SD<sub>y</sub>, 0.1 * SD<sub>y</sub>}}{\eqn{[-0.1*SD_{y}, 0.1*SD_{y}]}}.
#'
#' \item For **logistic models**, the parameters expressed in log odds
#' ratio can be converted to standardized difference through the formula
#' \ifelse{html}{\out{&pi;/&radic;(3)}}{\eqn{\pi/\sqrt{3}}}, resulting in a
#' range of `-0.18` to `0.18`.
#' - For **logistic models**, the parameters expressed in log odds ratio can be
#' converted to standardized difference through the formula
#' \ifelse{html}{\out{&pi;/&radic;(3)}}{\eqn{\pi/\sqrt{3}}}, resulting in a
#' range of `-0.18` to `0.18`.
#'
#' \item For other models with **binary outcome**, it is strongly
#' recommended to manually specify the rope argument. Currently, the same
#' default is applied that for logistic models.
#' - For other models with **binary outcome**, it is strongly recommended to
#' manually specify the rope argument. Currently, the same default is applied
#' that for logistic models.
#'
#' \item For models from **count data**, the residual variance is used.
#' This is a rather experimental threshold and is probably often similar to
#' `-0.1, 0.1`, but should be used with care!
#' - For models from **count data**, the residual variance is used. This is a
#' rather experimental threshold and is probably often similar to `-0.1, 0.1`,
#' but should be used with care!
#'
#' \item For **t-tests**, the standard deviation of the response is
#' used, similarly to linear models (see above).
#' - For **t-tests**, the standard deviation of the response is used, similarly
#' to linear models (see above).
#'
#' \item For **correlations**, `-0.05, 0.05` is used, i.e., half
#' the value of a negligible correlation as suggested by Cohen's (1988)
#' rules of thumb.
#' - For **correlations**, `-0.05, 0.05` is used, i.e., half the value of a
#' negligible correlation as suggested by Cohen's (1988) rules of thumb.
#'
#' \item For all other models, `-0.1, 0.1` is used to determine the
#' ROPE limits, but it is strongly advised to specify it manually.
#' }
#' - For all other models, `-0.1, 0.1` is used to determine the ROPE limits,
#' but it is strongly advised to specify it manually.
#'
#' @param x A `stanreg`, `brmsfit` or `BFBayesFactor` object.
#' @param verbose Toggle warnings.
#' @inheritParams rope
#'
#' @examples
#' @examplesIf require("rstanarm") && require("brms") && require("BayesFactor")
#' \donttest{
#' if (require("rstanarm")) {
#' model <- suppressWarnings(stan_glm(
#' mpg ~ wt + gear,
#' data = mtcars,
#' chains = 2,
#' iter = 200,
#' refresh = 0
#' ))
#' rope_range(model)
#'
#' model <- suppressWarnings(
#' stan_glm(vs ~ mpg, data = mtcars, family = "binomial", refresh = 0)
#' )
#' rope_range(model)
#' }
#'
#' if (require("brms")) {
#' model <- brm(mpg ~ wt + cyl, data = mtcars)
#' rope_range(model)
#' }
#'
#' if (require("BayesFactor")) {
#' model <- ttestBF(mtcars[mtcars$vs == 1, "mpg"], mtcars[mtcars$vs == 0, "mpg"])
#' rope_range(model)
#'
#' model <- lmBF(mpg ~ vs, data = mtcars)
#' rope_range(model)
#' }
#' model <- suppressWarnings(rstanarm::stan_glm(
#' mpg ~ wt + gear,
#' data = mtcars,
#' chains = 2,
#' iter = 200,
#' refresh = 0
#' ))
#' rope_range(model)
#'
#' model <- suppressWarnings(
#' rstanarm::stan_glm(vs ~ mpg, data = mtcars, family = "binomial", refresh = 0)
#' )
#' rope_range(model)
#'
#' model <- brms::brm(mpg ~ wt + cyl, data = mtcars)
#' rope_range(model)
#'
#' model <- BayesFactor::ttestBF(mtcars[mtcars$vs == 1, "mpg"], mtcars[mtcars$vs == 0, "mpg"])
#' rope_range(model)
#'
#' model <- lmBF(mpg ~ vs, data = mtcars)
#' rope_range(model)
#' }
#'
#' @references Kruschke, J. K. (2018). Rejecting or accepting parameter values
Expand Down
103 changes: 43 additions & 60 deletions man/rope_range.Rd

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

0 comments on commit 046d0eb

Please sign in to comment.