Learn R Programming

keyATM (version 0.5.4)

Keyword Assisted Topic Models

Description

Fits keyword assisted topic models (keyATM) using collapsed Gibbs samplers. The keyATM combines the latent dirichlet allocation (LDA) models with a small number of keywords selected by researchers in order to improve the interpretability and topic classification of the LDA. The keyATM can also incorporate covariates and directly model time trends. The keyATM is proposed in Eshima, Imai, and Sasaki (2024) .

Copy Link

Version

Install

install.packages('keyATM')

Monthly Downloads

543

Version

0.5.4

License

GPL-3

Maintainer

Shusei Eshima

Last Published

July 21st, 2025

Functions in keyATM (0.5.4)

keyATM_fit_LDAHMM

Run the Collapsed Gibbs sampler for the weighted LDA with HMM model
read_keywords

Convert a quanteda dictionary to keywords
keyATM_read

Read texts
read_dfm_cpp

Read files from the quanteda dfm (this is the same as dgCMatrix)
weightedLDA

Weighted LDA main function
predict.keyATM_output

Predict topic proportions for the covariate keyATM
multiPGreg

Run multinomial regression with Polya-Gamma augmentation
plot.strata_doctopic

Plot document-topic distribution by strata (for covariate models)
keyATM_output

Create an output object
make_wsz_cpp

Initialize assignments
keyATM_fit_LDAcov

Run the Collapsed Gibbs sampler for weighted LDA with covariates
word_in_doc

Checking if a word is in a document
values_fig

Get values used to create a figure
plot_timetrend

Plot time trend
keyATMvb_fit

Fit a keyATM model with Collapsed Variational Bayes
top_topics

Show the top topics for each document
plot_pi

Show a diagnosis plot of pi
top_words

Show the top words for each topic
visualize_keywords

Visualize keywords
plot_modelfit

Show a diagnosis plot of log-likelihood and perplexity
semantic_coherence

Semantic Coherence: Mimno et al. (2011)
top_docs

Show the top documents for each topic
refine_keywords

Refine keywords
save_fig

Save a figure
keyATM_fit_HMM

Run the Collapsed Gibbs sampler for the keyATM Dynamic
calc_PGtheta_R

Calculate the probability for Polya-Gamma Covariate Model
covariates_get

Return covariates used in the iteration
by_strata_TopicWord

Estimate subsetted topic-word distribution
covariates_info

Show covariates information
by_strata_DocTopic

Estimate document-topic distribution by strata (for covariate models)
keyATM-package

Keyword Assisted Topic Models
keyATM

keyATM main function
keyATMvb

keyATM with Collapsed Variational Bayes
keyATM_data_bills

Bills data
keyATMvb_call

Run the Variational Bayes for the keyATM models
keyATM_fit_base

Run the Collapsed Gibbs sampler for the keyATM Base
plot_topicprop

Show the expected proportion of the corpus belonging to each topic
keyATM_fit_LDA

Run the Collapsed Gibbs sampler for weighted LDA
keyATM_initialize

Initialize a keyATM model
plot_alpha

Show a diagnosis plot of alpha
keyATM_fit_covPG

Run the Collapsed Gibbs sampler for the keyATM covariates (Polya-Gamma)
keyATM_fit_cov

Run the Collapsed Gibbs sampler for the keyATM covariates (Dir-Multi)