cloud {stm}R Documentation

Plot a wordcloud

Description

Use the wordcloud package to plot a wordcloud for a particular topic

Usage

cloud(
  stmobj,
  topic = NULL,
  type = c("model", "documents"),
  documents,
  thresh = 0.9,
  max.words = 100,
  ...
)

Arguments

stmobj

The STM model object to be used in making the word cloud.

topic

NULL to plot the marginal distribution of words in the corpus, or a single integer indicating the topic number.

type

Specifies how the wordcloud is constructed. The type "model" which is used by default is based on the probability of the word given the topic. The type "documents" plots words within documents that have a topic proportion of higher than thresh. This requires that the documents argument also be specified.

documents

The documents object of the same kind as passed to stm. This is only necessary if type="documents".

thresh

The threshold for including a document in the type="documents" setting.

max.words

The maximum number of words to be plotted.

...

Additional parameters passed to wordcloud.

Details

Uses the wordcloud package to make a word cloud of a particular topic. The option "model" uses the topic-word model parameters. Thus it shows words weighted by their probability conditional that the word comes from a particular topic. With content covariates it averages over the values for all levels of the content covariate weighted by the empirical frequency in the dataset. The option "documents" plots the words which appear in documents that have a topic proportion higher than thresh. Thus "model" gives a pure model based interpretation of the topic while "documents" gives a picture of all the words in documents which are highly associated with the topic.

References

Ian Fellows (2014). wordcloud: Word Clouds. R package version 2.5. https://cran.r-project.org/package=wordcloud

See Also

plot.STM

Examples

cloud(gadarianFit, 1)

[Package stm version 1.3.7 Index]