Learn R Programming

sentometrics: An Integrated Framework for Textual Sentiment Time Series Aggregation and Prediction

Introduction

The sentometrics package is an integrated framework for textual sentiment time series aggregation and prediction. It accounts for the intrinsic challenge that textual sentiment can be computed in many different ways, as well as the large number of possibilities to pool sentiment into a time series index. The package integrates the fast quantification of sentiment from texts, the aggregation into different sentiment time series, and the prediction based on these measures. All in one coherent workflow!

See the package website and the vignette published in the Journal of Statistical Software for plenty of examples and details. We also refer to our survey organized as an overview of the required steps in a typical econometric analysis of sentiment from alternative (such as textual) data, and following companion web page.

Installation

To install the package from CRAN, simply do:

install.packages("sentometrics")

To install the latest development version of sentometrics (which may contain bugs!), execute:

devtools::install_github("SentometricsResearch/sentometrics")

Shiny application

For a visual interface as a Shiny application of the package's core functionalities, install the sentometrics.app package, and run the sento_app() function.

Reference

Please cite sentometrics in publications. Use citation("sentometrics").

Acknowledgements

This software package originates from a Google Summer of Code 2017 project, was further developed during a follow-up Google Summer of Code 2019 project, and benefited generally from financial support by Innoviris, IVADO, swissuniversities, and the Swiss National Science Foundation (grants #179281 and #191730).

Copy Link

Version

Install

install.packages('sentometrics')

Monthly Downloads

453

Version

1.0.1

License

GPL (>= 2)

Maintainer

Samuel Borms

Last Published

April 3rd, 2025

Functions in sentometrics (1.0.1)

get_dates

Get the dates of the sentiment measures/time series
list_lexicons

Built-in lexicons
list_valence_shifters

Built-in valence word lists
diff.sento_measures

Differencing of sentiment measures
ctr_model

Set up control for sentiment-based sparse regression modeling
get_dimensions

Get the dimensions of the sentiment measures
get_loss_data

Retrieve loss data from a selection of models
get_hows

Options supported to perform aggregation into sentiment measures
epu

Monthly U.S. Economic Policy Uncertainty index
data-defunct

Datasets with defunct names
plot.sento_modelIter

Plot iterative predictions versus realized values
merge.sentiment

Merge sentiment objects horizontally and/or vertically
measures_update

Update sentiment measures
peakdates

Extract dates related to sentiment time series peaks
plot.attributions

Plot prediction attributions at specified level
peakdocs

Extract documents related to sentiment peaks
nobs.sento_measures

Get number of observations in the sentiment measures
measures_fill

Add and fill missing dates to sentiment measures
plot.sento_measures

Plot sentiment measures
nmeasures

Get number of sentiment measures
sentometrics-deprecated

Deprecated functions
sento_lexicons

Set up lexicons (and valence word list) for use in sentiment analysis
sento_corpus

Create a sento_corpus object
sento_model

Optimized and automated sentiment-based sparse regression
sentometrics-package

sentometrics: An Integrated Framework for Textual Sentiment Time Series Aggregation and Prediction
sento_measures

One-way road towards a sento_measures object
weights_almon

Compute Almon polynomials
usnews

Texts (not) relevant to the U.S. economy
sentometrics-defunct

Defunct functions
subset.sento_measures

Subset sentiment measures
predict.sento_model

Make predictions from a sento_model object
weights_beta

Compute Beta weighting curves
weights_exponential

Compute exponential weighting curves
scale.sento_measures

Scaling and centering of sentiment measures
aggregate.sentiment

Aggregate textual sentiment across sentences, documents and time
add_features

Add feature columns to a (sento_)corpus object
corpus_summarize

Summarize the sento_corpus object
as.sentiment

Convert a sentiment table to a sentiment object
attributions

Retrieve top-down model sentiment attributions
compute_sentiment

Compute textual sentiment across features and lexicons
as.data.table.sento_measures

Get the sentiment measures
ctr_agg

Set up control for aggregation into sentiment measures
aggregate.sento_measures

Aggregate sentiment measures
as.sento_corpus

Convert a quanteda or tm corpus object into a sento_corpus object