aggregate_df
.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)
amultinomial(data, col_name, all_categories = NULL)
A one-row data frame containing counts for each of the first \(K - 1\) categories.
A vector containing the multinomial observations (will be coerced to character).
A character string giving the name of the column (primarily for context/error messages, less critical now).
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).