Using a Dictionary-Based Approach to Calculate Hawkish-Dovish Scores

The dictionary-based approach to sentiment analysis is widely used due to its simplicity and transparency. This post explores how this approach can be applied to Fed communications to calculate hawkish-dovish scores, providing insights into the sentiment conveyed in these statements.

Xian Thu 29 August 2024

What is the Dictionary-Based Approach for Sentiment Analysis?

The dictionary-based approach is a straightforward method in sentiment analysis that relies on predefined lists of words, or "dictionaries," categorized by sentiment—positive, negative, or neutral. This method involves scanning the text and matching its words with those in the dictionary to calculate a sentiment score based on the frequency and type of matches.

Common Dictionaries Used in Sentiment Analysis

Several well-known sentiment dictionaries have been developed for different domains:

  • Loughran-McDonald Dictionary: Specifically designed for financial text analysis, this dictionary categorizes words according to their financial sentiment (e.g., "positive," "negative," "uncertainty," "litigious"). It is commonly used for analyzing corporate reports, earnings calls, and regulatory filings.
  • Harvard General Inquirer: A widely used dictionary that categorizes words into positive, negative, and other sentiment-related categories. Although applicable across various fields, it may lack domain-specific terminology.
  • AFINN and VADER: Popular in general sentiment analysis, particularly in social media. These dictionaries focus on broader sentiments such as happiness, anger, or sadness.

Custom Hawkish-Dovish Dictionaries for Monetary Policy Analysis

For analyzing central bank communications, sentiment dictionaries like Loughran-McDonald may fall short, as they do not specifically account for hawkish or dovish language—terms that are crucial in understanding monetary policy.

To address this, custom hawkish-dovish dictionaries are created, containing terms strongly associated with either a hawkish or dovish stance. Examples include:

  • Hawkish Terms: Words like "inflation", "consumer confidence", "economic growth".
  • Dovish Terms: Words like "unemployment", "job losses", "quantitative easing".

These custom dictionaries allow sentiment analysis to focus specifically on monetary policy stances, enabling more accurate interpretations of central bank communications.

How the Dictionary-Based Approach Works

The dictionary-based approach follows a straightforward process:

  1. Text Preprocessing: Before applying the dictionary, the text (e.g., a Fed speech or statement) undergoes cleaning and preprocessing. This involves removing stop words, lemmatization, and converting all words to lowercase to standardize the text.
import nltk
import re
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from nltk.stem import PorterStemmer

# Function to preprocess text by converting to lowercase, removing non-ASCII characters,
# tokenizing, removing stop words, and stemming.
def preprocess_text(text):
    text = text.lower()
    text = re.sub(r'[^\x00-\x7F]+', ' ', text)  # Remove non-ASCII characters
    words = word_tokenize(text)

    stop_words = set(stopwords.words('english'))
    words = [word for word in words if word not in stop_words]

    stemmer = PorterStemmer()
    words = [stemmer.stem(word) for word in words]

    return ' '.join(words)
  1. Word Matching: The next step involves scanning the text for words that match those in the dictionary. Each time a word from the text matches a word in the hawkish or dovish dictionary, it is counted. The four-quadrant method is used, following FOMC minutes sentiments and their impact on financial markets paper. Hawkish and dovish keywords are matched with polarity words.
Category Hawkish Terms Dovish Terms
Positive Words Hawkish Dovish
Negative Words Dovish Hawkish

For example, the sentence “Recent indicators suggest that economic activity expanded at a strong pace in the third quarter” will be labeled as a "Hawkish" sentence due to the positive connotation of "economic activity" and "strong." In contrast, “The declining of the growth of real GDP in the fourth quarter of 2005 seems largely to have reflected temporary or special factors” will be labeled as a "Dovish" sentence because it highlights a "declining" in "economic growth", indicating a more cautious or easing stance.

The complete dictionary list used for this analysis can be found in the appendix.

from collections import Counter

