Learn R Programming

quanteda (version 0.9.9-3)

textplot_scale1d: plot a fitted wordfish model

Description

Plot a fitted wordfish model, either as an ideal point-style plot (theta plus confidence interval on the x-axis, document labels on the y) with optional renaming and sorting, or as a plot of estimated feature-level parameters (beta on the x, psi on the y, feature names over-plotted with alpha transparency, optionally some highlighted) as in Slapin and Proksch, 2008.

Usage

textplot_scale1d(x, margin = c("documents", "features"), doclabels = NULL, sort = TRUE, mar_left = 8, highlighted = NULL, alpha = 0.5, ...)

Arguments

x
the fitted textmodel_wordfish object to be plotted
margin
"documents" to plot document scores theta (the default) or "features" to plot psi against beta parameters
doclabels
a vector of names for document. If left NULL (the default), ordinary document names will be used.
sort
if TRUE (the default), order points from low to high score. If a vector, order according to these values from low to high. Only applies when margin = "documents"
mar_left
an overridden left margin, passed to par (default 8.1). This overrides R's default 4.1, which is typically too cramped for document names.
highlighted
a vector of feature names to draw attention to in a feature plot. Only applies if margin = "features".
alpha
A number between 0 and 1 (default 0.5) representing the level of alpha transparency used to overplot feature names in a feature plot. Only applies if margin = "features".
...
additional arguments passed to plot

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
postwar <- dfm_trim(dfm(data_corpus_inaugural[41:57]), min_count = 5, min_docfreq = 2)
mod <- textmodel(postwar, model = "wordfish")
textplot_scale1d(mod, sort = FALSE)
textplot_scale1d(mod, sort = TRUE)
textplot_scale1d(mod, margin = "features", 
                 highlighted = c("government", "countries", "children", 
                             "the", "nuclear", "federal"))

Run the code above in your browser using DataLab