SentimentDictionaryWeighted: Create a sentiment dictionary of words linked to a score

Description Usage Arguments Value Note Source References See Also Examples

Description

This routine creates a new object of type SentimentDictionaryWeighted that contains a number of words, each linked to a continuous score (i.e. weight) for specifying its polarity. The scores can later be interpreted as a linear model

Usage

1
2
3
4
5
6
SentimentDictionaryWeighted(
  words,
  scores,
  idf = rep(1, length(words)),
  intercept = 0
)

Arguments

words

is collection (vector) of different words as strings

scores

are the corresponding scores or weights denoting the word's polarity

idf

provide further details on the frequency of words in the corpus as an additional source for normalization

intercept

is an optional parameter for shifting the zero level (default: 0)

Value

Returns a new object of type SentimentDictionaryWordlist

Note

The intercept is useful when the mean or median of a response variable is not exactly located at zero. For instance, stock market returns have slight positive bias.

Source

doi: 10.1371/journal.pone.0209323

References

Pr\"ollochs and Feuerriegel (2018). Statistical inferences for Polarity Identification in Natural Language, PloS One 13(12).

See Also

SentimentDictionary

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# generate dictionary (based on linear model)
d <- SentimentDictionaryWeighted(c("increase", "decrease", "exit"),
                                 c(+1, -1, -10),
                                 rep(NA, 3))
summary(d)
# alternative call
d <- SentimentDictionaryWeighted(c("increase", "decrease", "exit"),
                                 c(+1, -1, -10))
summary(d)
# alternative call
d <- SentimentDictionary(c("increase", "decrease", "exit"),
                         c(+1, -1, -10),
                         rep(NA, 3))
summary(d)                                

Example output

Attaching package: 'SentimentAnalysis'

The following object is masked from 'package:base':

    write

Dictionary type:  weighted (words with individual scores)
Total entries:    3
Positive entries: 1 (33.33%)
Negative entries: 2 (66.67%)
Neutral entries:  0 (0%)

Details
Average score:      -3.333333
Median:             -1
Min:                -10
Max:                1
Standard deviation: 5.859465
Skewness:           -0.6155602
Dictionary type:  weighted (words with individual scores)
Total entries:    3
Positive entries: 1 (33.33%)
Negative entries: 2 (66.67%)
Neutral entries:  0 (0%)

Details
Average score:      -3.333333
Median:             -1
Min:                -10
Max:                1
Standard deviation: 5.859465
Skewness:           -0.6155602
Dictionary type:  weighted (words with individual scores)
Total entries:    3
Positive entries: 1 (33.33%)
Negative entries: 2 (66.67%)
Neutral entries:  0 (0%)

Details
Average score:      -3.333333
Median:             -1
Min:                -10
Max:                1
Standard deviation: 5.859465
Skewness:           -0.6155602

SentimentAnalysis documentation built on Feb. 18, 2021, 1:08 a.m.