quanteda.textmodels v0.9.1


Monthly downloads



Scaling Models and Classifiers for Textual Data

Scaling models and classifiers for sparse matrix objects representing textual data in the form of a document-feature matrix. Includes original implementations of 'Laver', 'Benoit', and Garry's (2003) <doi:10.1017/S0003055403000698>, 'Wordscores' model, Perry and 'Benoit's' (2017) <arXiv:1710.08963> class affinity scaling model, and 'Slapin' and 'Proksch's' (2008) <doi:10.1111/j.1540-5907.2008.00338.x> 'wordfish' model, as well as methods for correspondence analysis, latent semantic analysis, and fast Naive Bayes and linear 'SVMs' specially designed for sparse textual data.



Travis build
status AppVeyor build
status codecov Lifecycle:


An R package adding text scaling models and classifiers for quanteda. Prior to quanteda v2, many of these were part of that package. Early development was supported by the European Research Council grant ERC-2011-StG 283794-QUANTESS.

For more details, see https://quanteda.io.

How to Install

Once the package is on CRAN (which is it not yet), then you can install it via the normal way from CRAN, using your R GUI or


Or for the latest development version:

# devtools package required to install quanteda from Github 

Because this compiles some C++ and Fortran source code, you will need to have installed the appropriate compilers.

If you are using a Windows platform, this means you will need also to install the Rtools software available from CRAN.

If you are using macOS, you should install the macOS tools, namely the Clang 6.x compiler and the GNU Fortran compiler (as quanteda requires gfortran to build). If you are still getting errors related to gfortran, follow the fixes here.

How to cite

Benoit, Kenneth, Kohei Watanabe, Haiyan Wang, Paul Nulty, Adam Obeng, Stefan Müller, and Akitaka Matsuo. (2018) “quanteda: An R package for the quantitative analysis of textual data”. Journal of Open Source Software. 3(30), 774. https://doi.org/10.21105/joss.00774.

For a BibTeX entry, use the output from citation(package = "quanteda").

Leaving Feedback

If you like quanteda, please consider leaving feedback or a testimonial here.


Contributions in the form of feedback, comments, code, and bug reports are most welcome. How to contribute:

Functions in quanteda.textmodels

Name Description
data_corpus_EPcoaldebate Crowd-labelled sentence corpus from a 2010 EP debate on coal subsidies
friendly_class_undefined_message Print friendly object class not defined message
influence.predict.textmodel_affinity Compute feature influence from a predicted textmodel_affinity object
as.summary.textmodel Assign the summary.textmodel class to a list
data_dfm_lbgexample dfm from data in Table 1 of Laver, Benoit, and Garry (2003)
predict.textmodel_wordscores Predict textmodel_wordscores
data_corpus_moviereviews Movie reviews with polarity from Pang and Lee (2004)
coef.textmodel_ca Extract model coefficients from a fitted textmodel_ca object
textmodel_affinity Class affinity maximum likelihood text scaling model
predict.textmodel_svmlin Prediction from a fitted textmodel_svmlin object
textmodel_wordscores Wordscores text model
predict.textmodel_nb Prediction from a fitted textmodel_nb object
textmodels quanteda.textmodels: Scaling Models and Classifiers for Textual Data
predict.textmodel_svm Prediction from a fitted textmodel_svm object
message_error Return an error message
print.textmodel_wordfish print method for a wordfish model
predict.textmodel_affinity Prediction for a fitted affinity textmodel
print.coefficients_textmodel Print methods for textmodel features estimates This is a helper function used in print.summary.textmodel.
force_conformance Internal function to match a dfm features to a target set
textmodel_affinity-internal Internal methods for textmodel_affinity
textmodel_ca Correspondence analysis of a document-feature matrix
summary.textmodel_nb summary method for textmodel_nb objects
print.statistics_textmodel Implements print methods for textmodel_statistics
predict.textmodel_wordfish Prediction from a textmodel_wordfish method
textmodel_wordfish Wordfish text model
unused_dots Raise warning of unused dots
summary.textmodel_wordfish summary method for textmodel_wordfish
textmodel_svmlin (faster) Linear SVM classifier for texts
summary.textmodel_svm summary method for textmodel_svm objects
textplot_influence Influence plot for text scaling models
textmodel_lsa Latent Semantic Analysis
textmodel_nb Naive Bayes classifier for texts
textplot_scale1d Plot a fitted scaling model
textmodel_svm Linear SVM classifier for texts
print.summary.textmodel print method for summary.textmodel
summary.textmodel_svmlin summary method for textmodel_svmlin objects
textmodel_lsa-postestimation Post-estimations methods for textmodel_lsa
data_corpus_dailnoconf1991 Confidence debate from 1991 Irish Parliament
data_corpus_irishbudget2010 Irish budget speeches from 2010
as.statistics_textmodel Coerce various objects to statistics_textmodel
affinity Internal function to fit the likelihood scaling mixture model.
as.matrix.csr.dfm convert a dfm into a matrix.csr from SparseM package
as.coefficients_textmodel Coerce various objects to coefficients_textmodel This is a helper function used in summary.textmodel_*.
No Results!

Vignettes of quanteda.textmodels

No Results!

Last month downloads


Type Package
LinkingTo Rcpp, RcppParallel, RcppArmadillo (>= 0.7.600.1.0), quanteda
URL https://github.com/quanteda/quanteda.textmodels
License GPL-3
Encoding UTF-8
LazyData true
Language en-GB
RoxygenNote 7.0.2
SystemRequirements C++11
Collate 'RcppExports.R' 'quanteda.textmodels-package.R' 'data-documentation.R' 'textmodel-methods.R' 'textmodel_affinity.R' 'textmodel_ca.R' 'textmodel_lsa.R' 'textmodel_nb.R' 'textmodel_svm.R' 'textmodel_svmlin.R' 'textmodel_wordfish.R' 'textmodel_wordscores.R' 'textplot_influence.R' 'textplot_scale1d.R' 'utils.R'
VignetteBuilder knitr
NeedsCompilation yes
Packaged 2020-03-13 01:20:55 UTC; kbenoit
Repository CRAN
Date/Publication 2020-03-13 10:00:11 UTC

Include our badge in your README