W7 Lab: Scaling Political Texts

Wordscores and Wordfish | Text as Data | National Taiwan University

Before starting

Ungraded practice; no submission. In this lab, we’ll estimate support for the 2010 Irish budget with Wordscores and Wordfish. We’ll compare their rankings, read a speech on which they disagree, and check what changes when we choose another reference text. Allow 60–75 minutes, including time to read the speeches and discuss the outputs.

We download and extract the Lab ZIP, open Lab_Session_W7.R in RStudio, and read this handout alongside it. We keep Data/ beside the R script and run S01–S08b, including all lettered substeps, in one R session. We can read this HTML offline; Quarto is needed only if we choose to edit and render the source QMD.

R script · Instructions · W7 student slides

After each code block, we’ll read the actual output and discuss what it lets us conclude. The outputs below were generated by executing all nineteen checkpoints in order with quanteda 4.3.1, quanteda.textmodels 0.9.10, quanteda.textplots 0.96.1, one processing thread, and seed 7197 before Wordfish. With other versions, we may see small numerical differences. We can bring questions to instructor or TA office hours.

From W6 classification to W7 measurement

In W6, we compared predicted categories with reference labels. Here we ask whether a continuous position captures support for a particular budget. We’ll use agreement between models, close reading, and reference sensitivity to examine that interpretation. We would need independent judgments to assess how well the positions measure budget support.

Reading the R code

We’ll work from top to bottom in the same R session. In RStudio, we select a line or block and use Ctrl+Enter on Windows or Cmd+Enter on Mac. The checkpoint names match the W7 slides and W7_scaling.R, so we can move between the handout and the classroom demonstration.

Syntax What we do with it Example
<- Save a result under a name counts <- dfm(toks_irish)
$ Read a data-frame column or model component results$ws_raw, wf$theta
[rows, columns] Select observations or variables results[is.na(results$reference), ]
NA Leave a reference position unknown rep(NA_real_, ndoc(counts))
match() Find row or column positions by ID or name match(ref_ids, meta$doc_id)
& Keep rows satisfying both conditions is.na(ref_scores) & is.na(ref_alt)
rank() Order scores within the selected texts rank(comparison$ws_raw)
# Write a comment that R does not execute # S03: Define the Wordscores references

Functions used in the lab

Task Functions or components Package
Read corpus metadata and text docvars(), docnames(), corpus_reshape() quanteda
Count words tokens(), tokens_tolower(), dfm() quanteda
Match a scoring vocabulary dfm_match(), ntoken() quanteda
Fit and predict Wordscores textmodel_wordscores(), coef(), predict() quanteda.textmodels / R generics
Fit and inspect Wordfish textmodel_wordfish(), $theta, $se.theta, $beta, $psi quanteda.textmodels
Plot each model’s positions and intervals textplot_scale1d() quanteda.textplots
Format plot axes and appearance ggplot2::labs(), ggplot2::theme_minimal() ggplot2
Compare and plot estimates rank(), cor(), plot(), text() base R

Data and the measurement question

We use the fourteen speeches in quanteda.textmodels::data_corpus_irishbudget2010. They concern the 2010 budget, debated in December 2009. We load this corpus directly from the package. Data/irish_budget2010.csv contains a copy of the original texts and metadata for reading or reuse; we do not need to import it to run the script.

Our unit is a speech, and our intended dimension is support for this budget. We retain party labels to help interpret the results. We supply neither party labels nor independent human position scores to the model-fitting functions.

Method What we supply What we need to examine
Wordscores Word counts and two reference speeches assigned −1 and +1 Whether the references identify budget support and provide relevant language for the other speeches
Wordfish Word counts; an ordering to fix the direction Whether one dimension of word-use variation corresponds to budget support

For Wordscores, we’ll assign Lenihan +1 and Bruton −1. These are our reference inputs for this debate. For Wordfish, we’ll request Bruton below Lenihan to fix the sign. That ordering does not give Wordfish a set of reference position scores.

