proportion_topics {sentopics} | R Documentation |
Compute the topic or sentiment proportion time series
Description
Aggregate the topical or sentiment proportions at the document level into time series.
Usage
proportion_topics(
x,
period = c("year", "quarter", "month", "day", "identity"),
rolling_window = 1,
complete = TRUE,
plot = c(FALSE, TRUE, "silent"),
plot_ridgelines = TRUE,
as.xts = TRUE,
...
)
plot_proportion_topics(
x,
period = c("year", "quarter", "month", "day"),
rolling_window = 1,
complete = TRUE,
plot_ridgelines = TRUE,
...
)
Arguments
x |
a |
period |
the sampling period within which the sentiment of documents
will be averaged. |
rolling_window |
if greater than 1, determines the rolling window to compute a moving average of sentiment. The rolling window is based on the period unit and rely on actual dates (i.e, is not affected by unequally spaced data points). |
complete |
if FALSE, only compute proportions at the upper level of the topic model hierarchy (topics for rJST and sentiment for JST). No effect on LDA models. |
plot |
if |
plot_ridgelines |
if |
as.xts |
if |
... |
other arguments passed on to |
Value
A time series of proportions, stored as an xts::xts object or as a data.frame.
See Also
sentopics_sentiment sentopics_date
Other series functions:
sentiment_breakdown()
,
sentiment_series()
,
sentiment_topics()
Examples
lda <- LDA(ECB_press_conferences_tokens)
lda <- fit(lda, 100)
proportion_topics(lda)
# plot shortcut
plot_proportion_topics(lda, period = "month", rolling_window = 3)
# with or without ridgelines
plot_proportion_topics(lda, period = "month", plot_ridgelines = FALSE)
# also available for rJST and JST models
jst <- JST(ECB_press_conferences_tokens, lexicon = LoughranMcDonald)
jst <- fit(jst, 100)
# including both layers
proportion_topics(jst)
# or not
proportion_topics(jst, complete = FALSE)