From 7d3972616bee8344bc1f3845bed8c23c432dcca8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 14 May 2024 08:47:59 +0200 Subject: [PATCH] docs --- R/chi_squared_test.R | 4 +++- R/kruskal_wallis_test.R | 12 ++++++------ R/mann_whitney_test.R | 14 +++++++++----- R/t_test.R | 18 ++++++++++++++---- man/chi_squared_test.Rd | 18 ++++++++++++------ man/kruskal_wallis_test.Rd | 24 ++++++++++++++---------- man/mann_whitney_test.Rd | 14 +++++++++----- man/t_test.Rd | 32 +++++++++++++++++++++++--------- man/wilcoxon_test.Rd | 14 +++++++++----- 9 files changed, 99 insertions(+), 51 deletions(-) diff --git a/R/chi_squared_test.R b/R/chi_squared_test.R index 58e00917..395848e1 100644 --- a/R/chi_squared_test.R +++ b/R/chi_squared_test.R @@ -39,7 +39,9 @@ #' #' Interpretation of effect sizes are based on rules described in #' [`effectsize::interpret_phi()`], [`effectsize::interpret_cramers_v()`], -#' and [`effectsize::interpret_fei()`]. +#' and [`effectsize::interpret_fei()`]. Use these function directly to get other +#' interpretations, by providing the returned effect size as argument, e.g. +#' `interpret_phi(0.35, rules = "gignac2016")`. #' #' @references #' - Ben-Shachar, M.S., Patil, I., Thériault, R., Wiernik, B.M., diff --git a/R/kruskal_wallis_test.R b/R/kruskal_wallis_test.R index 24bc2cea..92852826 100644 --- a/R/kruskal_wallis_test.R +++ b/R/kruskal_wallis_test.R @@ -1,10 +1,10 @@ #' @title Kruskal-Wallis test #' @name kruskal_wallis_test -#' @description This function performs a Kruskal-Wallis rank sum test, to test -#' the null hypothesis that the population median of all of the groups are -#' equal. The alternative is that they differ in at least one. Unlike the -#' underlying base R function `kruskal.test()`, this function allows for -#' weighted tests. +#' @description This function performs a Kruskal-Wallis rank sum test, which is +#' a non-parametric method to test the null hypothesis that the population median +#' of all of the groups are equal. The alternative is that they differ in at +#' least one. Unlike the underlying base R function `kruskal.test()`, this +#' function allows for weighted tests. #' #' @inheritParams mann_whitney_test #' @inherit mann_whitney_test seealso @@ -19,7 +19,7 @@ #' #' - du Prel, J.B., Röhrig, B., Hommel, G., Blettner, M. Auswahl statistischer #' Testverfahren. Dtsch Arztebl Int 2010; 107(19): 343–8 -#' +#' #' @details The function simply is a wrapper around [`kruskal.test()`]. The #' weighted version of the Kruskal-Wallis test is based on the **survey** package, #' using [`survey::svyranktest()`]. diff --git a/R/mann_whitney_test.R b/R/mann_whitney_test.R index a307f8ef..efe8ac77 100644 --- a/R/mann_whitney_test.R +++ b/R/mann_whitney_test.R @@ -76,11 +76,15 @@ #' be using a linear mixed model. #' #' @seealso -#' - [`mann_whitney_test()`] for unpaired (independent) samples. -#' - [`t_test()`] for parametric t-tests. -#' - [`kruskal_wallis_test()`] for non-parametric ANOVA (i.e. more than two samples). -#' - [`wilcoxon_test()`] for Wilcoxon rank sum tests for paired (dependent) samples. -#' - [`chi_squared_test()`] for chi-squared tests (two categorical variables). +#' - [`t_test()`] for parametric t-tests of dependent and independent samples. +#' - [`mann_whitney_test()`] for non-parametric tests of unpaired (independent) +#' samples. +#' - [`wilcoxon_test()`] for Wilcoxon rank sum tests for non-parametric tests +#' of paired (dependent) samples. +#' - [`kruskal_wallis_test()`] for non-parametric tests with more than two +#' independent samples. +#' - [`chi_squared_test()`] for chi-squared tests (two categorical variables, +#' dependent and independent). #' #' @return A data frame with test results. The function returns p and Z-values #' as well as effect size r and group-rank-means. diff --git a/R/t_test.R b/R/t_test.R index 7b3a1c88..de9e5dd6 100644 --- a/R/t_test.R +++ b/R/t_test.R @@ -1,9 +1,15 @@ #' @title Student's t test #' @name t_test #' @description This function performs a Student's t test for two independent -#' samples, for paired samples, or for one sample. Unlike the underlying -#' base R function `t.test()`, this function allows for weighted tests and -#' automatically calculates effect sizes. +#' samples, for paired samples, or for one sample. It's a parametric test for +#' the null hypothesis that the means of two independent samples are equal, or +#' that the mean of one sample is equal to a specified value. The hypothesis +#' can be one- or two-sided. +#' +#' Unlike the underlying base R function `t.test()`, this function allows for +#' weighted tests and automatically calculates effect sizes. Cohen's _d_ is +#' returned for larger samples (n > 20), while Hedges' _g_ is returned for +#' smaller samples. #' #' @inheritParams mann_whitney_test #' @param paired Logical, whether to compute a paired t-test for dependent @@ -14,8 +20,12 @@ #' #' @details Interpretation of effect sizes are based on rules described in #' [`effectsize::interpret_cohens_d()`] and [`effectsize::interpret_hedges_g()`]. +#' Use these function directly to get other interpretations, by providing the +#' returned effect size (_Cohen's d_ or _Hedges's g_ in this case) as argument, +#' e.g. `interpret_cohens_d(0.35, rules = "sawilowsky2009")`. #' -#' @return A data frame with test results. +#' @return A data frame with test results. Effectsize Cohen's _d_ is returned +#' for larger samples (n > 20), while Hedges' _g_ is returned for smaller samples. #' #' @references #' - Bender, R., Lange, S., Ziegler, A. Wichtige Signifikanztests. diff --git a/man/chi_squared_test.Rd b/man/chi_squared_test.Rd index e2143371..8c340af0 100644 --- a/man/chi_squared_test.Rd +++ b/man/chi_squared_test.Rd @@ -82,7 +82,9 @@ table, using \code{\link[=xtabs]{xtabs()}} as input for \code{chisq.test()}. Interpretation of effect sizes are based on rules described in \code{\link[effectsize:interpret_r]{effectsize::interpret_phi()}}, \code{\link[effectsize:interpret_r]{effectsize::interpret_cramers_v()}}, -and \code{\link[effectsize:interpret_r]{effectsize::interpret_fei()}}. +and \code{\link[effectsize:interpret_r]{effectsize::interpret_fei()}}. Use these function directly to get other +interpretations, by providing the returned effect size as argument, e.g. +\code{interpret_phi(0.35, rules = "gignac2016")}. } \section{Which test to use}{ @@ -147,10 +149,14 @@ Testverfahren. Dtsch Arztebl Int 2010; 107(19): 343–8 } \seealso{ \itemize{ -\item \code{\link[=mann_whitney_test]{mann_whitney_test()}} for unpaired (independent) samples. -\item \code{\link[=t_test]{t_test()}} for parametric t-tests. -\item \code{\link[=kruskal_wallis_test]{kruskal_wallis_test()}} for non-parametric ANOVA (i.e. more than two samples). -\item \code{\link[=wilcoxon_test]{wilcoxon_test()}} for Wilcoxon rank sum tests for paired (dependent) samples. -\item \code{\link[=chi_squared_test]{chi_squared_test()}} for chi-squared tests (two categorical variables). +\item \code{\link[=t_test]{t_test()}} for parametric t-tests of dependent and independent samples. +\item \code{\link[=mann_whitney_test]{mann_whitney_test()}} for non-parametric tests of unpaired (independent) +samples. +\item \code{\link[=wilcoxon_test]{wilcoxon_test()}} for Wilcoxon rank sum tests for non-parametric tests +of paired (dependent) samples. +\item \code{\link[=kruskal_wallis_test]{kruskal_wallis_test()}} for non-parametric tests with more than two +independent samples. +\item \code{\link[=chi_squared_test]{chi_squared_test()}} for chi-squared tests (two categorical variables, +dependent and independent). } } diff --git a/man/kruskal_wallis_test.Rd b/man/kruskal_wallis_test.Rd index e97eb0d6..ac6251d9 100644 --- a/man/kruskal_wallis_test.Rd +++ b/man/kruskal_wallis_test.Rd @@ -39,11 +39,11 @@ test. If \code{by} is not a factor, it will be coerced to a factor. For A data frame with test results. } \description{ -This function performs a Kruskal-Wallis rank sum test, to test -the null hypothesis that the population median of all of the groups are -equal. The alternative is that they differ in at least one. Unlike the -underlying base R function \code{kruskal.test()}, this function allows for -weighted tests. +This function performs a Kruskal-Wallis rank sum test, which is +a non-parametric method to test the null hypothesis that the population median +of all of the groups are equal. The alternative is that they differ in at +least one. Unlike the underlying base R function \code{kruskal.test()}, this +function allows for weighted tests. } \details{ The function simply is a wrapper around \code{\link[=kruskal.test]{kruskal.test()}}. The @@ -118,10 +118,14 @@ Testverfahren. Dtsch Arztebl Int 2010; 107(19): 343–8 } \seealso{ \itemize{ -\item \code{\link[=mann_whitney_test]{mann_whitney_test()}} for unpaired (independent) samples. -\item \code{\link[=t_test]{t_test()}} for parametric t-tests. -\item \code{\link[=kruskal_wallis_test]{kruskal_wallis_test()}} for non-parametric ANOVA (i.e. more than two samples). -\item \code{\link[=wilcoxon_test]{wilcoxon_test()}} for Wilcoxon rank sum tests for paired (dependent) samples. -\item \code{\link[=chi_squared_test]{chi_squared_test()}} for chi-squared tests (two categorical variables). +\item \code{\link[=t_test]{t_test()}} for parametric t-tests of dependent and independent samples. +\item \code{\link[=mann_whitney_test]{mann_whitney_test()}} for non-parametric tests of unpaired (independent) +samples. +\item \code{\link[=wilcoxon_test]{wilcoxon_test()}} for Wilcoxon rank sum tests for non-parametric tests +of paired (dependent) samples. +\item \code{\link[=kruskal_wallis_test]{kruskal_wallis_test()}} for non-parametric tests with more than two +independent samples. +\item \code{\link[=chi_squared_test]{chi_squared_test()}} for chi-squared tests (two categorical variables, +dependent and independent). } } diff --git a/man/mann_whitney_test.Rd b/man/mann_whitney_test.Rd index 0b47e9d0..d9c4aaca 100644 --- a/man/mann_whitney_test.Rd +++ b/man/mann_whitney_test.Rd @@ -157,10 +157,14 @@ Testverfahren. Dtsch Arztebl Int 2010; 107(19): 343–8 } \seealso{ \itemize{ -\item \code{\link[=mann_whitney_test]{mann_whitney_test()}} for unpaired (independent) samples. -\item \code{\link[=t_test]{t_test()}} for parametric t-tests. -\item \code{\link[=kruskal_wallis_test]{kruskal_wallis_test()}} for non-parametric ANOVA (i.e. more than two samples). -\item \code{\link[=wilcoxon_test]{wilcoxon_test()}} for Wilcoxon rank sum tests for paired (dependent) samples. -\item \code{\link[=chi_squared_test]{chi_squared_test()}} for chi-squared tests (two categorical variables). +\item \code{\link[=t_test]{t_test()}} for parametric t-tests of dependent and independent samples. +\item \code{\link[=mann_whitney_test]{mann_whitney_test()}} for non-parametric tests of unpaired (independent) +samples. +\item \code{\link[=wilcoxon_test]{wilcoxon_test()}} for Wilcoxon rank sum tests for non-parametric tests +of paired (dependent) samples. +\item \code{\link[=kruskal_wallis_test]{kruskal_wallis_test()}} for non-parametric tests with more than two +independent samples. +\item \code{\link[=chi_squared_test]{chi_squared_test()}} for chi-squared tests (two categorical variables, +dependent and independent). } } diff --git a/man/t_test.Rd b/man/t_test.Rd index 32121956..b3385295 100644 --- a/man/t_test.Rd +++ b/man/t_test.Rd @@ -54,17 +54,27 @@ must be one of \code{"two.sided"} (default), \code{"greater"} or \code{"less"}. and \code{?wilcox.test}.} } \value{ -A data frame with test results. +A data frame with test results. Effectsize Cohen's \emph{d} is returned +for larger samples (n > 20), while Hedges' \emph{g} is returned for smaller samples. } \description{ This function performs a Student's t test for two independent -samples, for paired samples, or for one sample. Unlike the underlying -base R function \code{t.test()}, this function allows for weighted tests and -automatically calculates effect sizes. +samples, for paired samples, or for one sample. It's a parametric test for +the null hypothesis that the means of two independent samples are equal, or +that the mean of one sample is equal to a specified value. The hypothesis +can be one- or two-sided. + +Unlike the underlying base R function \code{t.test()}, this function allows for +weighted tests and automatically calculates effect sizes. Cohen's \emph{d} is +returned for larger samples (n > 20), while Hedges' \emph{g} is returned for +smaller samples. } \details{ Interpretation of effect sizes are based on rules described in \code{\link[effectsize:interpret_cohens_d]{effectsize::interpret_cohens_d()}} and \code{\link[effectsize:interpret_cohens_d]{effectsize::interpret_hedges_g()}}. +Use these function directly to get other interpretations, by providing the +returned effect size (\emph{Cohen's d} or \emph{Hedges's g} in this case) as argument, +e.g. \code{interpret_cohens_d(0.35, rules = "sawilowsky2009")}. } \section{Which test to use}{ @@ -129,10 +139,14 @@ Testverfahren. Dtsch Arztebl Int 2010; 107(19): 343–8 } \seealso{ \itemize{ -\item \code{\link[=mann_whitney_test]{mann_whitney_test()}} for unpaired (independent) samples. -\item \code{\link[=t_test]{t_test()}} for parametric t-tests. -\item \code{\link[=kruskal_wallis_test]{kruskal_wallis_test()}} for non-parametric ANOVA (i.e. more than two samples). -\item \code{\link[=wilcoxon_test]{wilcoxon_test()}} for Wilcoxon rank sum tests for paired (dependent) samples. -\item \code{\link[=chi_squared_test]{chi_squared_test()}} for chi-squared tests (two categorical variables). +\item \code{\link[=t_test]{t_test()}} for parametric t-tests of dependent and independent samples. +\item \code{\link[=mann_whitney_test]{mann_whitney_test()}} for non-parametric tests of unpaired (independent) +samples. +\item \code{\link[=wilcoxon_test]{wilcoxon_test()}} for Wilcoxon rank sum tests for non-parametric tests +of paired (dependent) samples. +\item \code{\link[=kruskal_wallis_test]{kruskal_wallis_test()}} for non-parametric tests with more than two +independent samples. +\item \code{\link[=chi_squared_test]{chi_squared_test()}} for chi-squared tests (two categorical variables, +dependent and independent). } } diff --git a/man/wilcoxon_test.Rd b/man/wilcoxon_test.Rd index 16813919..fc4d2db3 100644 --- a/man/wilcoxon_test.Rd +++ b/man/wilcoxon_test.Rd @@ -135,10 +135,14 @@ Testverfahren. Dtsch Arztebl Int 2010; 107(19): 343–8 } \seealso{ \itemize{ -\item \code{\link[=mann_whitney_test]{mann_whitney_test()}} for unpaired (independent) samples. -\item \code{\link[=t_test]{t_test()}} for parametric t-tests. -\item \code{\link[=kruskal_wallis_test]{kruskal_wallis_test()}} for non-parametric ANOVA (i.e. more than two samples). -\item \code{\link[=wilcoxon_test]{wilcoxon_test()}} for Wilcoxon rank sum tests for paired (dependent) samples. -\item \code{\link[=chi_squared_test]{chi_squared_test()}} for chi-squared tests (two categorical variables). +\item \code{\link[=t_test]{t_test()}} for parametric t-tests of dependent and independent samples. +\item \code{\link[=mann_whitney_test]{mann_whitney_test()}} for non-parametric tests of unpaired (independent) +samples. +\item \code{\link[=wilcoxon_test]{wilcoxon_test()}} for Wilcoxon rank sum tests for non-parametric tests +of paired (dependent) samples. +\item \code{\link[=kruskal_wallis_test]{kruskal_wallis_test()}} for non-parametric tests with more than two +independent samples. +\item \code{\link[=chi_squared_test]{chi_squared_test()}} for chi-squared tests (two categorical variables, +dependent and independent). } }