Learn R Programming

tidyBF (version 0.3.0)

bf_ttest: Bayes Factor for t-test

Description

Bayes Factor for t-test

Usage

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

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

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

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 column in data containing the response (outcome) variable to be plotted on the y-axis. Can be entered either as a character string (e.g., "y") or as a bare expression (e.g, y).

test.value

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

paired

Decides whether the design is repeated measures or not (Default: FALSE).

bf.prior

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

caption

Text to display as caption (will be displayed on top of the Bayes Factor caption/message).

output

Can either be "null" (or "caption" or "H0" or "h0"), which will return expression with evidence in favor of the null hypothesis, or "alternative" (or "title" or "H1" or "h1"), which will return expression with evidence in favor of the alternative hypothesis, 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 = 2L).

...

Additional arguments passed to parameters::model_parameters.BFBayesFactor().

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

Examples

Run this code
# NOT RUN {
# ------------------- two-samples tests -----------------------------------

# for reproducibility
set.seed(123)
library(tidyBF)

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

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

# to get dataframe
bf_ttest(
  data = iris,
  x = Sepal.Length,
  test.value = 5.85
)
# }

Run the code above in your browser using DataLab