FitCtmModel: Fit a Correlated Topic Model

Description Usage Arguments Value Examples

Description

A wrapper for the CTM function based on Blei's original code that returns a nicely-formatted topic model.

Usage

1
FitCtmModel(dtm, k, return_all = TRUE, ...)

Arguments

dtm

A document term matrix of class dgCMatrix

k

Number of topics

return_all

Logical. Do you want the raw results of the underlying function returned along with the formatted results? Defaults to TRUE.

...

Other arguments to pass to CTM.

Value

Returns a list with a minumum of two objects, phi and theta. The rows of phi index topics and the columns index tokens. The rows of theta index documents and the columns index topics.

Examples

1
2
3
4
5
6
# Load a pre-formatted dtm 
data(nih_sample_dtm) 

# Fit a CTM model on a sample of documents
model <- FitCtmModel(dtm = nih_sample_dtm[ sample(1:nrow(nih_sample_dtm) , 10) , ], 
                     k = 3, return_all = FALSE)

ChengMengli/topic documentation built on May 31, 2019, 8:44 p.m.