Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ Config/Needs/website:
rstudio/bslib,
r-lib/pkgdown,
easystats/easystatstemplate
Config/roxygen2/version: 8.0.0
Config/roxygen2/version: 8.1.1
Remotes:
easystats/datawizard
25 changes: 17 additions & 8 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ S3method(riskratio_to_nnt,default)
S3method(riskratio_to_nnt,numeric)
S3method(riskratio_to_oddsratio,default)
S3method(riskratio_to_oddsratio,numeric)
S3method(transform,rules)
export(.es_aov_simple)
export(.es_aov_strata)
export(.es_aov_table)
Expand Down Expand Up @@ -127,6 +128,8 @@ export(interpret_agfi)
export(interpret_bf)
export(interpret_cfi)
export(interpret_cohens_d)
export(interpret_cohens_f)
export(interpret_cohens_f2)
export(interpret_cohens_g)
export(interpret_cramers_v)
export(interpret_direction)
Expand Down Expand Up @@ -240,11 +243,17 @@ export(wmw_odds)
export(z_to_d)
export(z_to_r)
importFrom(bayestestR,equivalence_test)
importFrom(datawizard,standardise)
importFrom(datawizard,standardize)
importFrom(insight,display)
importFrom(insight,print_html)
importFrom(insight,print_md)
importFrom(parameters,standardize_info)
importFrom(parameters,standardize_parameters)
importFrom(parameters,standardize_posteriors)
importFrom(datawizard,
standardise,
standardize
)
importFrom(insight,
display,
print_html,
print_md
)
importFrom(parameters,
standardize_info,
standardize_parameters,
standardize_posteriors
)
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# effectsize (dev)

## New features

- New `transform()` method for rules, allowing to applied transformed rules.

## Bug fixes

- `rank_biserial(x, y, paired = TRUE)` gives the same CIs as `rank_biserial(x - y)` (#716)
Expand Down
4 changes: 2 additions & 2 deletions R/eta_squared_posterior.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @param ss_function For Bayesian models, the function used to extract
#' sum-of-squares. Uses [`anova()`] by default, but can also be `car::Anova()`
#' for simple linear models.
#' sum-of-squares. Uses [`stats::anova()`] by default, but can also be
#' `car::Anova()` for simple linear models.
#' @param draws For Bayesian models, an integer indicating the number of draws
#' from the posterior predictive distribution to return. Larger numbers take
#' longer to run, but provide estimates that are more stable.
Expand Down Expand Up @@ -113,7 +113,7 @@

res <- do.call("rbind", res)
attr(res, "generalized") <- generalized
return(res)

Check warning on line 116 in R/eta_squared_posterior.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/eta_squared_posterior.R,line=116,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
}

#' @export
Expand Down
31 changes: 30 additions & 1 deletion R/interpret.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@
#' @seealso [interpret()]
#'
#' @examples
#' rules(c(0.05), c("significant", "not significant"), right = FALSE)
#' rules(c(0.2, 0.5, 0.8), c("small", "medium", "large"))
#' rules(c("small" = 0.2, "medium" = 0.5), name = "Cohen's Rules")
#'
#' (sig_rules <- rules(c(0.05), c("significant", "not significant"), right = FALSE))
#'
#' # Convert the rules for p-values to the rules for S-values
#' p_to_S <- function(p) -log2(p)
#' transform(sig_rules, p_to_S)
#'
#'
#' @export
rules <- function(values, labels = NULL, name = NULL, right = TRUE) {
if (is.null(labels)) {
Expand Down Expand Up @@ -77,6 +84,28 @@ rules <- function(values, labels = NULL, name = NULL, right = TRUE) {
#' @export
is.rules <- function(x) inherits(x, "rules")

#' @rdname rules
#' @param `_data` A set of `rules`.
#' @param ... Arguments passed to the `transform` function in `transform()`. Otherwise ignored.
#' @param new_name Name to give to the new rule. Defaults to `transform(old_name)`
#' @param transform Transformation to apply to the rules' values.
#' @export
transform.rules <- function(
`_data`,
transform = "identity",
new_name = NULL,
...
) {
if (is.null(new_name)) {
f_name <- make.names(as.character(substitute(transform)))
new_name <- sprintf("%s(%s)", f_name, attr(`_data`, "rule_name"))
}

transform <- match.fun(transform)
`_data`$values <- transform(`_data`$values, ...)
attr(`_data`, "rule_name") <- new_name
`_data`
}

# Interpret ---------------------------------------------------------------

Expand Down
104 changes: 81 additions & 23 deletions R/interpret_omega_squared.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#' Interpret ANOVA Effect Sizes
#'
#' @param es Value or vector of (partial) eta / omega / epsilon squared or semipartial r squared values.
#' @param rules Can be `"field2013"` (default), `"cohen1992"` or custom set of [rules()].
#' @param es Value or vector of (partial) eta / omega / epsilon squared or
#' semipartial r squared values, or Cohen's f or f squared.
#' @param rules Can be `"field2013"` (default for eta squared), `"cohen1992"`
#' (default for f squared) or custom set of [rules()].
#' @param ... Not used for now.
#'
#' @section Rules:
Expand All @@ -11,45 +13,53 @@
#' - **0.01 <= ES < 0.06** - Small
#' - **0.06 <= ES < 0.14** - Medium
#' - **ES >= 0.14 ** - Large
#' - Cohen (1992) (`"cohen1992"`) applicable to one-way anova, or to *partial*
#' eta / omega / epsilon squared in multi-way anova.
#' - Cohen (1992) table 1 row 8 (`"cohen1992r8"` or `"cohen1992"`; multiple and multiple partial correlation)
#' - **ES < 0.02** - Very small
#' - **0.02 <= ES < 0.13** - Small
#' - **0.13 <= ES < 0.26** - Medium
#' - **ES >= 0.26** - Large
#' - Cohen (1992) row 7 (`"cohen1992r7"`; one-way ANOVA)
#' - **ES < 0.01** - Very small
#' - **0.01 <= ES < 0.06** - Small
#' - **0.06 <= ES < 0.14** - Medium
#' - **ES >= 0.14** - Large
#'
#' The same rules can be applied to Cohen's \eqn{f^2} (and \eqn{f}) by transforming those values:
#'
#' ```{r}
#' # Field (2013)
#' eta2_to_f2(c(small = 0.01, medium = 0.06, large = 0.14))
#' ```
#'
#' Cohen's rules are derived by applying the reverse transformation on Cohen's
#' cut-offs for \eqn{f^2} (row 8) and \eqn{f} (row 7):
#'
#' ```{r}
#' # Row 8
#' f2_to_eta2(c(small = 0.02, medium = 0.15, large = 0.35))
#'
#' # Row 7
#' f_to_eta2(c(small = 0.1, medium = 0.25, large = 0.4))
#' ```
#'
#' @examples
#' interpret_eta_squared(.02)
#' interpret_eta_squared(c(.5, .02), rules = "cohen1992")
#' interpret_eta_squared(c(.5, .02), rules = "cohen1992r8")
#'
#' @seealso https://imaging.mrc-cbu.cam.ac.uk/statswiki/FAQ/effectSize/
#'
#'
#' @references
#' - Field, A (2013) Discovering statistics using IBM SPSS Statistics. Fourth
#' Edition. Sage:London.
#'
#' - Cohen, J. (1992). A power primer. Psychological bulletin, 112(1), 155.
#' - Cohen, J. (1992). [A power primer](https://doi.org/10.1037/0033-2909.112.1.155).
#' Psychological Bulletin, 112(1), 155-159.
#'
#' @keywords interpreters
#' @export
interpret_omega_squared <- function(es, rules = "field2013", ...) {
rules <- .match.rules(
rules,
list(
field2013 = rules(
c(0.01, 0.06, 0.14),
c("very small", "small", "medium", "large"),
name = "field2013",
right = FALSE
),
cohen1992 = rules(
c(0.02, 0.13, 0.26),
c("very small", "small", "medium", "large"),
name = "cohen1992",
right = FALSE
)
)
)
rules <- .match.rules(rules, .anova_rules)

interpret(es, rules)
}
Expand All @@ -65,3 +75,51 @@ interpret_epsilon_squared <- interpret_omega_squared
#' @export
#' @rdname interpret_omega_squared
interpret_r2_semipartial <- interpret_omega_squared

#' @export
#' @rdname interpret_omega_squared
interpret_cohens_f2 <- function(es, rules = "field2013", ...) {
rules <- .match.rules(
rules,
lapply(.anova_rules, transform, transform = eta2_to_f2)
)

interpret(es, rules)
}

#' @export
#' @rdname interpret_omega_squared
interpret_cohens_f <- function(es, rules = "field2013", ...) {
rules <- .match.rules(
rules,
lapply(.anova_rules, transform, transform = eta2_to_f)
)

interpret(es, rules)
}

# Rules ------------------------------------------------------------------

#' @keywords internal
.anova_rules <- list(
field2013 = rules(
c(0.01, 0.06, 0.14),
c("very small", "small", "medium", "large"),
name = "field2013",
right = FALSE
),

cohen1992 = rules(
f2_to_eta2(c(0.02, 0.15, 0.35)),
c("very small", "small", "medium", "large"),
name = "cohen1992",
right = FALSE
),
cohen1992r7 = rules(
f_to_eta2(c(0.1, 0.25, 0.40)),
c("very small", "small", "medium", "large"),
name = "cohen1992",
right = FALSE
)
)
.anova_rules$cohen1992r8 <- .anova_rules$cohen1992
4 changes: 2 additions & 2 deletions man/eta_squared.Rd

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

50 changes: 44 additions & 6 deletions man/interpret_omega_squared.Rd

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

Loading
Loading