Package {Romney}


Type: Package
Title: Classical Cultural Consensus Analysis
Version: 0.1.1
Description: Implements classical cultural consensus analysis with formal, informal, and covariance agreement models, 'UCINET'-aligned minimum-residual factor extraction, competence estimation, and answer-key estimation. Based on the classical framework of Romney, Weller, and Batchelder (1986) <doi:10.1525/aa.1986.88.2.02a00020>, Romney, Batchelder, and Weller (1987) <doi:10.1177/000276487031002003>, and Weller (2007) <doi:10.1177/1525822X07303502>.
License: MIT + file LICENSE
Encoding: UTF-8
Imports: psych, stats
Suggests: knitr, rmarkdown, testthat (≥ 3.2.0)
VignetteBuilder: knitr
Config/testthat/edition: 3
URL: https://github.com/wernerhertzog/Romney
BugReports: https://github.com/wernerhertzog/Romney/issues
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2026-10-10 05:06:42 UTC; wberga
Author: Werner Hertzog ORCID iD [aut, cre]
Maintainer: Werner Hertzog <werner.hertzog@isek.uzh.ch>
Repository: CRAN
Date/Publication: 2026-10-10 05:30:09 UTC

Agreement matrices for consensus analysis

Description

Compute respondent-by-respondent agreement matrices for the formal, informal, and covariance consensus models.

Usage

agreement_formal(data, n_answers = NULL)

agreement_informal(data)

agreement_covariance(data, prior = 0.5, answer_levels = NULL)

Arguments

data

A respondent-by-item matrix or data frame.

n_answers

Number of possible answers for the formal model, including options that were not observed. All items must have the same options.

prior

Prior proportion of true items for the covariance model.

answer_levels

Optional vector of the two allowable binary responses.

Details

Missing responses are excluded pairwise, not imputed. Formal agreement is (m p_{ij} - 1)/(m - 1), where p_{ij} is the proportion of matching responses and m is the number of choices. Informal agreement uses Pearson correlations of respondent profiles. Numeric rank codes are treated as scores; arbitrary ordinal recoding is not invariant under Pearson correlation. Covariance agreement divides the sample covariance of binary profiles by \pi(1-\pi). The second allowed response value (by default the higher sorted value) is treated as true. Diagonals are set to one as input to factor extraction; they are not estimates of competence.

Value

A square agreement matrix.

References

Romney, A. K., Weller, S. C., and Batchelder, W. H. (1986). Culture as consensus: A theory of culture and informant accuracy. American Anthropologist, 88(2), 313–338. doi:10.1525/aa.1986.88.2.02a00020. Weller, S. C. (2007). Cultural consensus theory: Applications and frequently asked questions. Field Methods, 19(4), 339–368. doi:10.1177/1525822X07303502.

Examples

x <- rbind(c(0, 1, 1, 0), c(0, 1, 0, 0), c(1, 1, 1, 0))
agreement_formal(x, n_answers = 2)
agreement_covariance(x)

Estimate a binary competence-weighted answer key

Description

Estimate a binary competence-weighted answer key

Usage

answerkey_covariance(data, competence, answer_levels = NULL)

Arguments

data

A respondent-by-item matrix or data frame with two response values.

competence

Finite competence scores in [0,1], one per respondent.

answer_levels

Optional vector specifying the two allowable responses.

Details

Each observed response contributes its respondent's competence to the corresponding category. The category with the greater total weight is selected. Missing responses are omitted, and weights are normalized within each item. Ties within 10^{-12}, entirely missing items, and items with zero total weight have NA keys. This is a weighted vote, not a posterior probability calculation or an estimate of respondent response bias.

Value

A list with key, levels, status, weighted_proportions, and weighted_frequencies. Frequencies are proportions multiplied by the total number of respondents, as in 'UCINET' detail tables. Status may also be zero_weight.

References

Weller, S. C. (2007). Cultural consensus theory: Applications and frequently asked questions. Field Methods, 19(4), 339–368. doi:10.1177/1525822X07303502.

Examples

answerkey_covariance(matrix(c(0, 1, 1), ncol = 1), c(0.2, 0.8, 0.7))

Estimate a formal consensus answer key

Description

Estimate a formal consensus answer key

Usage

answerkey_formal(data, competence, prior = NULL, answer_levels = NULL)

Arguments

data

A respondent-by-item matrix or data frame.

competence

Numeric competence scores, one per respondent.

prior

Optional prior distribution over answer levels. Can be NULL, a vector of answer-level priors, or a matrix with one column per item.

answer_levels

Optional ordered vector of allowable answer levels.

Details

For candidate answer k, a matching response has likelihood c_i + (1-c_i)/m; each specific non-matching response has likelihood (1-c_i)/m. Posterior probabilities condition on the supplied competence estimates; they do not include uncertainty in those estimates. Computation uses log likelihoods. Ties within 10^{-12}, entirely missing items, and impossible observations have NA answer keys. Missing items retain their prior distribution. If every candidate has zero likelihood, probabilities are NA and a warning is issued. Weighted frequencies are separate descriptive quantities, not posteriors.

Value

A list with key, probabilities, levels, status, normalized prior, weighted_proportions, and weighted_frequencies. Status is estimated, tie, no_data, or impossible. Weighted frequencies are proportions multiplied by the total number of respondents, matching the scale of 'UCINET' detail tables.

