fitGWP: Fit a Generalized Word Power model.

Description Usage Arguments Value Examples

View source: R/fitGWP.R

Description

Fit a Generalized Word Power model on a target variable using word frequency data with an elastic-net model.

Usage

1
2
fitGWP(frequencies, responseData, alpha = c(0, 0.2, 0.4, 0.6, 0.8, 1),
  lowerLimit = 0.2)

Arguments

frequencies

frequencies data.table generated using the function computeFrequencies.

responseData

data.frame with column regID and y. regID should match with the regID of the frequencies input while y is the response variable.

alpha

alpha parameter for an elastic-net model.

lowerLimit

lower limit on the number of time a sentiment word must appear over all the period. If the value is above or equal to 1, this value is absolute. If the value is below 1, this value is in percentage term.

Value

A list with the following elements:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Load example data
data("corpus",  package = "GWP")
data("vix",  package = "GWP")
# Setup the lexicons
sentimentWord <- sentometrics::list_lexicons$LM_en$x
shifterWord <- sentometrics::list_valence_shifters$en[, c("x", "y")]

# Generate the frequency data
frequencies <- computeFrequencies(corpus, sentimentWord, shifterWord, clusterSize = 5)

# Calibrate the lexicon
res = fitGWP(frequencies = frequencies, responseData = vix)

keblu/GWP documentation built on June 15, 2020, 11:43 p.m.