We remove punctuation, symbols and numbers, and lowercase a working copy. We retain stopwords and use counts without stemming, trimming or TF-IDF weighting. We keep the original corpus for reading quotations and surrounding arguments. Both methods begin with the same count matrix; Wordscores prediction later uses the vocabulary scored by its references.

1. Set up R and inspect the corpus

If the three packages are not installed yet, we run this command once before S01. Installation messages depend on our system.

install.packages(c("quanteda", "quanteda.textmodels", "quanteda.textplots"),
  repos = "https://cloud.r-project.org")

S01. Packages and the Irish corpus

We load the packages, suppress their startup messages, use one processing thread, and keep the built-in corpus as corp_irish. We print the package versions before counting documents.

# S01: Packages and the built-in corpus
# install.packages(c("quanteda", "quanteda.textmodels",
#                    "quanteda.textplots"))
suppressPackageStartupMessages({
  library(quanteda)
  library(quanteda.textmodels)
  library(quanteda.textplots)
})
quanteda_options(threads = 1)
options(width = 72, digits = 4)
corp_irish <- data_corpus_irishbudget2010
c(quanteda = as.character(packageVersion("quanteda")),
  textmodels = as.character(packageVersion("quanteda.textmodels")),
  textplots = as.character(packageVersion("quanteda.textplots")))
ndoc(corp_irish)
  quanteda textmodels  textplots 
   "4.3.1"   "0.9.10"   "0.96.1" 
[1] 14

Explanation.

  • The built-in corpus contains fourteen speeches, each kept as one document.
  • Version strings identify the installed software, helping us trace differences between runs.
  • [1] marks the first printed value; 14 is the document count.

We see the three package versions and fourteen documents. We keep this session open because the later steps reuse the objects created here.

S02a. Speakers and document IDs

We copy the speaker and party metadata into meta and give each document a short ID derived from its original speech number. We use these IDs when we select references and join model results.

# S02a: Speakers and stable document IDs
meta <- data.frame(
  doc_id = paste0("ie_", docvars(corp_irish, "number")),
  speaker = docvars(corp_irish, "name"),
  party = docvars(corp_irish, "party"))
docnames(corp_irish) <- meta$doc_id
print(meta, row.names = FALSE)
 doc_id  speaker party
  ie_01  Lenihan    FF
  ie_02   Bruton    FG
  ie_03   Burton   LAB
  ie_04   Morgan    SF
  ie_05    Cowen    FF
  ie_06    Kenny    FG
  ie_07 ODonnell    FG
  ie_08  Gilmore   LAB
  ie_09  Higgins   LAB
  ie_10    Quinn   LAB
  ie_11  Gormley Green
  ie_12     Ryan Green
  ie_13    Cuffe Green
  ie_14 OCaolain    SF

Explanation.

  • IDs come from speech numbers, so each score can be matched to the correct text after sorting.
  • speaker and party describe the speeches; neither model uses the party column to fit positions.

We have fourteen speaker rows, with IDs ie_01–ie_14. Lenihan and Bruton are the first two speeches. We retain party as metadata; the fitting functions receive word counts rather than this party column.

S02b. Tokenize a working copy

We remove punctuation, symbols and numbers, then lowercase the tokens. We inspect the first twelve tokens from the first speech. We leave corp_irish unchanged for close reading later.

# S02b: Tokenize a working copy
toks_irish <- tokens(corp_irish, remove_punct = TRUE,
  remove_symbols = TRUE, remove_numbers = TRUE)
toks_irish <- tokens_tolower(toks_irish)
head(as.list(toks_irish)[[1]], 12)
 [1] "when"          "i"             "presented"     "the"          
 [5] "supplementary" "budget"        "to"            "this"         
 [9] "house"         "last"          "april"         "i"            

Explanation.

  • The twelve words stay in speech order because this previews tokens, before counting them.
  • [1], [5], and [9] mark token positions, not frequencies.
  • Lowercase words and missing punctuation follow our cleaning choices; the later matrix also removes order.

The output begins with Lenihan’s words, now in lowercase and separated into tokens. Our later count matrix will not retain their sequence or the punctuation marking a quotation.

S02c. Build the count matrix

We count the tokens, inspect the matrix dimensions, check for empty documents, and read the six most frequent features.

# S02c: Build the common count matrix
counts <- dfm(toks_irish)
dim(counts)
any(ntoken(counts) == 0)
topfeatures(counts, 6)
[1]   14 4885
[1] FALSE
 the   to   of  and   in    a 
3598 1633 1537 1359 1231 1013 

Explanation.

  • 14 4885 reflects fourteen speeches and their combined vocabulary; cells count word occurrences.
  • FALSE confirms cleaning left words in every speech.
  • We kept stopwords, so the remains common: 3,598 occurrences alone do not distinguish political positions.

We have 14 rows and 4,885 columns. The empty-document check is FALSE. Common words such as the remain in the matrix; frequency alone does not tell us whether a word distinguishes positions.

2. Estimate positions with Wordscores

We first use two reference speeches to score words, check the vocabulary available for prediction, and read the resulting raw document scores. We then plot all fourteen predictions in S04d.

S03. Define the Wordscores references

We create a named vector of unknown scores, then assign Lenihan +1 and Bruton −1 by document ID. We print the two assignments to check the design before fitting.

# S03: Define the Wordscores references
ref_scores <- rep(NA_real_, ndoc(counts))
names(ref_scores) <- docnames(counts)
ref_ids <- c("ie_01", "ie_02")
ref_scores[ref_ids] <- c(1, -1)
print(data.frame(speaker = meta$speaker[match(ref_ids, meta$doc_id)],
  reference = ref_scores[ref_ids]), row.names = FALSE)
 speaker reference
 Lenihan         1
  Bruton        -1

Explanation.

  • We assign Lenihan +1 because he defends the budget, and Bruton −1 because he criticizes it.
  • These inputs set the intended direction; the other twelve positions stay NA because we have not supplied them.

We see the two assigned endpoints. The other twelve entries remain NA, meaning that we have not supplied their positions as Wordscores references. These assignments establish our intended budget-support direction.

S04a. Fit Wordscores and inspect word scores

We fit Wordscores with smooth = 0 and inspect six words. The model learns their scores from relative word use in the selected reference speeches.

# S04a: Fit Wordscores and inspect word scores
ws <- textmodel_wordscores(counts, y = ref_scores, smooth = 0)
probe_words <- c("budget", "government", "tax",
                 "jobs", "fair", "recovery")
print(data.frame(word = probe_words,
  score = round(coef(ws)[probe_words], 3)), row.names = FALSE)
       word  score
     budget -0.384
 government  0.140
        tax  0.665
       jobs  0.379
       fair -0.229
   recovery  0.403

Explanation.

  • tax scores +0.665 because it is proportionally more frequent in Lenihan’s positive reference.
  • fair scores −0.229 because it is proportionally more frequent in Bruton’s negative reference.
  • Scores follow reference usage, so ordinary positive or negative sentiment does not determine their signs.

We see fair at −0.229 and tax at +0.665. These values describe associations with our two references. We have not supplied a general sentiment dictionary, so an ordinarily positive word can point toward the negative reference.

S04b. Check the scoring vocabulary

We match the count matrix to words that received a Wordscores coefficient. For each speech, we divide its retained token count by its original processed token count.

# S04b: Align the scoring vocabulary and inspect coverage
ws_counts <- dfm_match(counts, features = names(coef(ws)))
ws_coverage <- ntoken(ws_counts) / ntoken(counts)
dim(ws_counts)
summary(ws_coverage)
[1]   14 2131
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  0.836   0.850   0.874   0.886   0.887   1.000 

Explanation.

  • Only 2,131 of 4,885 features occur in the references and receive scores; all fourteen speeches remain.
  • Coverage is 83.6%–100%, with median 87.4%, because speeches use different amounts of scored vocabulary.
  • Repeated occurrences count toward coverage; this measures retained language, not prediction accuracy.

The scoring matrix has 2,131 features, compared with 4,885 in the full DFM. Coverage ranges from 0.836 to 1.000. With smooth = 0, words absent from the reference vocabulary do not receive scores. Coverage counts token occurrences, rather than unique word types.

S04c. Predict raw Wordscores

We predict every speech using the matched vocabulary and rescaling = "none". We keep the assigned inputs in reference and the predictions in ws_raw so we can compare their roles.

# S04c: Predict raw Wordscores for every speech
ws_pred <- predict(ws, newdata = ws_counts, rescaling = "none")
results <- meta
results$reference <- ref_scores
results$ws_raw <- as.numeric(ws_pred)
results$coverage <- ws_coverage
print(data.frame(speaker = results$speaker, party = results$party,
  reference = results$reference,
  ws_raw = round(results$ws_raw, 3)), row.names = FALSE)
  speaker party reference ws_raw
  Lenihan    FF         1  0.339
   Bruton    FG        -1 -0.339
   Burton   LAB        NA -0.001
   Morgan    SF        NA  0.023
    Cowen    FF        NA  0.180
    Kenny    FG        NA -0.020
 ODonnell    FG        NA -0.029
  Gilmore   LAB        NA -0.012
  Higgins   LAB        NA -0.040
    Quinn   LAB        NA -0.023
  Gormley Green        NA  0.159
     Ryan Green        NA -0.012
    Cuffe Green        NA  0.003
 OCaolain    SF        NA  0.026

Explanation.

  • Assigned +1 and −1 teach word scores; rescoring averages those scores, yielding Lenihan +0.339 and Bruton −0.339.
  • Shared vocabulary pulls raw averages toward the centre.
  • NA marks twelve speeches whose reference positions were not supplied; ws_raw contains their predictions.

Lenihan and Bruton are rescored at approximately +0.339 and −0.339, even though we assigned +1 and −1. Averaging learned word scores over shared language pulls raw scores toward the centre. The twelve NA-reference speeches are new texts for Wordscores; rescoring the two references does not provide an independent benchmark.

S04d. Plot raw Wordscores for every speech

We request raw predictions with standard errors, then use quanteda.textplots::textplot_scale1d() to plot all fourteen speeches. The labels mark Lenihan and Bruton as references. Each point is a raw prediction; its interval extends 1.96 standard errors in each direction.

# S04d: Plot raw Wordscores with model-based intervals
ws_plot <- predict(ws, newdata = ws_counts,
  se.fit = TRUE, rescaling = "none")
ws_labels <- paste0(meta$speaker,
  ifelse(is.na(ref_scores), "", " [reference]"))
textplot_scale1d(ws_plot, doclabels = ws_labels, sort = TRUE) +
  ggplot2::labs(x = NULL, y = "Raw Wordscores") +
  ggplot2::theme_minimal(base_size = 24)

Fourteen raw Wordscores predictions with 95% normal intervals; Lenihan and Bruton are labelled as references.

All fourteen raw Wordscores predictions, including the two references. Intervals extend 1.96 standard errors either side of each prediction; the assigned reference values are +1 and −1.

Explanation.

  • Reference dots near +0.339 and −0.339 show rescored word averages, rather than assigned endpoints.
  • Burton near zero reflects a word-score average; it does not establish neutral budget support.
  • Bars show approximate 95% uncertainty under the scoring method; reference-choice uncertainty is excluded.

Lenihan and Bruton still appear at approximately +0.339 and −0.339, rather than their assigned +1 and −1. Among the twelve new texts, Cowen has the highest raw score, about 0.180. Burton is near zero, but that does not establish a neutral budget position. The bars are 95% normal intervals under the scoring method; they do not validate the reference choices or the budget-support interpretation.

3. Estimate positions with Wordfish

We now fit a single dimension from all fourteen speeches without a reference-score vector. Under the Poisson specification, expected word counts depend on document effects, word baselines and a word-loading-by-position term. We need to examine whether that dimension captures our substantive question. S05d plots this model’s positions before we compare the two scales in S06.

S05a. Fit Wordfish and set its direction

