Skip to contents

Build labels such as "3: labor, wages, unions" from the top words of each topic, with the same words as stm::labelTopics().

Usage

topic_labels(
  model,
  measure = c("prob", "frex", "lift", "score"),
  n_terms = 3L,
  sep = ", ",
  frexw = 0.5,
  ...
)

Arguments

model

A fitted stm model without a content covariate (for a content-covariate model, use marginal_topic_model() first).

measure

Measure used to pick the words: "prob", "frex", "lift" or "score" (see topic_terms()).

n_terms

Integer scalar, number of words per label.

sep

Character scalar placed between words.

frexw

Numeric scalar in [0, 1], FREX weight (as in stm::labelTopics()).

...

Not used: an argument renamed in the development version of mintR gives an error naming its replacement.

Value

A data.table with topic and label.

Details

Faster than stm::labelTopics(), which computes the four measures for every topic: only the measure asked for is computed, and only the n_terms best words are kept. The words are identical to labelTopics(), ties included (both keep the vocabulary order among ties). FREX is computed with stm's internal function because labelTopics() shrinks exclusivity towards the corpus word counts (James-Stein estimator), which topic_terms() does not; the FREX labels may thus differ from its FREX top terms.

Examples

if (FALSE) { # \dontrun{
labels <- topic_labels(fit, measure = "frex", n_terms = 4)
} # }