Fit weighted LDA models.

weightedLDA(
  docs,
  model,
  number_of_topics,
  model_settings = list(),
  priors = list(),
  options = list(),
  keep = c()
)

Arguments

docs

texts read via keyATM_read().

model

Weighted LDA model: base, covariates, and dynamic.

number_of_topics

the number of regular topics.

model_settings

a list of model specific settings (details are in the online documentation).

priors

a list of priors of parameters.

options

a list of options (details are in the documentation of keyATM()).

keep

a vector of the names of elements you want to keep in output.

Value

A keyATM_output object containing:

V

number of terms (number of unique words)

N

number of documents

model

the name of the model

theta

topic proportions for each document (document-topic distribution)

phi

topic specific word generation probabilities (topic-word distribution)

topic_counts

number of tokens assigned to each topic

word_counts

number of times each word type appears

doc_lens

length of each document in tokens

vocab

words in the vocabulary (a vector of unique words)

priors

priors

options

options

keywords_raw

NULL for LDA models

model_fit

perplexity and log-likelihood

pi

estimated pi for the last iteration (NULL for LDA models)

values_iter

values stored during iterations

number_of_topics

number of topics

kept_values

outputs you specified to store in keep option

information

information about the fitting

Examples

if (FALSE) {
  library(keyATM)
  library(quanteda)
  data(keyATM_data_bills)
  bills_dfm <- keyATM_data_bills$doc_dfm  # quanteda dfm object
  keyATM_docs <- keyATM_read(bills_dfm)

  # Weighted LDA
  out <- weightedLDA(docs = keyATM_docs, model = "base",
                     number_of_topics = 5)

  # Visit our website for full examples: https://keyatm.github.io/keyATM/
}