References

Romney, A. K., Weller, S. C., and Batchelder, W. H. (1986). Culture as consensus: A theory of culture and informant accuracy. American Anthropologist, 88(2), 313–338. doi:10.1525/aa.1986.88.2.02a00020.

Examples

x <- matrix(c("A", "A", "B"), ncol = 1)
answerkey_formal(x, c(0.8, 0.7, 0.2), answer_levels = LETTERS[1:4])

Estimate an informal competence-weighted answer key

Description

Estimate an informal competence-weighted answer key

Usage

answerkey_informal(data, competence)

Arguments

data

A numeric respondent-by-item matrix or data frame.

competence

Finite signed factor loadings, one per respondent.

Details

Returns \sum_i c_i x_{ij} / \sum_i c_i over observed responses to each item. Signed weights are retained. A non-positive total weight or an entirely missing item produces an NA key. Negative weights can yield means outside the observed response range and warrant scrutiny of the single-culture assumption. These means are in the original response units; they are not standardized regression factor scores or posterior probabilities. Agreement uses Pearson correlations, so numeric coding of ordinal responses affects the analysis.

Value

A list with numeric key, status, and weight_sum.

References

Romney, A. K., Batchelder, W. H., and Weller, S. C. (1987). Recent applications of cultural consensus theory. American Behavioral Scientist, 31(2), 163–177. doi:10.1177/000276487031002003.

Examples

answerkey_informal(rbind(c(1, 4), c(2, 5)), c(0.8, 0.4))

Run a cultural consensus analysis

Description

Run a cultural consensus analysis

Usage

consensus(
  data,
  cultures = 1,
  method = c("formal", "informal", "covariance"),
  prior = 0.5,
  return_answer_key = TRUE,
  n_answers = NULL,
  answer_levels = NULL,
  competence_policy = c("strict", "truncate")
)

Arguments

data

A respondent-by-item matrix or data frame.

cultures

Number of factor dimensions to return. Additional dimensions are not automatically distinct cultural groups.

method

One of "formal", "informal", or "covariance".

prior

Prior proportion of true items for the covariance model.

return_answer_key

Whether to estimate a first-factor answer key.

n_answers

Optional number of possible responses for the formal model.

answer_levels

Optional vector specifying all categorical response options, including unobserved options. Not used for the informal model.

competence_policy

Policy for formal and covariance answer keys when first-factor loadings are outside [0,1]. "strict" (default) skips the key with a warning; "truncate" explicitly clips only answer-key weights. Reported competence and diagnostics always retain signed loadings.

Details

Analysis requires at least three respondents and two items. At least two unrotated minimum-residual factors are extracted for the first-to-second factor ratio, even when only the first is returned. Extraction failures are errors, not substitutions of another estimator. The legacy eigenvalues field contains factor sums of squared loadings; raw_eigenvalues contains eigenvalues of the input agreement matrix. These are different quantities. Warnings and residuals are retained in diagnostics; convergence is not certified by a large ratio. The ratio of three is a heuristic, not a statistical significance test. The mean-competence threshold is not applied to the informal model, whose loadings are not probabilities of knowing an answer.

Value

An object of class romney_consensus containing:

References

Romney, A. K., Weller, S. C., and Batchelder, W. H. (1986). Culture as consensus: A theory of culture and informant accuracy. American Anthropologist, 88(2), 313–338. doi:10.1525/aa.1986.88.2.02a00020. Romney, A. K., Batchelder, W. H., and Weller, S. C. (1987). Recent applications of cultural consensus theory. American Behavioral Scientist, 31(2), 163–177. doi:10.1177/000276487031002003. Weller, S. C. (2007). Cultural consensus theory: Applications and frequently asked questions. Field Methods, 19(4), 339–368. doi:10.1177/1525822X07303502.

Examples

x <- simulate_consensus_data(24, 60, n_answers = 4, competence = 0.6, seed = 7)
fit <- consensus(x$responses, answer_levels = 1:4)
fit$mean_competence
head(fit$answer_key$key)


Simulate formal consensus data

Description

Simulate formal consensus data

Usage

simulate_consensus_data(
  n_respondents,
  n_questions,
  n_answers = 2,
  competence = 0.7,
  seed = NULL
)

Arguments

n_respondents

Number of respondents.

n_questions

Number of questions/items.

n_answers

Number of possible answers per item.

competence

Scalar or vector of respondent competences.

seed

Optional non-negative integer seed. With a seed, the caller's random-number state is restored on exit.

Details

Respondent i knows an answer with probability c_i. Otherwise the respondent guesses uniformly among all m options, including the correct one. Thus the probability of a correct response is c_i + (1-c_i)/m, not c_i. Responses are conditionally independent given the answer key and competences. All items have the same choices and there is no response bias or missingness.

Value

A list with responses, key, and competence.

References

Romney, A. K., Weller, S. C., and Batchelder, W. H. (1986). Culture as consensus: A theory of culture and informant accuracy. American Anthropologist, 88(2), 313–338. doi:10.1525/aa.1986.88.2.02a00020.

Examples

simulated <- simulate_consensus_data(12, 30, n_answers = 4, seed = 42)
dim(simulated$responses)