The goal of aaiNB is to make the training sets used in the paper "Investor distraction and multi-dimensional financial narrative" to buil the Naive Bayes classifiers available to the public.
Gietzmann, M., Grossetti, F. & Lewis, C.M. Investor distraction and multi-dimensional financial narrative. Rev Account Stud 31, 334–373 (2026). https://doi.org/10.1007/s11142-026-09950-7
You can install the development version of aaiNB from GitHub with:
remotes::install_github("contefranz/aaiNB")This is a basic example which shows you how to train a classifier and apply it over a toy sample of randomly selected MD&A sentences.
library(aaiNB)
# Train Naive Bayes optimism classifier
optimism = train_NB_attributes(
x = train_dfm_attributes,
y = train_dfm_attributes$optimism,
prior = "docfreq"
)
optimism
# Predict on some new sentences
data("item7_sent")
pred_nb_optimism = predict(optimism, newdata = item7_sent, force = TRUE)
head(nb_optimism)