modal_confidence: Calculate the modal confidence across event reports

View source: R/modal_confidence.R

modal_confidenceR Documentation

Description

This function calculates the modal confidence score for one or more variables grouped by an event identifier. The modal confidence score captures how dominant the most common value is within each event — that is, the proportion of event reports that agree with the modal (most frequent) value for each variable.

Usage

modal_confidence(data, group_var, variables)

Arguments

data

A data frame containing event report level data.

group_var

A character string naming the column that uniquely identifies events (e.g., "event_id").

variables

A character vector of column names to assess modal confidence for.

Details

For each variable and event, the function computes the share of event reports that match the modal value. These proportions are then averaged across all events to produce a single score per variable. The result is a long-format dataframe that shows which variables tend to exhibit the greatest agreement in reporting.

Value

A tibble with two columns:

variable

The name of each variable.

modal_confidence

The average share of reports per event that match the modal value.

Examples

df <- data.frame(
  event_id = c(1, 1, 2, 2, 3),
  actor1 = c("A", "A", "B", "C", "D"),
  deaths_best = c(10, 10, 5, 15, 10)
)
modal_confidence(
  df,
  group_var = "event_id",
  variables = c("actor1", "deaths_best")
)

eventreport documentation built on March 11, 2026, 1:07 a.m.