bf_ttest

0th

Percentile

Bayes Factor for t-test

Bayes Factor for t-test

Usage
bf_ttest(data, x, y = NULL, test.value = 0, paired = FALSE,
  bf.prior = 0.707, caption = NULL, output = "null", k = 2, ...)

bf_one_sample_ttest(data, x, y = NULL, test.value = 0, paired = FALSE, bf.prior = 0.707, caption = NULL, output = "null", k = 2, ...)

bf_two_sample_ttest(data, x, y = NULL, test.value = 0, paired = FALSE, bf.prior = 0.707, caption = NULL, output = "null", k = 2, ...)

Arguments
data

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

x

Either the grouping variable from the dataframe data if it's a two-sample t-test or a numeric variable if it's a one-sample t-test.

y

The response (a.k.a. outcome or dependent) variable from the dataframe data.

test.value

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

paired

if TRUE, observations are paired

bf.prior

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

caption

The text for the plot caption.

output

Can either be "null" (or "caption" or "H0", which will contain text for evidence in favor of the null hypothesis or H0) or "alternative" (or "title" or "H1") or "results", which will return a dataframe with results all the details).

k

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

...

further arguments to be passed to or from methods.

Details

If y is NULL, a one-sample t-test will be carried out, otherwise a two-sample t-test will be carried out.

See Also

bf_contingency_tab, bf_corr_test, bf_oneway_anova

Aliases
  • bf_ttest
  • bf_one_sample_ttest
  • bf_two_sample_ttest
Examples
# NOT RUN {
# ------------------- two-samples tests -----------------------------------

# for reproducibility
set.seed(123)

# to get caption (default)
bf_ttest(
  data = mtcars,
  x = am,
  y = wt,
  paired = FALSE,
  bf.prior = 0.880
)

# to see results
bf_ttest(
  data = mtcars,
  x = am,
  y = wt,
  paired = FALSE,
  output = "results"
)

# for paired sample test
bf_ttest(
  data = dplyr::filter(
    ggstatsplot::intent_morality,
    condition %in% c("accidental", "attempted"),
    harm == "Poisoning"
  ),
  x = condition,
  y = rating,
  paired = TRUE,
  output = "results"
)

# ------------------- one-samples test -----------------------------------

# to get caption (default)
bf_ttest(
  data = iris,
  x = Sepal.Length,
  test.value = 5.85,
  bf.prior = 0.8,
  output = "caption", k = 2
)

# to get results dataframe
bf_ttest(
  data = iris,
  x = Sepal.Length,
  test.value = 5.85,
  bf.prior = 0.8,
  output = "results"
)
# }
Documentation reproduced from package ggstatsplot, version 0.0.12, License: GPL-3 | file LICENSE

Community examples

Looks like there are no examples yet.