We use the full count matrix and find the Bruton–Lenihan row indices from their IDs. We set seed 7197 and fit the Poisson Wordfish model with that ordering in dir.

# S05a: Fit Wordfish and fix its orientation
wf_dir <- match(c("ie_02", "ie_01"), docnames(counts))
set.seed(7197)
wf <- textmodel_wordfish(counts, dir = wf_dir,
  dispersion = "poisson")
data.frame(speaker = meta$speaker[wf_dir],
  theta = round(wf$theta[wf_dir], 3))
  speaker  theta
1  Bruton -0.585
2 Lenihan  1.775

Explanation.

  • Bruton (−0.585) is below Lenihan (1.775) because dir chooses that ordering.
  • The positions are estimated from counts, not fixed at −1/+1. Direction alone does not establish budget-support meaning.

We see Bruton below Lenihan, at approximately −0.585 and +1.775. Wordfish estimates all positions jointly. We have fixed its direction; we have not supplied the Wordscores reference vector or established the meaning of the fitted dimension.

S05b. Read positions and model standard errors

We add the estimated positions and their standard errors to results, keeping the original speaker order. These standard errors describe uncertainty under the fitted model and its assumptions.

# S05b: Inspect Wordfish positions and model standard errors
results$wf_theta <- wf$theta
results$wf_se <- wf$se.theta
print(data.frame(speaker = results$speaker, party = results$party,
  theta = round(results$wf_theta, 3),
  se = round(results$wf_se, 3)), row.names = FALSE)
  speaker party  theta    se
  Lenihan    FF  1.775 0.021
   Bruton    FG -0.585 0.029
   Burton   LAB -1.150 0.016
   Morgan    SF -0.093 0.029
    Cowen    FF  1.794 0.024
    Kenny    FG -0.789 0.026
 ODonnell    FG -0.493 0.044
  Gilmore   LAB -0.587 0.030
  Higgins   LAB -0.979 0.041
    Quinn   LAB -0.921 0.042
  Gormley Green  1.122 0.075
     Ryan Green  0.212 0.065
    Cuffe Green  0.793 0.073
 OCaolain    SF -0.098 0.039

Explanation.

  • Burton has theta = −1.150 and se = 0.016; Gormley’s se = 0.075 is larger.
  • Burton’s smaller standard error gives a narrower model interval; it does not prove the scale measures budget support.

Burton has the lowest estimated position, at about −1.150, with a model standard error of about 0.016. We can estimate a position precisely under the model while still needing evidence about what that position means.

S05c. Read word discrimination and baseline frequency

We inspect beta and psi for the same six words used in S04a. beta links word use to position; psi is the word baseline in the log expected-count model, alongside the document effect.

# S05c: Inspect word discrimination and baseline frequency
word_id <- match(probe_words, wf$features)
print(data.frame(word = probe_words,
  beta = round(wf$beta[word_id], 3),
  psi = round(wf$psi[word_id], 3)), row.names = FALSE)
       word  beta   psi
     budget 0.042 2.711
 government 0.173 2.612
        tax 0.396 2.194
       jobs 0.505 1.842
       fair 0.191 0.860
   recovery 0.358 0.897

Explanation.

  • Budget’s psi (2.711) describes baseline commonness; its small beta (0.042) means little change along theta.
  • Jobs’ beta (0.505) gives stronger log expected-count change per theta unit, with other effects fixed.
  • psi is not raw frequency; positive beta is not positive sentiment.

We see separate estimates for discrimination and baseline frequency. For example, budget has a relatively large baseline and a small loading. The positive loading for fair also differs from its negative Wordscores value, because the two models learn their parameters in different ways.

S05d. Plot the Wordfish positions

We pass the fitted Wordfish model to quanteda.textplots::textplot_scale1d() and sort all fourteen speeches by their estimated positions. Each point shows theta, with a 95% normal interval calculated from its model standard error.

# S05d: Plot Wordfish positions with model-based intervals
textplot_scale1d(wf, doclabels = meta$speaker, sort = TRUE) +
  ggplot2::labs(x = NULL, y = "Wordfish position (theta)") +
  ggplot2::theme_minimal(base_size = 24)

