Learn R Programming

tidyBF (version 0.4.0)

bf_oneway_anova: Bayes Factor for one-way analysis of variance (ANOVA)

Description

Bayes Factor for one-way analysis of variance (ANOVA)

Usage

bf_oneway_anova(
  data,
  x,
  y,
  subject.id = NULL,
  paired = FALSE,
  bf.prior = 0.707,
  ...
)

Arguments

data

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

x

The grouping variable from the dataframe data.

y

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

subject.id

In case of repeated measures design (paired = TRUE, i.e.), this argument specifies the subject or repeated measures id. Note that if this argument is NULL (which is the default), the function assumes that the data has already been sorted by such an id by the user and creates an internal identifier. So if your data is not sorted and you leave this argument unspecified, the results can be inaccurate.

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.

...

Arguments passed on to bf_extractor

conf.level

Confidence/Credible Interval (CI) level. Default to 0.95 (95%).

centrality

The point-estimates (centrality indices) to compute. Character (vector) or list with one or more of these options: "median", "mean", "MAP" or "all".

conf.method

The type of index used for Credible Interval. Can be "hdi" (default, see bayestestR::hdi()), "eti" (see bayestestR::eti()) or "si" (see bayestestR::si()).

k

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

top.text

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

output

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

See Also

bf_contingency_tab, bf_corr_test, bf_ttest

Examples

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

# between-subjects -------------------------------------------------------

# to get dataframe
bf_oneway_anova(
  data = iris,
  x = Species,
  y = Sepal.Length,
  bf.prior = 0.8,
  output = "dataframe"
)

# within-subjects -------------------------------------------------------

# to get expression (needs `BayesFactor 0.9.12-4.3`)
if (utils::packageVersion("BayesFactor") >= package_version("0.9.12-4.3")) {
  bf_oneway_anova(
    data = bugs_long,
    x = condition,
    y = desire,
    subject.id = subject,
    paired = TRUE,
    output = "expression"
  )
}
# }

Run the code above in your browser using DataLab