labelTopics: Label topics

Description Usage Arguments Details Value See Also Examples


Generate a set of words describing each topic from a fitted STM object. Uses a variety of labeling algorithms (see details).


labelTopics(model, topics = NULL, n = 7, frexweight = 0.5)



An STM model object.


A vector of numbers indicating the topics to include. Default is all topics.


The desired number of words (per type) used to label each topic. Must be 1 or greater.


A weight used in our approximate FREX scoring algorithm (see details).


Four different types of word weightings are printed with label topics.

Highest Prob: are the words within each topic with the highest probability (inferred directly from topic-word distribution parameter β).

FREX: are the words that are both frequent and exclusive, identifying words that distinguish topics. This is calculated by taking the harmonic mean of rank by probability within the topic (frequency) and rank by distribution of topic given word p(z|w=v) (exclusivity). In estimating exclusivity we use a James-Stein type shrinkage estimator of the distribution p(z|w=v). More information can be found in the documentation for the internal function calcfrex and js.estimate.

Score and Lift are measures provided in two other popular text mining packages. For more information on type Score, see the R package lda or the internal function calcscore. For more information on type Lift, see the R package maptpx or or the internal function calclift.


A labelTopics object (list)


matrix of highest probability words


matrix of highest ranking frex words


matrix of highest scoring words by lift


matrix of best words by score


a vector of topic numbers which correspond to the rows

See Also

stm plot.STM calcfrex js.estimate calcscore calclift



Example output

stm v1.3.0 (2017-09-08) successfully loaded. See ?stm for help.
Topic 1 Top Words:
 	 Highest Prob: immigr, illeg, legal, border, will, need, worri 
 	 FREX: border, mexico, mexican, need, concern, fine, make 
 	 Lift: cross, racism, happen, other, continu, concern, deport 
 	 Score: immigr, border, need, will, mexico, illeg, mexican 
Topic 2 Top Words:
 	 Highest Prob: job, illeg, tax, pay, american, take, care 
 	 FREX: cost, health, servic, welfar, increas, loss, school 
 	 Lift: violenc, expens, opportun, cost, healthcar, loss, increas 
 	 Score: job, welfar, crime, cost, tax, care, servic 
Topic 3 Top Words:
 	 Highest Prob: peopl, come, countri, think, get, english, mani 
 	 FREX: english, get, come, mani, back, becom, like 
 	 Lift: anyth, send, still, just, receiv, deserv, back 
 	 Score: think, peopl, come, get, english, countri, mani 

stm documentation built on Dec. 18, 2019, 1:47 a.m.