textmodel_wordscores implements Laver, Benoit and Garry's (2003) wordscores method for scaling of a single dimension.

textmodel_wordscores(x, y, scale = c("linear", "logit"), smooth = 0)

Arguments

x

the dfm on which the model will be trained

y

vector of training scores associated with each document in x

scale

scale on which to score the words; "linear" for classic LBG linear posterior weighted word class differences, or "logit" for log posterior differences

smooth

a smoothing parameter for word counts; defaults to zero for the to match the LBG (2003) method.

Details

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

Slots

scale

linear or logit, according to the value of scale

Sw

the scores computed for each word in the training set

x

the dfm on which the wordscores model was called

y

the reference scores

call

the function call that fitted the model

method

takes a value of wordscores for this model

Predict Methods

A predict method is also available for a fitted wordscores object, see predict.textmodel_wordscores_fitted.

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.

See also

predict.textmodel_wordscores_fitted

Examples

(ws <- textmodel_wordscores(data_dfm_lbgexample, c(seq(-1.5, 1.5, .75), NA)))
#> Fitted wordscores model: #> Call: #> textmodel_wordscores.dfm(x = data_dfm_lbgexample, y = c(seq(-1.5, #> 1.5, 0.75), NA)) #> #> Reference documents and reference scores: #> #> Documents Ref scores #> R1 -1.50 #> R2 -0.75 #> R3 0.00 #> R4 0.75 #> R5 1.50 #> V1 . #> #> Word scores: showing first 30 scored features #> #> A B C D E F G H I J K L M #> -1.50 -1.50 -1.50 -1.50 -1.50 -1.48 -1.48 -1.45 -1.41 -1.32 -1.18 -1.04 -0.88 #> N O P Q R S T U V W X Y Z #> -0.75 -0.62 -0.45 -0.30 -0.13 0.00 0.13 0.30 0.45 0.62 0.75 0.88 1.04 #> ZA ZB ZC ZD #> 1.18 1.32 1.41 1.45
predict(ws)
#> Predicted textmodel of type: wordscores #> #> textscore LBG se ci lo ci hi #> R1 -1.3179 0.0067 -1.3311 -1.3048 #> R2 -0.7396 0.0114 -0.7620 -0.7172 #> R3 0.0000 0.0120 -0.0235 0.0235 #> R4 0.7396 0.0114 0.7172 0.7620 #> R5 1.3179 0.0067 1.3048 1.3311 #> V1 -0.4481 0.0119 -0.4714 -0.4247 #>
predict(ws, rescaling = "mv")
#> Warning: #> More than two reference scores found with MV rescaling; using only min, max values.
#> Predicted textmodel of type: wordscores #> #> textscore LBG se ci lo ci hi MV rescaled textscore_mv_lo textscore_mv_hi #> R1 -1.3179 0.0067 -1.3311 -1.3048 -1.5000 -1.5149 -1.4851 #> R2 -0.7396 0.0114 -0.7620 -0.7172 -0.8417 -0.8672 -0.8162 #> R3 0.0000 0.0120 -0.0235 0.0235 0.0000 -0.0268 0.0268 #> R4 0.7396 0.0114 0.7172 0.7620 0.8417 0.8162 0.8672 #> R5 1.3179 0.0067 1.3048 1.3311 1.5000 1.4851 1.5149 #> V1 -0.4481 0.0119 -0.4714 -0.4247 -0.5100 -0.5365 -0.4834 #>
predict(ws, rescaling = "lbg")
#> Predicted textmodel of type: wordscores #> #> textscore LBG se ci lo ci hi LBG rescaled LBG lo LBG hi #> R1 -1.3179 0.0067 -1.3311 -1.3048 -1.5897 -1.6057 -1.5737 #> R2 -0.7396 0.0114 -0.7620 -0.7172 -0.8849 -0.9122 -0.8576 #> R3 0.0000 0.0120 -0.0235 0.0235 0.0163 -0.0124 0.0450 #> R4 0.7396 0.0114 0.7172 0.7620 0.9175 0.8902 0.9448 #> R5 1.3179 0.0067 1.3048 1.3311 1.6223 1.6063 1.6383 #> V1 -0.4481 0.0119 -0.4714 -0.4247 -0.5297 -0.5581 -0.5013 #>