calc_ac | R Documentation |
This function computes various agreement coefficients based on the type of
input data provided, including raw data, contingency tables, or
distributions. It automatically selects the appropriate calculation method
based on whether data
, table
, or distribution
is provided.
calc_ac(
data = NULL,
...,
table = NULL,
distribution = NULL,
weights = "unweighted",
categ = NULL,
conf_lev = 0.95,
N = Inf,
test_value = 0,
alternative = "two.sided",
show_weights = FALSE
)
data |
A data frame containing raw ratings data. Only used if |
... |
Columns within the |
table |
A contingency table of ratings. Only used if |
distribution |
A distribution matrix of ratings. Only used if |
weights |
The weighting method for agreement calculation. Default is "unweighted". |
categ |
A vector of category names, optional. |
conf_lev |
Confidence level for confidence intervals. Default is 0.95. |
N |
Population size for finite population correction. Default is |
test_value |
The null hypothesis value for hypothesis testing. Default is 0. |
alternative |
The alternative hypothesis to test: "two.sided", "less", or "greater". Default is "two.sided". |
show_weights |
Logical, whether to include the weights matrix in the output. Default is FALSE. |
A list containing the summary of the input, agreement coefficient
table, and hypothesis text. If show_weights
is TRUE, the weights matrix
is included in the output.
library(tidyverse)
library(janitor)
#### Example 1 --------------------------------
# two radiologists who classify 85 xeromammograms into one of four categories
# (Altman p. 403)
radiologist
radiologist |>
janitor::tabyl(radiologist_a, radiologist_b) |>
janitor::adorn_totals(where = c("row", "col")) |>
janitor::adorn_title(placement = "combined")
## With a raw data frame ----------------
calc_ac(data = radiologist,
radiologist_a, radiologist_b)
## With a table ----------------
(tab <- with(radiologist,
table(radiologist_a, radiologist_b)))
calc_ac(table = tab)
## With a distribution ----------------
ex_dist <- radiologist |>
mutate(subject = dplyr::row_number()) |>
calc_agree_mat(dplyr::starts_with("radiologist"),
subject_id = subject)
ex_dist
calc_ac(distribution = ex_dist)
#### Example 5 --------------------------------
# 5 raters classify 10 subjects into 1 of 3 rating categories
rvary2
## With a raw data frame ----------------
calc_ac(data = rvary2,
dplyr::starts_with("rater"))
## With a table ----------------
# Only works for 2x2 tables. This example has more than 2 raters.
## With a distribution ----------------
ex_dist <- calc_agree_mat(data = rvary2,
dplyr::starts_with("rater"),
subject_id = subject)
ex_dist
calc_ac(distribution = ex_dist)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.