Learn R Programming

statsExpressions (version 0.5.1)

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

Description

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

Usage

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,
  stat.title = NULL,
  ...
)

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 = 2).

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).

stat.title

A character describing the test being run, which will be added as a prefix in the subtitle. The default is NULL. An example of a stat.title argument will be something like "Student's t-test: ".

...

Additional arguments (currently ignored).

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

Run this code
# NOT RUN {
# for reproducibility
set.seed(123)

# ----------------------- parametric ---------------------------------------

statsExpressions::expr_t_onesample(
  data = ggplot2::msleep,
  x = brainwt,
  test.value = 0.275,
  type = "parametric"
)

# ----------------------- non-parametric -----------------------------------

statsExpressions::expr_t_onesample(
  data = ggplot2::msleep,
  x = brainwt,
  test.value = 0.275,
  type = "nonparametric"
)

# ----------------------- robust --------------------------------------------

statsExpressions::expr_t_onesample(
  data = ggplot2::msleep,
  x = brainwt,
  test.value = 0.275,
  type = "robust"
)

# ----------------------- Bayes Factor -----------------------------------

statsExpressions::expr_t_onesample(
  data = ggplot2::msleep,
  x = brainwt,
  test.value = 0.275,
  type = "bayes",
  bf.prior = 0.8
)
# }

Run the code above in your browser using DataLab