R: Draw from the posterior of an LDA topic model

posterior.lda_topic_model {textmineR} | R Documentation

## Draw from the posterior of an LDA topic model

### 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

    ## 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

    ## 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)

[Package textmineR version 3.0.5 Index]