# Function to evaluate a sentence by matching words against given hawkish and dovish dictionaries.
# The function returns counts of hawkish and dovish terms found and a list of matched words.
def evaluate_sentence(sentence, hawkish_terms, positive_words, dovish_terms, negative_words):
    words = nltk.word_tokenize(sentence)
    bigrams = [" ".join(bigram) for bigram in nltk.bigrams(words)]

    unigram_counts = Counter(words)
    bigram_counts = Counter(bigrams)
    matched = []

    counts = {'hawkish': 0, 'dovish': 0}

    def match_scenario(word_list):
        return any(word in unigram_counts or word in bigram_counts for word in word_list)

    scenarios = [
        [dovish_terms, positive_words, 'hawkish'],
        [dovish_terms, negative_words, 'dovish'],
        [hawkish_terms, negative_words, 'hawkish'],
        [hawkish_terms, positive_words, 'dovish'],
    ]

    for scenario in scenarios:
        scenario_words = scenario[:-1]
        count_type = scenario[-1]
        if all(match_scenario(word_list) for word_list in scenario_words):
            counts[count_type] += 1
            for word_list in scenario_words:
                for word in word_list:
                    if word in unigram_counts or word in bigram_counts:
                        matched.append(word)

    return counts['hawkish'], counts['dovish'], matched

# Example usage:
# hawkish_count, dovish_count, matched_words = evaluate_sentence(sentence, hawkish_terms, positive_words, dovish_terms, negative_words)
  1. Scoring the Sentiment: The sentiment score is calculated by summing up the counts for hawkish and dovish terms. A scoring formula based on the proportion of hawkish and dovish terms in the text provides a quantitative measure of the sentiment in that communication.
# Function to calculate the hawkish-dovish score.
def hawkish_dovish_score(total_hawkish_count, total_dovish_count, total_sentences):
    return (total_hawkish_count - total_dovish_count) / total_sentences

# Example usage:
# score = hawkish_dovish_score(50, 30, 100)

For example, if a Fed statement contains more hawkish terms than dovish ones, the resulting score indicates a hawkish sentiment, suggesting a tilt toward tighter monetary policy. Conversely, if dovish terms dominate, the sentiment indicates a preference for easing.

Advantages of the Dictionary-Based Approach

  • Transparency: One of the biggest advantages is its interpretability. With predefined dictionaries, it is clear which words drive the sentiment score.
  • Efficiency: The approach is computationally efficient and can be implemented with basic NLP tools like Python’s nltk or pandas.
  • Customizability: As demonstrated with hawkish-dovish dictionaries, this method can be adapted to suit different domains, making it a flexible tool for sentiment analysis in specialized fields like finance.

Result

To cover most of the sentiment in statements, minutes, or speeches, a 3-month average of documents is used.

Appendix

Category Keywords
Hawkish Terms asset purchas, bank rate, busi, consum confid, credit market, demand, econom activ, econom condit, econom growth, economi, employ, energi price, equiti, financi stabil, fiscal polici, foreign market, fund rate, GDP, geopolit risk, global economi, growth, hous, hous price, incom, inflat, inflat expect, interest rate, intern trade, invest, investor sentiment, job gain, job market, labor, liquid, manufactur, market condit, market perform, monetari polici, outlook, output, product, rate polici, spend, stock market, wage
Dovish Terms balance sheet, deficit, delinquency rates, dollar, holdings, job losses, monetary easing, quantitative easing, unemployment, unemployment rate
Positive Words abat, acceler, add, advanc, anticip, appreci, augment, balanc, better, bolster, boom, boost, bullish, continu, eas, elev, expand, expansionari, expect, extend, fast, faster, firmer, forecast, gain, grow, heighten, high, higher, hike, improv, increas, initi, inject, more, optimist, provid, rais, rapid, rebound, recov, restrict, rise, risen, robust, rose, signific, solid, sooner, spike, stabl, strength, strengthen, strong, stronger, support, up, upsid, upsw, uptick, upward
Negative Words accommod, advers, anchor, back, bearish, below, cautionari, cautiou, constrain, conting, contract, cool, correct, cut, damp, dampen, deceler, declin, decreas, deepen, depreci, depress, deterior, diminish, disappoint, disloc, disrupt, down, downbeat, downsid, downward, drop, eb, end, eros, fade, fall, fallen, fell, insuffici, less, limit, low, lower, moder, non-acceler, paus, pessimist, reduc, reduct, reluct, remov, restrain, restraint, resumpt, revers, risk, shrink, slack, slow, slower, slowli, sluggish, slump, soft, soften, stabl, stimul, strain, stress, subdu, taper, tighten, tragic, turmoil, uncertain, underutil, volatil, vulner, wari, weak, weaken, weaker, withdraw



Related posts: