View source: R/apa_print_BFBayesFactor.R
apa_print.BFBayesFactor | R Documentation |
These methods take result objects from the BayesFactor package to create formatted character strings to report the results in accordance with APA manuscript guidelines.
## S3 method for class 'BFBayesFactor'
apa_print(
x,
stat_name = NULL,
est_name = NULL,
subscript = NULL,
escape_subscript = FALSE,
scientific_threshold = NULL,
reciprocal = FALSE,
log = FALSE,
mcmc_error = any(x@bayesFactor$error > 0.05),
iterations = 10000,
standardized = FALSE,
central_tendency = median,
interval = hd_int,
interval_type = "HDI",
bf_r1 = NULL,
bf_1r = NULL,
...
)
## S3 method for class 'BFBayesFactorTop'
apa_print(x, reciprocal = FALSE, ...)
x |
Output object. See details. |
stat_name |
Character. If |
est_name |
Character. If |
subscript |
Character. Index used to specify the model comparison for
the Bayes factors, e.g., |
escape_subscript |
Logical. If |
scientific_threshold |
Numeric. Named vector of length 2 taking the form
|
reciprocal |
Logical. If |
log |
Logical. If |
mcmc_error |
Logical. If |
iterations |
Numeric. Number of iterations of the MCMC sampler to estimate HDIs from the posterior. |
standardized |
Logical. Whether to return standardized or unstandardized effect size estimates. |
central_tendency |
Function to calculate central tendency of MCMC samples to obtain a point estimate from the posterior. |
interval |
Function to calculate an interval estimate of MCMC
samples from the posterior. The returned object must be either a named
vector or matrix with (column) names giving the interval bounds
(e.g., |
interval_type |
Character. Used to specify the type of interval in the formatted text. |
bf_r1 |
Numeric. Vector of the same length as |
bf_1r |
Numeric. Same as |
... |
Arguments passed on to
|
stat_name
and est_name
are placed in the output string and are
thus passed to pandoc or LaTeX through knitr. To the extent it is
supported by the final document type, you can pass LaTeX-markup to format
the final text (e.g., M_\Delta
yields M_\Delta
).
For models with order constraint, the evidence for the order constraint
relative to the null model can be obtained by multiplying the
Bayes factor BF_{r1}
for the order constraint relative to the
unconstrained model (bf_r1
) with the Bayes factor BF_{10}
for the
unconstrained model relative to the null model,
\frac{p(y \mid {\cal M}_r)}{p(y \mid {\cal M}_0)} = \frac{p(y \mid {\cal M}_r)}{p(y \mid {\cal M}_1)} \times \frac{p(y \mid {\cal M}_1)}{p(y \mid {\cal M}_0)}
.
BF_{r1}
can be calculated from the prior and posterior odds of the
order constraint (e.g., Morey & Wagenmakers, 2014). If bf_r1
(or
bf_1r
) is specified they are multiplied with the corresponding Bayes
factor supplied in x
before the reciprocal is taken and the results are
formatted. Note, that it is not possible to determine whether x
gives
BF_{10}
or BF_{01}
and, hence, bf_r1
and bf_1r
are treated
identically; the different argument names only serve to ensure the
expressiveness of the code. It is the user's responsibility to ensure that
the supplied Bayes factor is correct!
apa_print()
-methods return a named list of class apa_results
containing the following elements:
estimate |
One or more character strings giving point estimates, confidence intervals, and confidence level. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is |
statistic |
One or more character strings giving the test statistic, parameters (e.g., degrees of freedom), and p-value. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is |
full_result |
One or more character strings comprised 'estimate' and 'statistic'. A single string is returned in a vector; multiple strings are returned as a named list. |
table |
A |
Column names in apa_results_table
are standardized following the broom glossary (e.g., term
, estimate
conf.int
, statistic
, df
, df.residual
, p.value
). Additionally, each column is labelled (e.g., $\hat{\eta}^2_G$
or $t$
) using the tinylabels package and these labels are used as column names when an apa_results_table
is passed to apa_table()
.
Morey, R. D., & Wagenmakers, E.-J. (2014). Simple relation between Bayesian order-restricted and point-null hypothesis tests. Statistics & Probability Letters, 92, 121–124. doi: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.spl.2014.05.010")}
Other apa_print:
apa_print()
,
apa_print.aov()
,
apa_print.emmGrid()
,
apa_print.glht()
,
apa_print.htest()
,
apa_print.list()
,
apa_print.lm()
,
apa_print.lme()
,
apa_print.merMod()
# ANOVA
data(sleep, package = "BayesFactor")
bayesian_anova <- BayesFactor::anovaBF(
extra ~ group + ID
, data = sleep
, whichRandom = "ID"
, progress = FALSE
)
# Paired t-test
ttest_paired <- BayesFactor::ttestBF(
x = sleep$extra[sleep$group == 1]
, y = sleep$extra[sleep$group == 2]
, paired = TRUE
)
# Results for paired t-tests are indistinguishable
# from one-sample t-tests. We therefore specify the
# appropriate `est_name` manually.
apa_print(
ttest_paired
, est_name = "M_D"
, iterations = 1000
)
apa_print(
ttest_paired
, iterations = 1000
, interval = function(x) quantile(x, probs = c(0.025, 0.975))
, interval_type = "CrI"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.