Learn R Programming

cocoon (version 0.2.0)

format_bf: Format Bayes factors

Description

format_bf() can input either a BayesFactor object or a vector of Bayes factor values. By default, this function rounds Bayes factors greater than 1 to one decimal place and Bayes factors less than 1 to two decimal places. Values greater than 1000 or less than 1/1000 are formatted using scientific notation. Cutoffs can be set that format the values as greater than or less than the cutoffs (e.g., BF > 1000 or BF < 0.001). Numbers of digits, cutoffs, italics, and label subscripts are all customizable.

Usage

format_bf(
  x,
  digits1 = 1,
  digits2 = 2,
  cutoff = NULL,
  label = "BF",
  italics = TRUE,
  subscript = "10",
  type = "md"
)

Value

A character string that includes label (by default BF~10~) and then the Bayes factor formatted in Markdown or LaTeX. If Bayes factor is above or below cutoff, _BF_~10~ > <cutoff> or _BF_~10~ < 1 / <cutoff> is used.

Arguments

x

BayesFactor object or vector of numeric Bayes factor values.

digits1

Number of digits after the decimal for Bayes factors > 1.

digits2

Number of digits after the decimal for Bayes factors < 1.

cutoff

Cutoff for using _BF_~10~ > <cutoff> or _BF_~10~ < 1 / <cutoff> (value must be > 1).

label

Character string for label before Bayes factor. Default is BF. Set label = "" to return just the formatted Bayes factor value with no label or operator (=, <, >).

italics

Logical value (default = TRUE) for whether label should be italicized (BF or BF).

subscript

Subscript to include with BF label ("10", "01", or "" for no subscript).

type

Type of formatting ("md" = markdown, "latex" = LaTeX).

See Also

Other functions for printing statistical objects: format_corr(), format_stats(), format_stats.BFBayesFactor(), format_stats.aov(), format_stats.easycorrelation(), format_stats.htest(), format_stats.lm(), format_stats.lmerModLmerTest(), format_stats.merMod(), format_ttest()

Examples

Run this code
# Format BFBayesfactor objects from {BayesFactor} package
format_bf(BayesFactor::lmBF(mpg ~ am, data = mtcars))

# Format Bayes factors > 1
format_bf(12.4444)

# Bayes factors > 1000 will use scientific notation
format_bf(1244.44)

# Control digits for Bayes factors > 1 with digits1
format_bf(1244.44, digits1 = 3)

# Control cutoff for output
format_bf(1244.44, cutoff = 10000)

# Format Bayes factors < 1
format_bf(0.111)

# Bayes factors < 0.001 will use scientific notation
format_bf(0.0001)

# Control digits for Bayes factors < 1 with digits2
format_bf(0.111, digits2 = 3)

# Control cutoff for output
format_bf(0.001, cutoff = 100)

# Return only Bayes factor value (no label)
format_bf(12.4444, label = "")

# Format for LaTeX
format_bf(12.4444, type = "latex")

Run the code above in your browser using DataLab