Learn R Programming

stm (version 1.3.8)

Estimation of the Structural Topic Model

Description

The Structural Topic Model (STM) allows researchers to estimate topic models with document-level covariates. The package also includes tools for model selection, visualization, and estimation of topic-covariate regressions. Methods developed in Roberts et. al. (2014) and Roberts et. al. (2016) . Vignette is Roberts et. al. (2019) .

Copy Link

Version

Install

install.packages('stm')

Monthly Downloads

3,851

Version

1.3.8

License

MIT + file LICENSE

Maintainer

Brandon Stewart

Last Published

September 3rd, 2025

Functions in stm (1.3.8)

exclusivity

Exclusivity
make.heldout

Heldout Likelihood by Document Completion
findTopic

Find topics that contain user specified words.
findThoughts

Find Thoughts
fitNewDocuments

Fit New Documents
labelTopics

Label topics
make.dt

Make a data.table of topic proportions.
gadarian

Gadarian and Albertson data
makeDesignMatrix

Make a Design Matrix
js.estimate

A James-Stein Estimator Shrinking to a Uniform Distribution
permutationTest

Permutation test of a binary covariate.
plot.topicCorr

Plot a topic correlation graph
plot.STM

Functions for plotting STM objects
manyTopics

Performs model selection across separate STM's that each assume different numbers of topics.
plot.estimateEffect

Plot effect of covariates on topics
plot.searchK

Plots diagnostic values resulting from searchK
plot.MultimodDiagnostic

Plotting Method for Multimodality Diagnostic Objects
multiSTM

Analyze Stability of Local STM Mode
optimizeDocument

Optimize Document
plot.STMpermute

Plot an STM permutation test.
rmvnorm

Draw from a Multivariate Normal
plotRemoved

Plot documents, words and tokens removed at various word thresholds
readCorpus

Read in a corpus file.
plotQuote

Plots strings
s

Make a B-spline Basis Function
plotModels

Plots semantic coherence and exclusivity for high likelihood models outputted from selectModel.
poliblog5k

CMU 2008 Political Blog Corpus
readLdac

Read in a .ldac Formatted File
plotTopicLoess

Plot some effects with loess
prepDocuments

Prepare documents for analysis with stm
selectModel

Assists the user in selecting the best STM model.
sageLabels

Displays verbose labels that describe topics and topic-covariate groups in depth.
stm-package

Structural Topic Model
searchK

Computes diagnostic values for models with different values of K (number of topics).
thetaPosterior

Draw from Theta Posterior
semanticCoherence

Semantic Coherence
summary.STM

Summary Function for the STM objects
summary.estimateEffect

Summary for estimateEffect
writeLdac

Write a .ldac file
topicQuality

Plots semantic coherence and exclusivity for each topic.
topicCorr

Estimate topic correlation
textProcessor

Process a vector of raw texts
stm

Variational EM for the Structural Topic Model
unpack.glmnet

Unpack a glmnet object
toLDAvis

Wrapper to launch LDAvis topic browser.
topicLasso

Plot predictions using topics
toLDAvisJson

Wrapper to create Json mapping for LDAvis. This can be useful in indirect render e.g. Shiny Dashboards
checkBeta

Looks for words that load exclusively onto a topic
calcscore

Calculate Score Words
asSTMCorpus

STM Corpus Coercion
checkResiduals

Residual dispersion test for topic number
convertCorpus

Convert stm formatted documents to another format
estimateEffect

Estimates regressions using an STM object
alignCorpus

Align the vocabulary of a new corpus to an old corpus
cloud

Plot a wordcloud
calclift

Calculate Lift Words
calcfrex

Calculate FREX (FRequency and EXclusivity) Words