% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/effectsize.BFBayesFactor.R, R/effectsize.R,
%   R/effectsize.htest.R
\name{effectsize.BFBayesFactor}
\alias{effectsize.BFBayesFactor}
\alias{effectsize}
\alias{effectsize.aov}
\alias{effectsize.htest}
\title{Effect Size}
\usage{
\method{effectsize}{BFBayesFactor}(model, type = NULL, verbose = TRUE, test = NULL, ...)

effectsize(model, ...)

\method{effectsize}{aov}(model, type = NULL, ...)

\method{effectsize}{htest}(model, type = NULL, verbose = TRUE, ...)
}
\arguments{
\item{model}{An object of class \code{htest}, or a statistical model. See details.}

\item{type}{The effect size of interest. See details.}

\item{verbose}{Toggle off warnings.}

\item{test}{The indices of effect existence to compute. Character (vector) or
list with one or more of these options: \code{"p_direction"} (or \code{"pd"}),
\code{"rope"}, \code{"p_map"}, \code{"equivalence_test"} (or \code{"equitest"}),
\code{"bayesfactor"} (or \code{"bf"}) or \code{"all"} to compute all tests.
For each "test", the corresponding \pkg{bayestestR} function is called
(e.g. \code{\link[bayestestR:rope]{rope()}} or \code{\link[bayestestR:p_direction]{p_direction()}}) and its results
included in the summary output.}

\item{...}{Arguments passed to or from other methods. See details.}
}
\value{
A data frame with the effect size (depending on input) and and its
CIs (\code{CI_low} and \code{CI_high}).
}
\description{
This function tries to return the best effect-size measure for the provided
input model. See details.
}
\details{
\itemize{
\item For an object of class \code{htest}, data is extracted via \code{\link[insight:get_data]{insight::get_data()}}, and passed to the relevant function according to:
\itemize{
\item A \strong{t-test} depending on \code{type}: \code{"cohens_d"} (default), \code{"hedges_g"}, or \code{"cles"}.
\item A \strong{Chi-squared tests of independence or goodness-of-fit}, depending on \code{type}: \code{"cramers_v"} (default), \code{"phi"}, \code{"cohens_w"}, \code{"pearsons_c"}, \code{"cohens_h"}, \code{"oddsratio"}, or \code{"riskratio"}.
\item A \strong{One-way ANOVA test}, depending on \code{type}: \code{"eta"} (default), \code{"omega"} or \code{"epsilon"} -squared, \code{"f"}, or \code{"f2"}.
\item A \strong{McNemar test} returns \emph{Cohen's g}.
\item A \strong{Wilcoxon test} depending on \code{type}: returns "\code{rank_biserial}" correlation (default) or \code{"cles"}.
\item A \strong{Kruskal-Wallis test} returns \emph{rank Epsilon squared}.
\item A \strong{Friedman test} returns \emph{Kendall's W}.
(Where applicable, \code{ci} and \code{alternative} are taken from the \code{htest} if not otherwise provided.)
}
\item For an object of class \code{BFBayesFactor}, using \code{\link[bayestestR:describe_posterior]{bayestestR::describe_posterior()}},
\itemize{
\item A \strong{t-test} depending on \code{type}: "cohens_d"\verb{(default) or}"cles"`.
\item A \strong{correlation test} returns \emph{r}.
\item A \strong{contingency table test}, depending on \code{type}: \code{"cramers_v"} (default), \code{"phi"}, \code{"cohens_w"}, \code{"pearsons_c"}, \code{"cohens_h"}, \code{"oddsratio"}, or \code{"riskratio"}.
\item A \strong{proportion test} returns \emph{p}.
}
\item Objects of class \code{anova}, \code{aov}, or \code{aovlist}, depending on \code{type}: \code{"eta"} (default), \code{"omega"} or \code{"epsilon"} -squared, \code{"f"}, or \code{"f2"}.
\item Other objects are passed to \code{\link[=standardize_parameters]{standardize_parameters()}}.
}

\strong{For statistical models it is recommended to directly use the listed
functions, for the full range of options they provide.}
}
\examples{

## Hypothesis Testing
## ------------------
contingency_table <- as.table(rbind(c(762, 327, 468), c(484, 239, 477), c(484, 239, 477)))
Xsq <- chisq.test(contingency_table)
effectsize(Xsq)
effectsize(Xsq, type = "phi")

Tt <- t.test(1:10, y = c(7:20), alternative = "less")
effectsize(Tt)

Aov <- oneway.test(extra ~ group, data = sleep, var.equal = TRUE)
effectsize(Aov)
effectsize(Aov, type = "omega")

Wt <- wilcox.test(1:10, 7:20, mu = -3, alternative = "less")
effectsize(Wt)
effectsize(Wt, type = "cles")

## Bayesian Hypothesis Testing
## ---------------------------
\donttest{
if (require(BayesFactor)) {
  bf_prop <- proportionBF(3, 7, p = 0.3)
  effectsize(bf_prop)

  bf_corr <- correlationBF(attitude$rating, attitude$complaints)
  effectsize(bf_corr)

  data(raceDolls)
  bf_xtab <- contingencyTableBF(raceDolls, sampleType = "poisson", fixedMargin = "cols")
  effectsize(bf_xtab)
  effectsize(bf_xtab, type = "oddsratio")

  bf_ttest <- ttestBF(sleep$extra[sleep$group==1],
                      sleep$extra[sleep$group==2],
                      paired = TRUE, mu = -1)
  effectsize(bf_ttest)
}
}

## Models and Anova Tables
## -----------------------
fit <- lm(mpg ~ factor(cyl) * wt + hp, data = mtcars)
effectsize(fit)

anova_table <- anova(fit)
effectsize(anova_table)
effectsize(anova_table, type = "epsilon")
}
\seealso{
Other effect size indices: 
\code{\link{cles}()},
\code{\link{cohens_d}()},
\code{\link{eta_squared}()},
\code{\link{phi}()},
\code{\link{rank_biserial}()},
\code{\link{standardize_parameters}()}
}
\concept{effect size indices}
