Skip to content

Commit

Permalink
Merge pull request #384 from easystats/CRAN-0.5-for-real-this-time
Browse files Browse the repository at this point in the history
Cran 0.5 for real this time
  • Loading branch information
mattansb authored Oct 4, 2021
2 parents 385e790 + 4895ff9 commit 6f86d08
Show file tree
Hide file tree
Showing 25 changed files with 312 additions and 392 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
.Rhistory
.Rapp.history

# revdepcheck
/revdep*

# Session Data files
.RData

Expand Down
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: effectsize
Title: Indices of Effect Size and Standardized Parameters
Version: 0.4.99
Version: 0.5
Authors@R:
c(person(given = "Mattan S.",
family = "Ben-Shachar",
Expand Down Expand Up @@ -54,7 +54,7 @@ Imports:
bayestestR (>= 0.10.5),
insight (>= 0.14.3),
parameters (>= 0.14.0),
performance (>= 0.7.3.5),
performance (>= 0.8.0),
datawizard (>= 0.2.0),
stats,
utils
Expand Down Expand Up @@ -91,6 +91,5 @@ Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
Remotes: easystats/performance
Config/testthat/edition: 3
Config/testthat/parallel: true
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- `interpret_d()`, `interpret_g()`, and `interpret_delta()` are now `interpret_cohens_d()`, `interpret_hedges_g()`, and `interpret_glass_delta()`.
- `interpret_parameters()` was removed. Use `interpret_r()` instead (with caution!).
- Phi, Cohen's *w*, Cramer's *V*, ANOVA effect sizes, rank Epsilon squared, Kendall's *W* - CIs default to 95% one-sided CIs (`alternative = "greater"`). (To restore previous behavior, set `ci = .9, alternative = "two.sided"`.)
- `adjust()`, `change_scale()`, `normalize()`, `ranktransform()`, `standardize()` (data), and `unstandardize()` have moved to the new [`{datawizard}`](https://easystats.github.io/datawizard) package!
- `adjust()`, `change_scale()`, `normalize()`, `ranktransform()`, `standardize()` (data), and `unstandardize()` have moved to the new [`{datawizard}`](https://easystats.github.io/datawizard/) package!

## New features

Expand Down
88 changes: 35 additions & 53 deletions R/docs_extra.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
#'
#' @section Confidence (Compatibility) Intervals (CIs):
#' Unless stated otherwise, confidence (compatibility) intervals (CIs) are
#' estimated using the noncentrality parameter method (also called the
#' "pivot method"). This method finds the noncentrality parameter ("*ncp*") of
#' a noncentral *t*, *F*, or
#' \ifelse{latex}{\out{$\chi^2$}}{\ifelse{html}{\out{&chi;<sup>2</sup>}}{chi-squared}}
#' distribution that places the observed *t*, *F*, or
#' \ifelse{latex}{\out{$\chi^2$}}{\ifelse{html}{\out{&chi;<sup>2</sup>}}{chi-squared}}
#' test statistic at the desired probability point of the distribution.
#' For example, if the observed *t* statistic is 2.0, with 50
#' degrees of freedom, for which cumulative noncentral *t* distribution is
#' *t* = 2.0 the .025 quantile (answer: the noncentral *t* distribution with
#' *ncp* = .04)? After estimating these confidence bounds on the *ncp*, they are
#' estimated using the noncentrality parameter method (also called the "pivot
#' method"). This method finds the noncentrality parameter ("*ncp*") of a
#' noncentral *t*, *F*, or \eqn{\chi^2} distribution that places the observed
#' *t*, *F*, or \eqn{\chi^2} test statistic at the desired probability point of
#' the distribution. For example, if the observed *t* statistic is 2.0, with 50
#' degrees of freedom, for which cumulative noncentral *t* distribution is *t* =
#' 2.0 the .025 quantile (answer: the noncentral *t* distribution with *ncp* =
#' .04)? After estimating these confidence bounds on the *ncp*, they are
#' converted into the effect size metric to obtain a confidence interval for the
#' effect size (Steiger, 2004).
#' \cr\cr
Expand All @@ -26,23 +23,20 @@
#' in a hypothesis test, and more." (Steiger, 2004). Confidence (compatibility)
#' intervals and p values are complementary summaries of parameter uncertainty
#' given the observed data. A dichotomous hypothesis test could be performed
#' with either a CI or a p value. The
#' 100(\ifelse{latex}{\out{$1 - \alpha$}}{\ifelse{html}{\out{1 &minus; &alpha;}}{1 - alpha}})%
#' confidence interval contains all of the parameter values for which
#' \ifelse{latex}{\out{$p > \alpha$}}{\ifelse{html}{\out{p > &alpha;}}{p > alpha}}
#' with either a CI or a p value. The 100 (1 - \eqn{\alpha})% confidence
#' interval contains all of the parameter values for which *p* > \eqn{\alpha}
#' for the current data and model. For example, a 95% confidence interval
#' contains all of the values for which p > .05.
#' \cr\cr
#' Note that a confidence interval including 0 *does not* indicate that the null
#' (no effect) is true. Rather, it suggests that the observed data together with
#' the model and its assumptions combined do not provided clear evidence against
#' a parameter value of 0 (same as with any other value in the interval), with
#' the level of this evidence defined by the chosen
#' \ifelse{latex}{\out{$\alpha$}}{\ifelse{html}{\out{&alpha;}}{alpha}} level
#' (Rafi & Greenland, 2020; Schweder & Hjort, 2016; Xie & Singh, 2013). To infer
#' no effect, additional judgments about what parameter values are "close
#' enough" to 0 to be negligible are needed ("equivalence testing"; Bauer &
#' Kiesser, 1996).
#' the level of this evidence defined by the chosen \eqn{\alpha} level (Rafi &
#' Greenland, 2020; Schweder & Hjort, 2016; Xie & Singh, 2013). To infer no
#' effect, additional judgments about what parameter values are "close enough"
#' to 0 to be negligible are needed ("equivalence testing"; Bauer & Kiesser,
#' 1996).
#'
#' @section One-Sided CIs:
#' Typically, CIs are constructed as two-tailed intervals, with an equal
Expand All @@ -59,51 +53,39 @@
#' are generally tested using 2-tailed tests and 2-sided CIs.
#' \cr\cr
#' Some effect sizes are strictly positive--they do have a minimum value, of 0.
#' For example,
#' \ifelse{latex}{\out{$R^2$}}{\ifelse{html}{\out{<i>R</i><sup>2</sup>}}{R^2}},
#' \ifelse{latex}{\out{$\eta^2$}}{\ifelse{html}{\out{&eta;<sup>2</sup>}}{eta^2}},
#' and other variance-accounted-for effect sizes, as well as Cramer's *V* and
#' multiple *R*, range from 0 to 1. These typically involve *F*- or
#' \ifelse{latex}{\out{$\chi^2$}}{\ifelse{html}{\out{&chi;<sup>2</sup>}}{chi-squared}}-statistics
#' and are generally tested using *1-tailed* tests which test whether the
#' estimated effect size is *larger* than the hypothesized null value (e.g., 0).
#' In order for a CI to yield the same significance decision it must then by a
#' *1-sided* CI, estimating only a lower bound. This is the default CI computed
#' by *effectsize* for these effect sizes, where `alternative = "greater"` is
#' set.
#' For example, \eqn{R^2}, \eqn{\eta^2}, and other variance-accounted-for effect
#' sizes, as well as Cramer's *V* and multiple *R*, range from 0 to 1. These
#' typically involve *F*- or \eqn{\chi^2}-statistics and are generally tested
#' using *1-tailed* tests which test whether the estimated effect size is
#' *larger* than the hypothesized null value (e.g., 0). In order for a CI to
#' yield the same significance decision it must then by a *1-sided* CI,
#' estimating only a lower bound. This is the default CI computed by
#' *effectsize* for these effect sizes, where `alternative = "greater"` is set.
#' \cr\cr
#' This lower bound interval indicates the smallest effect size that is not
#' significantly different from the observed effect size. That is, it is the
#' minimum effect size compatible with the observed data, background model
#' assumptions, and
#' \ifelse{latex}{\out{$\alpha$}}{\ifelse{html}{\out{&alpha;}}{alpha}} level.
#' This type of interval does not indicate a maximum effect size value; anything
#' up to the maximum possible value of the effect size (e.g., 1) is in the
#' interval.
#' assumptions, and \eqn{\alpha} level. This type of interval does not indicate
#' a maximum effect size value; anything up to the maximum possible value of the
#' effect size (e.g., 1) is in the interval.
#' \cr\cr
#' One-sided CIs can also be used to test against a maximum effect size value
#' (e.g., is
#' \ifelse{latex}{\out{$R^2$}}{\ifelse{html}{\out{<i>R</i><sup>2</sup>}}{R^2}}
#' significantly smaller than a perfect correlation of 1.0?) can by setting
#' `alternative = "less"`. This estimates a CI with only an *upper* bound;
#' anything from the minimum possible value of the effect size (e.g., 0) up to
#' this upper bound is in the interval.
#' (e.g., is \eqn{R^2} significantly smaller than a perfect correlation of 1.0?)
#' can by setting `alternative = "less"`. This estimates a CI with only an
#' *upper* bound; anything from the minimum possible value of the effect size
#' (e.g., 0) up to this upper bound is in the interval.
#' \cr\cr
#' We can also obtain a 2-sided interval by setting `alternative = "two-sided"`.
#' These intervals can be interpreted in the same way as other 2-sided
#' intervals, such as those for *r*, *d*, or *g*.
#' \cr\cr
#' An alternative approach to aligning significance tests using CIs and 1-tailed
#' *p* values that can often be found in the literature is to construct a
#' 2-sided CI at a lower confidence level (e.g., 100(\ifelse{latex}{\out{$1 -
#' 2\alpha$}}{\ifelse{html}{\out{1 &minus; 2&alpha;}}{1 - 2*alpha}})% =
#' \ifelse{latex}{\out{$100 - 2 \times 5\% = 90\%$}}{\ifelse{html}{\out{100
#' &minus; 2 &times; 5&percnt; = 90&percnt;}}{100 - 2*5% = 90%}}). This
#' estimates the lower bound and upper bound for the above 1-sided intervals
#' simultaneously. These intervals are commonly reported when conducting
#' **equivalence tests**. For example, a 90% 2-sided interval gives the bounds
#' for an equivalence test with \ifelse{latex}{\out{$\alpha =
#' .05$}}{\ifelse{html}{\out{&alpha; = .05}}{alpha = .05}}. However, be aware
#' 2-sided CI at a lower confidence level (e.g., 100(1-2\eqn{\alpha})% = 100 -
#' 2*5% = 90%. This estimates the lower bound and upper bound for the above
#' 1-sided intervals simultaneously. These intervals are commonly reported when
#' conducting **equivalence tests**. For example, a 90% 2-sided interval gives
#' the bounds for an equivalence test with \eqn{\alpha} = .05. However, be aware
#' that this interval does not give 95% coverage for the underlying effect size
#' parameter value. For that, construct a 95% 2-sided CI.
#'
Expand Down
36 changes: 35 additions & 1 deletion R/standardize.models.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
#' Performs a standardization of data (z-scoring) using
#' [`datawizard::standardize()`] and then re-fits the model to the standardized
#' data.
#' \cr\cr
#' Standardization is done by completely refitting the model on the standardized
#' data. Hence, this approach is equal to standardizing the variables *before*
#' fitting the model and will return a new model object. This method is
#' particularly recommended for complex models that include interactions or
#' transformations (e.g., polynomial or spline terms). The `robust` (default to
#' `FALSE`) argument enables a robust standardization of data, based on the
#' `median` and the `MAD` instead of the `mean` and the `SD`.
#'
#' @param x A statistical model.
#' @param weights If `TRUE` (default), a weighted-standardization is carried out.
Expand All @@ -16,11 +24,37 @@
#'
#' @return A statistical model fitted on standardized data
#'
#' @inheritSection standardize_parameters Generalized Linear Models
#' @details
#'
#' # Generalized Linear Models
#' Standardization for generalized linear models (GLM, GLMM, etc) is done only
#' with respect to the predictors (while the outcome remains as-is,
#' unstandardized) - maintaining the interpretability of the coefficients (e.g.,
#' in a binomial model: the exponent of the standardized parameter is the OR of
#' a change of 1 SD in the predictor, etc.)
#'
#' # Dealing with Factors
#' `standardize(model)` or `standardize_parameters(model, method = "refit")` do
#' *not* standardized categorical predictors (i.e. factors) / their
#' dummy-variables, which may be a different behaviour compared to other R
#' packages (such as \pkg{lm.beta}) or other software packages (like SPSS). To
#' mimic such behaviours, either use `standardize_parameters(model, method =
#' "basic")` to obtain post-hoc standardized parameters, or standardize the data
#' with `datawizard::standardize(data, force = TRUE)` *before* fitting the
#' model.
#'
#' # Transformed Variables
#' When the model's formula contains transformations (e.g. `y ~ exp(X)`) the
#' transformation effectively takes place after standardization (e.g.,
#' `exp(scale(X))`). Since some transformations are undefined for none positive
#' values, such as `log()` and `sqrt()`, the releven variables are shifted (post
#' standardization) by `Z - min(Z) + 1` or `Z - min(Z)` (respectively).
#'
#' @family standardize
#' @examples
#' model <- lm(Infant.Mortality ~ Education * Fertility, data = swiss)
#' coef(standardize(model))
#'
#' @importFrom stats update
#' @importFrom insight get_data model_info find_response get_response find_weights get_weights
#' @importFrom datawizard standardize
Expand Down
35 changes: 13 additions & 22 deletions R/standardize_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,33 +74,25 @@
#' level 1 predictors (Hoffman 2015, page 342). A warning is given when a
#' within-group varialbe is found to have access between-group variance.
#'
#' ## Dealing with Factors
#' The `"refit"` method does *not* standardized categorical predictors (i.e.
#' factors), which may be a different behaviour compared to other R packages
#' (such as \pkg{lm.beta}) or other software packages (like SPSS). to mimic such
#' behaviours, either use the `"basic"` method or standardize the data with
#' `effectsize::standardize(force=TRUE)` *before* fitting the model.
#'
#' ## Transformed Variables
#' When the model's formula contains transformations (e.g. `y ~ exp(X)`)
#' `method = "refit"` might give different results compared to
#' `method = "basic"` (`"posthoc"` and `"smart"` do not support such
#' transformations): where `"refit"` standardizes the data prior to the
#' transformation (e.g. equivalent to `exp(scale(X))`), the `"basic"` method
#' standardizes the transformed data (e.g. equivalent to `scale(exp(X))`). See
#' [standardize()] for more details on how different transformations are dealt
#' with.
#' # Transformed Variables
#' When the model's formula contains transformations (e.g. `y ~ exp(X)`) `method
#' = "refit"` will give different results compared to `method = "basic"`
#' (`"posthoc"` and `"smart"` do not support such transformations): While
#' `"refit"` standardizes the data *prior* to the transformation (e.g.
#' equivalent to `exp(scale(X))`), the `"basic"` method standardizes the
#' transformed data (e.g. equivalent to `scale(exp(X))`).
#' \cr\cr
#' See the *Transformed Variables* section in [standardize.default()] for more
#' details on how different transformations are dealt with when `method =
#' "refit"`.
#'
#' # Confidence Intervals
#' The returned confidence intervals are re-scaled versions of the
#' unstandardized confidence intervals, and not "true" confidence intervals of
#' the standardized coefficients (cf. Jones & Waller, 2015).
#'
#' # Generalized Linear Models
#' When standardizing coefficients of a generalized model (GLM, GLMM, etc), only
#' the predictors are standardized, maintaining the interpretability of the
#' coefficients (e.g., in a binomial model: the exponent of the standardized
#' parameter is the OR of a change of 1 SD in the predictor, etc.)
#' @inheritSection standardize.default Generalized Linear Models
#' @inheritSection standardize.default Dealing with Factors
#'
#' @return A data frame with the standardized parameters (`Std_*`, depending on
#' the model type) and their CIs (`CI_low` and `CI_high`). Where applicable,
Expand All @@ -109,7 +101,6 @@
#'
#' @family standardize
#' @family effect size indices
#' @seealso [standardize_info()]
#'
#' @examples
#' library(effectsize)
Expand Down
9 changes: 6 additions & 3 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* GitHub Actions (windows): devel, release, oldrel
* Github Actions (macOS): devel, release, oldrel
* GitHub Actions (ubuntu-16.04): devel, release, oldrel, 3.6, 3.5, 3.4
* win-builder: devel
* win-builder: release


## R CMD check results
Expand All @@ -17,6 +17,9 @@



## Reverse Dependancies
## `revdepcheck` results

- The maintainer of `statsExperssions` has been informed about the imminent failure of tests with this new version.
We checked 15 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.

* We saw 0 new problems
* We failed to check 0 packages
36 changes: 15 additions & 21 deletions man/F_to_eta2.Rd

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

Loading

0 comments on commit 6f86d08

Please sign in to comment.