Fourteen Wordfish positions, sorted by their estimates, with 95% normal intervals from model standard errors.

All fourteen Wordfish positions with intervals of plus or minus 1.96 model standard errors. Precision under the model does not establish the budget-support interpretation.

Explanation.

  • Cowen (1.794) and Lenihan (1.775) lie to the right of Burton (−1.150) on the theta axis.
  • Approximate 95% bars use theta ± 1.96 × se; smaller standard errors produce narrower intervals.
  • Intervals describe model uncertainty; they do not establish budget-support meaning.

Cowen and Lenihan are near the high end, at about 1.79 and 1.78. Burton is at the low end, about −1.15. The intervals describe uncertainty under the fitted model. Small intervals do not show that the dimension measures budget support, and zero is not a validated neutral position. These are Wordfish units, so we do not compare their numerical distances directly with raw Wordscores.

4. Compare the models and return to the speeches

We use agreement to describe the rankings and disagreement to guide our reading. We would need evidence beyond agreement between these two models to validate budget support.

S06a. Compare the twelve new texts

We exclude the two Wordscores references, rank the remaining twelve speeches within each model, and sort by the absolute rank gap. We use document ID to break ties in the display order.

# S06a: Compare rankings among the twelve new texts
comparison <- results[is.na(results$reference), ]
comparison$ws_rank <- rank(comparison$ws_raw)
comparison$wf_rank <- rank(comparison$wf_theta)
comparison$gap <- abs(comparison$ws_rank - comparison$wf_rank)
comparison <- comparison[order(-comparison$gap, comparison$doc_id), ]
round(cor(comparison$ws_raw, comparison$wf_theta,
  method = "spearman"), 3)
print(head(comparison[c("speaker", "ws_rank", "wf_rank", "gap")], 6),
  row.names = FALSE)
[1] 0.734
  speaker ws_rank wf_rank gap
   Burton       7       1   6
 ODonnell       2       6   4
     Ryan       6       9   3
 OCaolain      10       7   3
    Cuffe       8      10   2
   Morgan       9       8   1

Explanation.

  • ws_rank = 7 and wf_rank = 1 give Burton an absolute gap = 6; rank 1 means lower.
  • Spearman 0.734 summarizes twelve speeches: overall agreement can coexist with one large disagreement. It is not accuracy.

Spearman rank correlation is 0.734. Burton has the largest rank gap: Wordscores rank 7, Wordfish rank 1, a gap of 6. Rank 1 is the lower end of each oriented scale. We are comparing model rankings on the same corpus; these twelve speeches were still included in the Wordfish fit.

S06b. Plot the two scales

We plot each of the twelve new texts using its raw Wordscores value and Wordfish position. We label the three speeches selected by the rank-gap diagnostic in S06a.

# S06b: Plot the new texts on both scales
plot(comparison$ws_raw, comparison$wf_theta,
  type = "n", xlim = c(-0.08, 0.24),
  xlab = "Wordscores (raw)", ylab = "Wordfish (theta)")
abline(h = 0, v = 0, col = "grey45", lty = 2, lwd = 1.8)
points(comparison$ws_raw, comparison$wf_theta,
  pch = 19, col = "#0271bb")
text(comparison$ws_raw[1:3], comparison$wf_theta[1:3],
  labels = comparison$speaker[1:3], pos = 4, cex = 0.85)

Twelve speeches on raw Wordscores and Wordfish axes; Burton, ODonnell and Ryan are labelled.

The twelve new texts for Wordscores, labelled by the three largest rank gaps. Wordfish was fitted to all fourteen speeches.

Explanation.

  • Burton is near zero in Wordscores but low in Wordfish: ranks 7 versus 1.
  • Wordscores uses two reference speeches; Wordfish fits all speeches’ word-count patterns.
  • The axes have different units. Read her argument before treating near-zero as neutral.

