Learn R Programming

quanteda (version 0.9.2-0)

textmodel_wordscores: Wordscores text model

Description

textmodel_wordscores implements Laver, Benoit and Garry's (2003) wordscores method for scaling of a single dimension. This can be called directly, but the recommended method is through textmodel.

Usage

textmodel_wordscores(data, scores, scale = c("linear", "logit"), smooth = 0)

## S3 method for class 'textmodel_wordscores_fitted': predict(object, newdata = NULL, rescaling = "none", level = 0.95, verbose = TRUE, ...)

## S3 method for class 'textmodel_wordscores_fitted': print(x, n = 30L, digits = 2, ...)

## S3 method for class 'textmodel_wordscores_fitted': show(object)

## S3 method for class 'textmodel_wordscores_predicted': show(object)

## S3 method for class 'textmodel_wordscores_predicted': print(x, ...)

Arguments

data
the dfm on which the model will be fit. Does not need to contain only the training documents, since the index of these will be matched automatically.
scores
vector of training scores associated with each document identified in refData
scale
classic LBG linear posterior weighted word class differences, or logit scale of log posterior differences
smooth
a smoothing parameter for word counts; defaults to zero for the to match the LBG (2003) method.
object
the fitted wordscores textmodel on which prediction will be made
newdata
dfm on which prediction should be made
rescaling
none for "raw" scores; lbg for LBG (2003) rescaling; or mv for the rescaling proposed by Martin and Vanberg (2007). (Note to authors: Provide full details here in documentation.)
level
probability level for confidence interval width
verbose
If TRUE, output status messages
...
additional arguments passed to other functions
x
for print method, the object to be printed
n
max rows of dfm to print
digits
number of decimal places to print for print methods

Value

  • The predict method for a wordscores fitted object returns a data.frame whose rows are the documents fitted and whose columns contain the scored textvalues, with the number of columns depending on the options called (for instance, how many rescaled scores, and whether standard errors were requested.) (Note: We may very well change this soon so that it is a list similar to other existing fitted objects.)

Details

Fitting a textmodel_wordscores results in an object of class textmodel_wordscores_fitted containing the following slots:

References

Laver, Michael, Kenneth R Benoit, and John Garry. 2003. "Extracting Policy Positions From Political Texts Using Words as Data." American Political Science Review 97(02): 311-31

Beauchamp, N. 2012. "Using Text to Scale Legislatures with Uninformative Voting." New York University Mimeo.

Martin, L W, and G Vanberg. 2007. "A Robust Transformation Procedure for Interpreting Political Text." Political Analysis 16(1): 93-100.

Laver, Michael, Kenneth R Benoit, and John Garry. 2003. "Extracting Policy Positions From Political Texts Using Words as Data." American Political Science Review 97(02): 311-31.

Martin, L W, and G Vanberg. 2007. "A Robust Transformation Procedure for Interpreting Political Text." Political Analysis 16(1): 93-100.

Examples

Run this code
(ws <- textmodel(LBGexample, c(seq(-1.5, 1.5, .75), NA), model="wordscores"))
predict(ws)
predict(ws, rescaling="mv")
predict(ws, rescaling="lbg")

# same as:
(ws2 <- textmodel_wordscores(LBGexample, c(seq(-1.5, 1.5, .75), NA)))
predict(ws2)

Run the code above in your browser using DataLab