sentiment_breakdown {sentopics} | R Documentation |
Breakdown the sentiment into topical components
Description
Break down the sentiment series obtained with
sentiment_series()
into topical components. Sentiment is broken down at
the document level using estimated topic proportions, then processed to
create a time series and its components.
Usage
sentiment_breakdown(
x,
period = c("year", "quarter", "month", "day", "identity"),
rolling_window = 1,
scale = TRUE,
scaling_period = c("1900-01-01", "2099-12-31"),
plot = c(FALSE, TRUE, "silent"),
as.xts = TRUE,
...
)
plot_sentiment_breakdown(
x,
period = c("year", "quarter", "month", "day"),
rolling_window = 1,
scale = TRUE,
scaling_period = c("1900-01-01", "2099-12-31"),
...
)
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). |
scale |
if |
scaling_period |
the date range over which the scaling should be applied. Particularly useful to normalize only the beginning of the time series. |
plot |
if |
as.xts |
if |
... |
other arguments passed on to |
Details
The sentiment is broken down at the sentiment level assuming the following composition:
, where
is the sentiment of topic i and
the proportion of
topic i in a given document. For an LDA model, the sentiment of each topic
is considered equal to the document sentiment (i.e.
). The topical sentiment attention, defined by
represent the effective sentiment conveyed by a topic in a
document. The topical sentiment attention of all documents in a period are
averaged to compute the breakdown of the sentiment time series.
Value
A time series of sentiment, stored as an xts::xts object or as a data.frame.
See Also
sentopics_sentiment sentopics_date
Other series functions:
proportion_topics()
,
sentiment_series()
,
sentiment_topics()
Examples
lda <- LDA(ECB_press_conferences_tokens)
lda <- fit(lda, 100)
sentiment_breakdown(lda)
# plot shortcut
plot_sentiment_breakdown(lda)
# also available for rJST models (with topic-level sentiment)
rjst <- rJST(ECB_press_conferences_tokens, lexicon = LoughranMcDonald)
rjst <- fit(rjst, 100)
sentopics_sentiment(rjst, override = TRUE)
plot_sentiment_breakdown(rjst)