We see Burton, O’Donnell and Ryan labelled. The horizontal and vertical axes have different units, and their zero lines do not define a validated neutral position. The plot helps us choose cases to read rather than settle which model is correct.

S07a. Read the largest ranking disagreement

We select the largest rank gap using comparison, then return to the original corpus. We split that speech into sentences and read its opening in the original wording.

# S07a: Identify and read the largest ranking disagreement
read_id <- comparison$doc_id[1]
print(comparison[1, c("doc_id", "speaker", "ws_rank", "wf_rank")],
  row.names = FALSE)
read_sentences <- as.character(corpus_reshape(
  corp_irish[read_id], to = "sentences"))
cat(strwrap(read_sentences[1], width = 66), sep = "\n")
 doc_id speaker ws_rank wf_rank
  ie_03  Burton       7       1
The other day, Goldman Sachs circulated a note about the Irish
budget which referred to the remarkable degree of consensus in
Ireland about the necessity for budget adjustments.

Explanation.

  • Burton was selected because her model ranks differ most: Wordscores 7, Wordfish 1.
  • The consensus claim comes from a Goldman Sachs note she reports, so it does not establish her approval.

Our diagnostic selects Joan Burton (ie_03). The opening reports a Goldman Sachs note about consensus. We need to distinguish the source of that claim from Burton’s own stance and read how she develops the argument.

S07b. Read the surrounding argument

We read sentences 5–7 of the same speech. With the current data and settings, these passages follow Burton’s opening. If our fit selects another speech, we first check which surrounding passages we should read.

# S07b: Read more of the same speech
# In this corpus, the selected speech is Burton's. Read sentences 5-7.
cat(strwrap(paste(read_sentences[5:7], collapse = " "),
  width = 66), sep = "\n")
# We can print the full speech in the console:
# cat(as.character(corp_irish[read_id]))
One could never have imagined one's party giving such an
advantageous start to any Government. This could have been a
consensus budget as it was a classic "all jump together" moment,
an opportunity for burden sharing by everyone but the Minister
blew it. The budget is straight out of the Leona Helmsley school
of thought in which burden sharing, like taxation, is only for
the little people.

Explanation.

  • A consensus budget is something Burton says the Minister failed to achieve; she criticizes burden sharing.
  • Words like consensus appear inside criticism, so a near-zero score need not mean moderate support.

Burton describes a missed opportunity for shared burdens and criticizes the budget. This context gives us reason to question whether a middle score represents moderate support. It does not by itself show which words caused the disagreement between the two models.

5. Check sensitivity to a reference choice

We change one reference while keeping the remaining analysis choices fixed. We then compare the same set of new speeches under both designs.

S08a. Change the positive reference

We replace Lenihan with Cowen at +1 and retain Bruton at −1. We use the same preprocessing, smooth = 0, vocabulary-matching rule and raw prediction setting.

# S08a: Replace the positive reference and refit Wordscores
ref_alt <- ref_scores
ref_alt[c("ie_01", "ie_05")] <- c(NA, 1)
ws_alt <- textmodel_wordscores(counts, y = ref_alt, smooth = 0)
ws_alt_counts <- dfm_match(counts, features = names(coef(ws_alt)))
ws_alt_pred <- predict(ws_alt, newdata = ws_alt_counts,
  rescaling = "none")
print(data.frame(speaker = meta$speaker[!is.na(ref_alt)],
  reference = ref_alt[!is.na(ref_alt)]), row.names = FALSE)
 speaker reference
  Bruton        -1
   Cowen         1

Explanation.

  • reference lists assigned inputs: Cowen +1 replaces Lenihan +1; Bruton −1 stays.
  • A different reference speech supplies different word shares, so word scores and scoring vocabulary can change despite identical endpoints.

The printed reference design now contains Bruton −1 and Cowen +1. Even with unchanged numerical endpoints, we have changed the positive reference’s lexical evidence. The refit can therefore change both word scores and vocabulary coverage.

S08b. Compare the same eleven new texts

