mergeTopics {sentopics} | R Documentation |
Merge topics into fewer themes
Description
This operation is especially useful for the analysis of the model's output, by grouping together topics that share a common theme.
Usage
mergeTopics(x, merging_list)
Arguments
x |
|
merging_list |
a list where each element is an integer vector containing the indices of topics to be merged. If named, the list's names become the label of the aggregated themes. |
Details
Topics are aggregated at the word assignment level. New document-topic and topic-word probabilities are derived from the aggregated assignments.
Note that the output of this function does not constitute an estimated
topic model, but merely an aggregation to ease the analysis. It is not
advised to use fit()
on the merged topic
model as it will radically affect the content and proportions of the new
themes.
Value
A LDA()
or rJST()
model with the merged topics.
See Also
sentopics_labels
Examples
lda <- LDA(ECB_press_conferences_tokens, K = 5)
lda <- fit(lda, 100)
merging_list <- list(
c(1,5),
2:4
)
mergeTopics(lda, merging_list)
# also possible with a named list
merging_list2 <- list(
mytheme_1 = c(1,5),
mytheme_2 = 2:4
)
merged <- mergeTopics(lda, merging_list2)
sentopics_labels(merged)
# implemented for rJST
rjst <- rJST(ECB_press_conferences_tokens, lexicon = LoughranMcDonald)
rjst <- fit(rjst, 100)
mergeTopics(rjst, merging_list2)