The share of each topic's word distribution that falls on
vocabulary terms matching a pattern
(\(\sum_{v \in S} \beta_{kv}\)), e.g. to find the topics about the
environment with "climat|green|environment". A sum rather than a mean:
a topic with many matching words scores higher than a topic with one.
Arguments
- model
A fitted
stmmodel (or a list withbeta$logbeta[[1]]andvocab).- regex
Regular expression (ICU, via stringi) matched against the vocabulary; several patterns are joined by
|. In the vocabulary built byextract_ngrams(), the words of an n-gram are joined by_("green_bond"). A space inregexis therefore replaced by_, with a warning.- n_terms
Integer scalar, number of matching terms listed per topic.
- ...
Not used: an argument renamed in the development version of mintR gives an error naming its replacement.
Value
A data.table with topic, mass and top_terms (the most
probable matching terms), by decreasing mass.
Examples
logbeta <- log(matrix(c(0.5, 0.3, 0.2, 0.1, 0.2, 0.7), nrow = 2, byrow = TRUE))
mdl <- list(beta = list(logbeta = list(logbeta)), vocab = c("green_bond", "labour", "climate"))
topic_word_mass(mdl, "green|climat")
#> topic mass top_terms
#> <int> <num> <char>
#> 1: 2 0.8 climate, green_bond
#> 2: 1 0.7 green_bond, climate
