bf_contingency_tab: Bayes Factor for contingency table analysis

Description Usage Arguments See Also Examples

View source: R/bf_contingency_tab.R

Description

Bayes Factor for contingency table analysis

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
bf_contingency_tab(
  data,
  x,
  y = NULL,
  counts = NULL,
  ratio = NULL,
  sampling.plan = "indepMulti",
  fixed.margin = "rows",
  prior.concentration = 1,
  top.text = NULL,
  output = "dataframe",
  k = 2L,
  ...
)

Arguments

data

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

x

The variable to use as the rows in the contingency table.

y

The variable to use as the columns in the contingency table. Default is NULL. If NULL, one-sample proportion test (a goodness of fit test) will be run for the main variable. Otherwise an appropriate association test will be run.

counts

A string naming a variable in data containing counts, or NULL if each row represents a single observation.

ratio

A vector of proportions: the expected proportions for the proportion test (should sum to 1). Default is NULL, which means the null is equal theoretical proportions across the levels of the nominal variable. This means if there are two levels this will be ratio = c(0.5,0.5) or if there are four levels this will be ratio = c(0.25,0.25,0.25,0.25), etc.

sampling.plan

Character describing the sampling plan. Possible options are "indepMulti" (independent multinomial; default), "poisson", "jointMulti" (joint multinomial), "hypergeom" (hypergeometric). For more, see ?BayesFactor::contingencyTableBF().

fixed.margin

For the independent multinomial sampling plan, which margin is fixed ("rows" or "cols"). Defaults to "rows".

prior.concentration

Specifies the prior concentration parameter, set to 1 by default. It indexes the expected deviation from the null hypothesis under the alternative, and corresponds to Gunel and Dickey's (1974) "a" parameter.

top.text

Text to display on top of the Bayes Factor message. This is mostly relevant in the context of ggstatsplot functions.

output

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

k

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

...

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), "eti", or "si" (see si(), hdi(), eti() functions from bayestestR package).

See Also

bf_corr_test, bf_oneway_anova, bf_ttest

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# for reproducibility
set.seed(123)
library(tidyBF)

# ------------------ association tests --------------------------------

# to get dataframe
bf_contingency_tab(
  data = mtcars,
  x = am,
  y = cyl,
  output = "dataframe"
)

# ------------------ goodness of fit tests --------------------------------

# to get expression
bf_contingency_tab(
  data = mtcars,
  x = am,
  prior.concentration = 10,
  output = "expression"
)

tidyBF documentation built on June 12, 2021, 9:06 a.m.