We retain only speeches with unknown reference scores in both designs. We exclude Lenihan, Bruton and Cowen, then recompute both rankings within the same eleven texts. We calculate change as the new rank minus the earlier rank.

# S08b: Compare ranks within the same eleven new texts
common_new <- is.na(ref_scores) & is.na(ref_alt)
sensitivity <- meta[common_new, c("doc_id", "speaker")]
sensitivity$before <- rank(ws_pred[common_new])
sensitivity$after <- rank(ws_alt_pred[common_new])
sensitivity$change <- sensitivity$after - sensitivity$before
print(sensitivity[c("speaker", "before", "after", "change")],
  row.names = FALSE)
  speaker before after change
   Burton      7     5     -2
   Morgan      9     8     -1
    Kenny      4     2     -2
 ODonnell      2     4      2
  Gilmore      5     6      1
  Higgins      1     1      0
    Quinn      3     3      0
  Gormley     11    11      0
     Ryan      6     9      3
    Cuffe      8    10      2
 OCaolain     10     7     -3

Explanation.

  • Ryan: 6→9 (+3); O’Caolain: 10→7 (−3). These are the largest absolute changes.
  • change = after − before, with both rankings recalculated among the same eleven speeches.
  • Changing reference language changes learned word scores, so rankings can move without any policy change.

Ryan moves from rank 6 to 9 and O’Caolain from 10 to 7, the largest changes in this comparison. A positive change means movement toward the higher end of the ranking. These ranks use eleven common texts, rather than the twelve-text comparison in S06. We hold membership fixed so that reference sensitivity is not confused with a change in the comparison set.

6. Report what we can conclude

We write a short account of the analysis, using the output and the original speeches together:

  1. Define the target and unit. What do we intend to measure, and what does one document represent?
  2. Describe our design. Which preprocessing, references and orientation did we use? Which estimates are raw Wordscores and which are Wordfish positions?
  3. Report agreement and disagreement. How do we describe the 0.734 rank correlation alongside Burton’s rank gap and the passages we read?
  4. Report sensitivity. Which rankings changed after we replaced Lenihan with Cowen, and which eleven speeches did we compare?
  5. Specify independent evidence. How would we collect human judgments of budget support without giving readers our model scores? What would we ask them to compare, and which additional speeches would we read?

We have diagnosed model disagreement and reference sensitivity. To validate the interpretation of the scale, we would compare the estimates with independent evidence about budget support. We also distinguish the Wordfish model standard errors from uncertainty about whether the dimension measures our intended concept.

Data notes

We can inspect the full original speeches in Data/irish_budget2010.csv. The file contains doc_id, speaker, party, budget_year, source_document and text. We retain the corpus wording and punctuation. We assign the −1/+1 reference inputs in the R script; the CSV does not provide independently validated position scores. The data README records the source and fields.

We use the installed package corpus for fitting, one processing thread, and seed 7197 immediately before Wordfish. We compare the models on the supplied corpus. Our preprocessing and fitted results are classroom estimates, so we distinguish them from estimates reported in the original articles.

Reading connections

  • Wordscores: Laver, Benoit and Garry (2003). We connect the reference design to word scores, raw document scoring and its plot in S03–S04d.
  • Wordfish: Slapin and Proksch (2008). We distinguish identification, word loadings, model precision and the position plot from the interpretation of positions in S05a–S05d.
  • Position plots: quanteda’s fitted scaling model examples. S04d and S05d use quanteda.textplots::textplot_scale1d(); the intervals summarize uncertainty under each method rather than independent evidence of validity.
  • Human validation: Lowe and Benoit (2013), “Validating Estimates of Latent Traits from Textual Data Using Human Judgment as a Benchmark.” We use the Irish budget case to motivate close reading and independent evidence in S06–S08.
  • Lecture concepts: Benoit, TCD text-scaling lecture (2018). We can review pp. 9–20 for Wordscores, pp. 37–41 for Wordfish, and pp. 59–66 for validity, uncertainty and text scope. The lecture’s Gormley example and our Burton diagnostic concern different passages.

Course homepage · W7 student slides · Lab ZIP