posterior.lda_topic_model: Draw from the posterior of an LDA topic model

Description Usage Arguments Value References Examples

View source: R/topic_modeling_core.R

Description

This function takes an object of class lda_topic_model and draws samples from the posterior of either phi or theta. This is useful for quantifying uncertainty around parametersof the final model.

Usage

1
2
## S3 method for class 'lda_topic_model'
posterior(object, which = "theta", num_samples = 100, ...)

Arguments

object

An object of class lda_topic_model

which

A character of either 'theta' or 'phi', indicating from which matrix to draw posterior samples

num_samples

Integer number of samples to draw

...

Other arguments to be passed to TmParallelApply.

Value

Returns a data frame where each row is a single sample from the posterior. Each column is the distribution over a single parameter. The variable var is a facet for subsetting by document (for theta) or topic (for phi).

References

Heinrich, G. (2005) Parameter estimation for text analysis. Technical report. http://www.arbylon.net/publications/text-est.pdf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
a <- posterior(object = nih_sample_topic_model, which = "theta", num_samples = 20)

plot(density(a$t1[a$var == "8693991"]))

b <- posterior(object = nih_sample_topic_model, which = "phi", num_samples = 20)

plot(denisty(b$research[b$var == "t_5"]))

## End(Not run)

textmineR documentation built on June 28, 2021, 9:08 a.m.