Learn R Programming

quanteda (version 0.7.2-1)

textmodel_wordfish: wordfish text model

Description

Estimate Slapin and Proksch's (2008) "wordfish" Poisson scaling model of one-dimensional document positions using conditional maximum likelihood.

Usage

textmodel_wordfish(data, dir = c(1, 2), priors = c(Inf, Inf, 3, 1),
  tol = c(1e-06, 1e-08))

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

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

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

Arguments

data
the dfm on which the model will be fit
dir
set global identification by specifying the indexes for a pair of documents such that $\hat{\theta}_{dir[1]} < \hat{\theta}_{dir[2]}$.
priors
priors for $\theta_i$, $\alpha_i$, $\psi_j$, and $\beta_j$ where $i$ indexes documents and $j$ indexes features
tol
tolerances for convergence (explain why a pair)
x
for print method, the object to be printed
n
max rows of dfm to print
...
additional arguments passed to other functions
object
wordfish fitted or predicted object to be shown

Value

  • An object of class textmodel_fitted_wordfish. This is a list containing:
  • dirglobal identification of the dimension
  • thetaestimated document positions
  • alphaestimated document fixed effects
  • betaestimated feature marginal effects
  • psiestimated word fixed effects
  • docsdocument labels
  • featuresfeature labels
  • sigmaregularization parameter for betas in Poisson form
  • lllog likelihood at convergence
  • se.thetastandard errors for theta-hats
  • datadfm to which the model was fit

Details

The returns match those of Will Lowe's R implementation of wordfish (see the austin package), except that here we have renamed words to be features. (This return list may change.) We have also followed the practice begun with Slapin and Proksch's early implementation of the model that used a regularization parameter of se$(\sigma) = 3$, through the third element in priors.

References

Jonathan Slapin and Sven-Oliver Proksch. 2008. "A Scaling Model for Estimating Time-Series Party Positions from Texts." American Journal of Political Science 52(3):705-772.

Examples

Run this code
ie2010dfm <- dfm(ie2010Corpus, verbose=FALSE)
wfmodel <- textmodel_wordfish(LBGexample, dir = c(6,5))
wfmodel

if (require(austin)) {
        wfmodelAustin <- wordfish(quanteda::as.wfm(LBGexample), dir = c(6,5))
        cor(wfmodel@theta, wfmodelAustin$theta)
}

Run the code above in your browser using DataLab