Learn R Programming

tidyBF (version 0.2.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",
  hypothesis.text = TRUE,
  k = 2,
  ...
)

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

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

Arguments

data

for use with formula, a data frame containing all the data

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

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

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

hypothesis.text

Logical that decides whether the expression containing result should have text to describe the hypothesis test being described. For output = "null", this is "In favor of null: ", otherwise "In favor of alternative: ".

k

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

...

Additional arguments (ignored).

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