Expression for one sample t-test and its non-parametric and robust equivalents

expr_t_onesample(
  data,
  x,
  type = "parametric",
  test.value = 0,
  k = 2L,
  conf.level = 0.95,
  conf.type = "norm",
  bf.prior = 0.707,
  robust.estimator = "onestep",
  effsize.type = "g",
  nboot = 100L,
  output = "expression",
  ...
)

Arguments

data

A dataframe (or a tibble) from which variables specified are to be taken. A matrix or tables will not be accepted.

x

A numeric variable from the dataframe data.

type

Type of statistic expected ("parametric" or "nonparametric" or "robust" or "bayes").Corresponding abbreviations are also accepted: "p" (for parametric), "np" (nonparametric), "r" (robust), or "bf"resp.

test.value

A number specifying the value of the null hypothesis (Default: 0).

k

Number of digits after decimal point (should be an integer) (Default: k = 2L).

conf.level

Scalar between 0 and 1. If unspecified, the defaults return 95% lower and upper confidence intervals (0.95).

conf.type

A vector of character strings representing the type of intervals required. The value should be any subset of the values "norm", "basic", "perc", "bca". For more, see ?boot::boot.ci.

bf.prior

A number between 0.5 and 2 (default 0.707), the prior width to use in calculating Bayes factors.

robust.estimator

If type = "robust", a robust estimator to be used ("onestep" (Default), "mom", or "median"). For more, see ?WRS2::onesampb.

effsize.type

Type of effect size needed for parametric tests. The argument can be "d" (for Cohen's d) or "g" (for Hedge's g).

nboot

Number of bootstrap samples for computing confidence interval for the effect size (Default: 100).

output

If "expression", will return expression with statistical details, while "dataframe" will return a dataframe containing the results.

...

Additional arguments passed to tidyBF::bf_ttest.

Value

Expression containing results from a one-sample test. The exact test and the effect size details contained will be dependent on the type argument.

References

For more details, see- https://indrajeetpatil.github.io/statsExpressions/articles/stats_details.html

Examples

# \donttest{ # for reproducibility set.seed(123) library(statsExpressions) # ----------------------- parametric --------------------------------------- expr_t_onesample( data = ggplot2::msleep, x = brainwt, test.value = 0.275, type = "parametric" )
#> paste(italic("t")["Student"], "(", "55", ") = ", "0.05", ", ", #> italic("p"), " = ", "0.960", ", ", widehat(italic("g"))["Hedge"], #> " = ", "0.01", ", CI"["95%"], " [", "-0.25", ", ", "0.27", #> "]", ", ", italic("n")["obs"], " = ", 56L)
# ----------------------- non-parametric ----------------------------------- expr_t_onesample( data = ggplot2::msleep, x = brainwt, test.value = 0.275, type = "nonparametric" )
#> paste("log"["e"](italic("V")["Wilcoxon"]), " = ", "5.51", ", ", #> italic("p"), " = ", "7.38e-06", ", ", widehat(italic("r")), #> " = ", "-0.60", ", CI"["95%"], " [", "-0.83", ", ", "-0.39", #> "]", ", ", italic("n")["obs"], " = ", 56L)
# ----------------------- robust -------------------------------------------- expr_t_onesample( data = ggplot2::msleep, x = brainwt, test.value = 0.275, type = "robust" )
#> paste(italic("M")["robust"], " = ", "0.02", ", CI"["95%"], " [", #> "0.01", ", ", "0.05", "], ", italic("p"), " = ", "0e+00", #> ", ", italic("n")["obs"], " = ", 56L)
# ----------------------- Bayes Factor ----------------------------------- expr_t_onesample( data = ggplot2::msleep, x = brainwt, test.value = 0.275, type = "bayes", bf.prior = 0.8 )
#> paste("log"["e"], "(BF"["01"], ") = ", "2.04", ", ", widehat(italic(delta))["median"]^"posterior", #> " = ", "0.01", ", CI"["95%"]^"HDI", " [", "-0.25", ", ", #> "0.26", "]", ", ", italic("r")["Cauchy"]^"JZS", " = ", "0.80")
# }