Skip to contents

Prediction method for textmodel_lss

Usage

# S3 method for textmodel_lss
predict(
  object,
  newdata = NULL,
  se_fit = FALSE,
  density = FALSE,
  rescale = TRUE,
  cut = NULL,
  min_n = 0L,
  ...
)

Arguments

object

a fitted LSS textmodel.

newdata

a dfm on which prediction should be made.

se_fit

if TRUE, returns standard error of document scores.

density

if TRUE, returns frequency of polarity words in documents.

rescale

if TRUE, normalizes polarity scores using scale().

cut

a vector of one or two percentile values to dichotomized polarty scores of words. When two values are given, words between them receive zero polarity.

min_n

set the minimum number of polarity words in documents.

...

not used

Details

Polarity scores of documents are the means of polarity scores of words weighted by their frequency. When se_fit = TRUE, this function returns the weighted means, their standard errors, and the number of polarity words in the documents. When rescale = TRUE, it converts the raw polarity scores to z sores for easier interpretation. When rescale = FALSE and cut is used, polarity scores of documents are bounded by [-1.0, 1.0].

Documents tend to receive extreme polarity scores when they have only few polarity words. This is problematic when LSS is applied to short documents (e.g. social media posts) or individual sentences, but users can alleviate this problem by adding zero polarity words to short documents using min_n. This setting does not affect empty documents.