amultinomial: Aggregate multinomial data. Used in 'aggregate_df'.

View source: R/internal-multinomial_aggregation.R

amultinomialR Documentation

Aggregate multinomial data. Used in aggregate_df.

Description

Aggregates multinomial data into sufficient statistics for multinomial samples.
Converts input data to character before processing. For a sample \boldsymbol{y} = \{y_1, \dots, y_n\} with y_i \in \{1, \dots, K\}, P(y_i = k) = p_k, k=1, \dots, K, the sample is aggregated into the sufficient statistic

\boldsymbol{s} = (s_1, \dots, s_{K-1})

where

s_k = \sum_{i=1}^n \mathbb{I}(y_i = k) for k = 1, \dots, K-1.

(The last category is omitted due to the sum-to-one constraint)

Usage

amultinomial(data, col_name, all_categories = NULL)

Arguments

data

A vector containing the multinomial observations (will be coerced to character).

col_name

A character string giving the name of the column (primarily for context/error messages, less critical now).

all_categories

A character vector with the names or levels of all possible categories in the multinomial distribution (must include all observed values after coercion to character).

Value

A one-row data frame containing counts for each of the first K - 1 categories.


MAPCtools documentation built on June 25, 2025, 5:09 p.m.