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"
)
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)
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.
See also
Other functions for printing statistical objects:
format_corr()
,
format_stats()
,
format_stats.BFBayesFactor()
,
format_stats.easycorrelation()
,
format_stats.htest()
,
format_ttest()
Examples
# Format BFBayesfactor objects from {BayesFactor} package
format_bf(BayesFactor::lmBF(mpg ~ am, data = mtcars))
#> [1] "_BF_~10~ = 87.3"
# Format Bayes factors > 1
format_bf(12.4444)
#> [1] "_BF_~10~ = 12.4"
# Bayes factors > 1000 will use scientific notation
format_bf(1244.44)
#> [1] "_BF_~10~ = 1.2×10^3^"
# Control digits for Bayes factors > 1 with digits1
format_bf(1244.44, digits1 = 3)
#> [1] "_BF_~10~ = 1.244×10^3^"
# Control cutoff for output
format_bf(1244.44, cutoff = 10000)
#> [1] "_BF_~10~ = 1244.4"
# Format Bayes factors < 1
format_bf(0.111)
#> [1] "_BF_~10~ = 0.11"
# Bayes factors < 0.001 will use scientific notation
format_bf(0.0001)
#> [1] "_BF_~10~ = 1.0×10^-4^"
# Control digits for Bayes factors < 1 with digits2
format_bf(0.111, digits2 = 3)
#> [1] "_BF_~10~ = 0.111"
# Control cutoff for output
format_bf(0.001, cutoff = 100)
#> [1] "_BF_~10~ < 0.01"
# Return only Bayes factor value (no label)
format_bf(12.4444, label = "")
#> [1] "12.4"
# Format for LaTeX
format_bf(12.4444, type = "latex")
#> [1] "$BF$$_{10}$ = 12.4"