W7: Scaling Political Texts
W6 asked "Which category does this text belong to?"; W7 asks a different question: "Where does this text fall on a continuous scale?" This week introduces four methods—Wordscores, Wordfish, Wordshoal, and Latent Semantic Scaling (LSS)—and actually runs Wordscores and Wordfish on 14 speeches from the 2010 Irish budget debate.
From categories to continuous positions
Slide 8 sets W6 and W7 side by side as three rows of research tasks:
| Research task | Link to W6 | W7 question |
|---|---|---|
| Assign a category | Hate speech and grandstanding | Which texts belong to the same class? |
| Measure a degree | Julia Park's original grandstanding scores (continuous) | Where is a text on a scale? |
| Interpret the measure | Read the errors, look at external evidence | What makes a position meaningful? |
A classifier answers "yes/no"; a scaling model answers "more/less". For example, instead of asking "Does this speech support the budget?", we place the 14 TDs on a "support ↔ oppose" line. But the model only gives you a list of numbers; whether that line stands for "supporting the budget", "government/opposition", or "talking economics/talking welfare" is something you decide by reading the texts and finding external evidence—this is the "validation" that keeps coming up this week.
What you should be able to explain this week
The four learning goals on slide 11 (order: cases → method concepts → reading and validation → R tools and practice). Come back and tick them after reading:
- Problems and assumptions: explain what problem each method solves and what its main assumptions are.
- Connect to research: link a published application to the texts it uses and its measurement target.
- Three kinds of "guidance": distinguish reference scores, latent positions, and seed words.
- Read before fitting: read the texts before fitting a model, and plan independent checks.
This week's six research cases
| No. | Article | Method | Texts | Teaching link |
|---|---|---|---|---|
| Study 1 | Laver, Benoit & Garry (2003) | Wordscores | Party manifestos | Wordscores and reference positions (Ch. 2–3) |
| Study 2 | Slapin & Proksch (2008) | Wordfish | German party manifestos | Wordfish and change over time (Ch. 4–5) |
| Study 6 | Lowe & Benoit (2013) | Wordfish | Irish budget speeches | Human judgement and model failure (Ch. 6) |
| Study 3 | Lauderdale & Herzog (2016) | Wordshoal | Parliamentary debates | Wordshoal and debate structure (Ch. 7) |
| Study 4 | Trubowitz & Watanabe (2021) | LSS | News summaries | LSS and geopolitical threat (Ch. 8) |
| Study 5 | Hjorth et al. (2015) | Both (Wordscores + Wordfish) | Danish and German manifestos | External benchmarks and context (Ch. 9) |
Note on slide 12: Wordshoal uses Wordfish within each debate.
This week's practice data: the 2010 Irish budget debate
- 14 speeches on the 2010 Irish budget, debated in December 2009. Loaded directly from
quanteda.textmodels::data_corpus_irishbudget2010. Data/irish_budget2010.csvis a copy of the same texts and metadata (columnsdoc_id, speaker, party, budget_year, source_document, text), convenient for reading and for reuse in other programs; it is not needed for fitting. Local check: the 14 full texts in the CSV are identical to the package corpus (see Ch. 10).- Measurement target: support for this budget. S03 sets Lenihan (Minister for Finance, FF) = +1 and Bruton (FG) = −1; S08 switches to Cowen = +1 to check sensitivity.
- Research context: Lowe & Benoit (2013) use human judgement as a benchmark to test Wordfish (Ch. 6).
How to use these notes
- The slide panel on the right switches pages as you read; the "Slide N" next to each heading is the source.
- The R code and output in Ch. 10–13 come from running the course script
W7/classroom/W7_scaling.Rlocally (R 4.5.3 (aarch64-conda-linux-gnu), quanteda 4.5.1, quanteda.textmodels 0.9.10, quanteda.textplots 0.96.1, ggplot2 4.0.3). Every number was checked one by one against slides 93–129 and all match; the only difference is the package version string (slides: quanteda 4.3.1; local: 4.5.1). - Interactive components come in three kinds: real data (this week's 14 speeches and local model output), toy intuition (marked "Supplement (not from the lecture)"), and practice (answer boxes, claim judgements, a plan builder).
- Anything marked "Supplement (not from the lecture)" is extra explanation, not slide content.
Self-check
What does scaling do? What "guidance" do you supply?
All four methods place texts on one (or more) scales; they differ in what information the researcher supplies in advance, what data structure they need, and what they output. This chapter builds the map first; later chapters go into each in depth.
An analogy: lining speeches up on a ruler (supplement)
Imagine lining up 14 speeches on a "support ↔ oppose the budget" ruler. Wordscores: you first tell the computer "this one is +1, that one is −1"; it learns which end each word resembles, then scores the other speeches. Wordfish: you give no scores; the computer finds by itself the one axis that "best explains differences in word use", and you only tell it which end points left. Wordshoal: legislators speak in many debates; rank them within each debate first, then link the debates together. LSS: you give a set of "seed words" representing the two ends, and the computer learns from co-occurrence how close other words are to each end.
Four methods: guidance, structure, output
| Method | Guidance supplied by the researcher | Required structure | Main output |
|---|---|---|---|
| Wordscores | Reference document scores | Comparable reference and new texts | Positions of new documents |
| Wordfish | No position labels | One count matrix | Relative document positions |
| Wordshoal | No position labels | The same speakers across many debates | Common speaker positions |
| LSS | Seed words and their polarity | Semantic relations in the corpus | Word and document polarity |
Anchors are not independent validation
| Evidence | What it does | What remains to be checked |
|---|---|---|
| Wordscores reference texts | Define the learned scale | Performance on other texts |
Wordfish dir | Chooses the direction | The meaning of the dimension |
| LSS seed words | Specify the semantic direction | Whether concept and target match in context |
| Independent judgement | Checks the expected interpretation | Agreement, range covered, and scope |
A validation workflow: five questions
Slide 89 distils this week's research cases into five questions (the plan builder in Ch. 9 uses them). Click each step:
- Concept: what does a high score mean?
- Unit: which text, speaker, or period receives a score?
- Design: what information and structure does the method need?
- Assumption: which condition is most likely to fail in your data?
- Evidence: what independent observation could reveal that failure?
Method chooser
Answer three questions about your data to see which situation described in the slides is closest. This is only a starting point: the choice of method depends on the research question and the available evidence (slide 11).
Self-check
dir argument supply?Wordscores: from reference texts to new documents
Wordscores starts in the Irish parliament: a 1991 confidence debate. First assign positions to a few "reference texts", learn a score for each word, then use those word scores to position the other speeches.
Parliamentary origin: Ireland, 1991
| Research choice | Irish Dáil study (Laver & Benoit 2002) |
|---|---|
| Political setting | October 1991 confidence debate on the Fianna Fáil–PD government |
| Texts | 58 individual legislators' speeches in English |
| Measurement target | How strongly did each speaker support or oppose the government? |
Beyond the final confidence vote, what else might the speeches reveal? (Hint (supplement): under party discipline a vote usually has only two outcomes, "yes/no", but the wording of a speech can show differences of degree.)
From reference speeches to positions: three steps
| Step | The early parliamentary design |
|---|---|
| 1. Assign reference positions | Haughey: +1; Bruton and de Rossa: −1 |
| 2. Score the vocabulary | Learn word scores from these reference speeches |
| 3. Place the other speakers | Combine the scored words in each remaining speech |
Interpretation: support for this government within this debate. 2002 is the parliamentary application; the 2003 general Wordscores article (Laver, Benoit & Garry, APSR) also includes this debate (slide 7 cites Laver & Benoit 2002, pp. 61–66; LBG 2003, pp. 326–328).
Situation: some texts already have credible positions
- Use these documents as reference texts.
- Learn how their words separate those positions.
- Estimate positions for comparable new documents (the W7 R practice calls them new texts; the literature often calls them virgin texts).
Example: use earlier party manifestos as references to position the next election's manifestos (this is what LBG 2003 does in Ch. 3).
How it is computed: three formulas (supplement, verified in R)
textmodel_wordscores(smooth = 0) step by step in local RLet the assigned score of reference text r be Ar, and the relative frequency of word w in r be Fwr = countwr / total wordsr.
- The "conditional probability" of a word across references: Pwr = Fwr / Σr Fwr (computed only for words that appear in at least one reference).
- Word score: Sw = Σr Pwr · Ar.
- Raw score of a new document: Sv = Σw Fwv · Sw, where Fwv is the relative frequency computed only among "scored words".
Local verification (Ch. 11, X2): hand-computed word scores vs. coef(ws) maximum difference 0; hand-computed document scores vs. ws_raw maximum difference 5.662e-15; 2,131 scored words in total.
Toy Wordscores calculator
Edit the counts or reference scores in the table and watch how the word scores Sw and the new text's score change. The words and numbers are made up, only to demonstrate the computation. Try: (1) make the new text use only the middle word "budget"—its score is pulled toward the centre; (2) the new text contains a word the references lack (the last row, pension, has reference counts of 0)—it gets no score and does not count toward coverage.
Reference A also uses words common to both sides (e.g., the, budget); those words score near 0 and pull A's average toward the centre. In the real data of Ch. 11, Lenihan is assigned +1 but rescores to only 0.339 (slide 107). Slides 34–35 put it this way: shared words pull raw scores inward.
Wordscores assumptions and scope
- Reference scores: measure the concept we want.
- Comparable language: words signal positions in similar ways.
- Coverage: new texts contain enough scored words.
- Transferability: word–position links extend to new texts.
The model interpretation on slide 14 cites Will Lowe (2008), “Understanding Wordscores,” Political Analysis 16(4): 356–371.
Are election manifestos suitable references for "parliamentary interjections"? (Hint (supplement): different genre, different length, different vocabulary—the "comparable language" and "transferability" assumptions are the most likely to break.)
Self-check
smooth = 0). It will…smooth = 0 only reference vocabulary receives scores, and coverage is the share of words retained.Laver, Benoit & Garry (2003): reading estimated changes
The classic Wordscores application: use the 1992 British party manifestos (with expert scores) as references to estimate the economic policy positions of the 1997 manifestos. Slides 16–19 walk you through the original Figure 1 (p. 314) in four steps.
Research question and design
- Question: How do texts place parties on policy dimensions?
- References: British 1992 party manifestos and expert scores.
- New texts: each party's 1997 manifesto.
Reading Figure 1 in four steps: reference texts → words → new texts
| Step | Content |
|---|---|
| 1 · 1992 reference scores | Labour 5.35; Liberal Democrats 8.21; Conservatives 17.21. Economic policy: lower = public services, higher = tax cuts. |
| 2 · From texts to words | Learn word scores from the 1992 references; then combine them using word proportions in each 1997 manifesto. |
| 3 · 1997 positions | Labour 9.17; Liberal Democrats 5.00; Conservatives 17.18. Labour and the Liberal Democrats swap order. |
| 4 · Read the note | Values are transformed; standard errors are in parentheses; compare ordering, be cautious about distances. |
Scale: lower = public services, higher = tax cuts (slide 16). The numbers are the original transformed values; the chart only plots points and does not mean distances can be read directly.
Why is "ordering" more reliable than "distance"?
Raw Wordscores scores are pulled toward the centre by shared words (the toy in Ch. 2), so LBG 2003 transform the new-text scores so that their spread is close to that of the references. The transformation changes the size of distances but not the ordering; and the transformation itself depends on the choice of references. Hence slide 19's advice: compare ordering, be cautious about distances. Ch. 11 also shows what R's rescaling = "lbg" does to the distances of the same scores.
Claim-judgement practice
Based on slides 16–19, decide whether each statement "can be claimed" or "cannot be claimed".
Self-check
Wordfish: positions without reference scores
When no credible position labels exist, Wordfish estimates a latent dimension directly from regularities in word counts: after accounting for document length and each word's baseline frequency, it looks at which words "become more or less frequent as position increases".
Situation: comparable documents, but no credible position labels
- Estimate a latent dimension from regularities in word counts.
- Account for document length and baseline word frequency.
- Interpret the dimension found using the texts and external evidence.
Example: party manifestos across several elections, or speeches in one budget debate (this week's R practice).
The model: one equation, four parameters
Course notation: i is a document (manifesto), j is a word (Slapin & Proksch 2008, AJPS, p. 709).
| Symbol | Meaning (slides) | In plain words (supplement) |
|---|---|---|
| yij | Observed word count | How many times word j appears in document i |
| μij | Expected word count | How many times the model expects it to appear |
| αi | Document baseline (partly length) | A long speech has more of every word |
| ψj | Word baseline (overall frequency) | the is frequent in every document |
| θi | Manifesto (document) position | The number we want |
| βj | Word weight (log scale) | How much the word's log expected count changes per 1-unit increase in θ |
Slides 24, 26: no reference scores are supplied; all parameters are fit jointly across elections.
How do expected counts change with position?
Fix a document's α, adjust a word's ψ and β, and see how μ = exp(α + ψ + βθ) changes along θ ∈ [−2, 2]. A word with β = 0 (like und) is equally frequent at any position; the larger |β|, the better the word separates the two ends.
Toy: generate data from known positions, then let Wordfish recover them
Set the "true" positions θ of 8 documents and β for 40 words, sample counts from the Poisson model on slide 24, then estimate θ with alternating Poisson iterations (a simplified version, not quanteda's implementation). Raise document length to see estimates stabilise; lower the share of "discriminating words" to see them get noisy.
Multiply all θ and β by −1 at the same time and log μ is completely unchanged—the model itself cannot tell left from right. That is why R uses dir to specify "which document is to the left of which" (Ch. 12, S05a). Moreover, the estimated θ is usually normalised to mean 0 and standard deviation 1, so it is a relative position, not fixed ±1 endpoints (slide 111). (The "multiplying by −1 changes nothing" point and the normalisation remark are supplementary.)
Wordfish's assumptions about word counts
- Count model: word counts follow conditionally independent Poisson distributions.
- One dimension: after accounting for document and word baselines, one document position helps explain word use.
- Political interpretation: the dimension must track the concept we care about.
Changing topics, speaking roles, genre, and changes in historical vocabulary—any of these may become the "main dimension" Wordfish finds, instead of the political position you want.
Self-check
Slapin & Proksch (2008), reading the word plot, comparing the two methods
The original Wordfish paper estimates positions over time from German party manifestos, 1990–2005. This chapter reads two figures from the article, then draws the same word plot with the real β and ψ from this week's Irish data.
Research design
- Question: How do party positions change over time?
- Texts: German party manifestos, 1990–2005.
- Evidence: estimated positions and politically discriminating words.
Figure 1: German party positions across elections
- Compare parties within each panel; panels A and B use different policy scopes.
- Slide 29 highlights SPD's trajectory, 1990–2002.
- A common time scale requires comparable word use.
Original AJPS Figure 1, p. 714; the slide crops panels A–B out of four.
Figure 2: reading the word plot
- Read across, then up.
- x: word weight β. The farther from 0, the stronger the discrimination.
- y: word fixed effect ψ. Higher means more common baseline use.
- Top centre: und ("and") is common but has little weight.
- Lower sides: discriminating words, to be read back in context.
Original AJPS Figure 2, p. 715. (Supplement: this shape is often called the "Eiffel Tower plot".)
The same plot, drawn with this week's Irish data
wf$beta, wf$psi from the local S05a fitEach point is a word. Type a word to search, or click the plot to select the nearest word. Orange marks the 6 probe words from S05c (budget, government, tax, jobs, fair, recovery). Direction is set by dir: words with β > 0 are more frequent in speeches with higher θ (the Lenihan/Cowen end).
Slide 115: psi is not raw frequency; a positive beta is not positive sentiment. Points with very large |β| are often rare words that appear in only one or two speeches (very low ψ); go back and read the original text (speech browser in Ch. 10) before drawing conclusions. (The second sentence is supplementary.)
Wordscores and Wordfish: strengths and limits
| Aspect | Wordscores | Wordfish |
|---|---|---|
| Strength | Scores new texts using reference positions | Estimates positions without supplied position scores |
| Assumptions | Credible reference positions; comparable language; shared word–position links | One common dimension; conditionally independent Poisson counts; shared word effects |
| Limits | Reference choice matters; unseen words lack scores; shared words pull raw scores inward | Topics or roles may drive the scale; small standard errors do not establish validity |
Self-check
Lowe & Benoit (2013): human judgement reveals model failure
With the same 14 budget speeches, Lowe & Benoit use human judgements of budget support as a benchmark to check Wordfish. Most positions roughly agree, but Sinn Féin's strong opposition looks too moderate in Wordfish—this is why this week keeps stressing "read the texts".
Research design
- Texts: 14 speeches on the 2010 Irish budget.
- Debate: December 2009.
- Benchmark: human judgements of budget support.
Human judgement revealed a model failure
- Many positions roughly agree.
- Sinn Féin: strong opposition looks too moderate in Wordfish (marked with a red arrow on slide 38).
- A second political distinction complicates "one dimension".
Original authors' manuscript Figure 3, p. 32; for background on the dimensionality issue see Benoit (2018), p. 63. Slide 39 also marks the grey agreement line.
The θ of the two Sinn Féin TDs, Morgan and Ó Caoláin, are −0.093 and −0.098, in the middle of the 14 speeches—closer to the government end than Labour's Burton (−1.150), Higgins (−0.979), and Quinn (−0.921). This only describes this week's scores; Lowe & Benoit's human judgement values are not in the repo, so these notes cannot redo their comparison.
Blind-reading practice: without party labels, which passage supports the budget?
“We have sought to do all of this in a manner that is fair and that protects the most vulnerable.”
“This is a jobless and a joyless budget.”
Reveal the speakers (slide 41)
Text A: Brian Lenihan (supports the budget) · Fianna Fáil · Minister for Finance. Text B: Richard Bruton (opposes the budget) · Fine Gael · opposition finance spokesperson.
Interpretation: budget support, policy preferences, and government responsibility may overlap in these speeches. Local check: with quanteda 4.5.1 sentence segmentation, these two sentences are still Lenihan's 7th sentence and Bruton's 6th sentence respectively (slide 41 used quanteda 4.3.1).
Draw a random sentence (12–45 words), judge it first, then reveal the speaker and party. Background (supplement, not from the lecture): in December 2009 the governing coalition was Fianna Fáil (FF) and the Green Party; FG, Labour (LAB), and Sinn Féin (SF) were in opposition. Many sentences have no stance on their own—that is exactly the point.
Budget support and speaking roles
Lenihan is the Minister for Finance and Bruton the opposition finance spokesperson: the differences in their words reflect both their stance on the budget and their role in the debate (presenting policy vs. criticising policy). When Wordscores uses these two speeches as references, the word scores it learns mix both kinds of difference.
Gormley: one speaker, two roles
A fuller speech example from Benoit's lecture notes: the Green Party leader is also a government minister.
- “As leader of the Green Party …” → the speaker states his party's position on the budget.
- “I will now comment on some specific aspects of my Department’s Estimate.” → the speaker turns to departmental business.
Discussion: which passages should be included in a measure of "budget support"? (Note on slide 42: the text range in the lecture notes differs from the class corpus.)
Self-check
Wordshoal: speaker positions across debates
Legislators talk about different issues in different debates. Wordshoal first runs Wordfish within each debate, then links the positions from each debate into one common scale through legislators who appear repeatedly—a shoal is "a group of fish".
Situation: speakers spread across different debates
- First compare speakers within each debate.
- Estimate a Wordfish position for each speaker in that debate.
- Link the debate positions through legislators who appear across debates.
Goal: a common summary of expressed positions across debates.
A shoal of Wordfish: two stages
Stage 1: run Wordfish once in each debate; Stage 2: the same speakers (A, B, C) link the results of each debate; Output: common speaker positions.
Course schematic; the name comes from Lauderdale & Herzog (2016), p. 374 n. 1; the two stages pp. 377–378. The fish illustration on slide 49 was generated by OpenAI.
Cross-debate assumptions
- Within debates: differences in word use carry information about relative positions.
- Across debates: some position differences reflect one common dimension.
- Overlap: repeated participants link the debates.
- Participation: selective speaking limits what the observed positions represent.
Linking debate positions: the second stage
| Quantity | Meaning |
|---|---|
| zij | Stage 1: speaker i's Wordfish position in debate j |
| θi | The speaker's common position |
| bj | Direction and strength of the debate's link to the common dimension |
| Missing zij | The legislator did not speak in that debate |
Teaching notation (Lauderdale & Herzog 2016, §3.2); the original second-stage model also specifies speaker precision and priors. Debate scales may link with different signs and strengths.
Align debate scales first
Two debates encode the same ordering with opposite signs. Simply averaging makes all three people 0; align directions with bj first and then average, and the ordering comes back. Try adjusting debate B's loading bB.
Why does a negative debate loading not necessarily mean there is no common structure? (Hint: the negative sign only means that debate's Wordfish direction is opposite to the common dimension; |bj| is the strength of the link.)
Lauderdale & Herzog (2016): parliamentary speech
- Question: How can debates yield legislator-level positions?
- Data: the 29th and 30th Irish Dáil; the 104th–113th US Senate.
- Two interpretations for the Irish Dáil (Figure 1 a–b): the main dimension tracks government/opposition (coalition status); left–right needs its own evidence.
| 30th Dáil, individual legislators | Correlation r with government status | Reading |
|---|---|---|
| Wordfish | 0.31 | Government and opposition scores overlap |
| Wordshoal | 0.94 | Much clearer separation in this Dáil |
Slides 59–60: original Figure 2, p. 382, interpretation on p. 383; the lower panel shows positions with 95% intervals.
Debate structure and research scope
| Speaker | Budget | Health | Foreign affairs |
|---|---|---|---|
| A | Speaks | Speaks | — |
| B | Speaks | — | Speaks |
| C | — | Speaks | Speaks |
Shared speakers link different debates. A single budget debate provides no cross-debate structure (which is why this week's R practice does not run Wordshoal); disconnected groups of speakers need additional identifying information. (The participation table on slide 61 is a course schematic.)
Self-check
Latent Semantic Scaling: seed words and a geopolitical threat index
When you can name the two ends of a concept but have almost no labelled documents, LSS defines a direction with a few seed words, learns the polarity of other words from co-occurrence in the corpus, and aggregates them to documents.
Situation: you can name the two ends, but few documents are labelled
- Supply words that express the two ends of the concept.
- Learn semantic relations from a relevant corpus.
- Score words by their proximity to the seeds, then score documents.
enemy, foe, hostile
ally, friend, peaceful
Seed examples from Trubowitz & Watanabe (2021), ISQ; the slide omits plural forms and other seeds. Method: Watanabe (2021), “Latent Semantic Scaling”.
Assumptions about meaning and context
- Seeds: these words express the intended two ends in this domain.
- Semantics: co-occurrence regularities contain useful information about this distinction.
- Aggregation: word scores give a meaningful summary at the document level.
- Target: the polarity relates to the actor or issue we want to measure.
Could a negative news story describe an ally sympathetically? (Hint (supplement): "our ally was attacked by the enemy" contains both ally and enemy; the document's polarity is not necessarily the attitude toward this ally. That is the "target" assumption.)
Four steps
| Step | Information used |
|---|---|
| Define the two ends | Concept-specific seed words and polarity |
| Estimate semantic relations | Word co-occurrence, usually across sentences |
| Score words | Similarity to seed words in a reduced semantic space |
| Score documents | Frequency-weighted average of word scores |
From vectors to word polarity
Use singular value decomposition (SVD) to reduce sentence–word counts to k dimensions:
| Quantity | Meaning |
|---|---|
| vj | Word vector learned from sentence contexts |
| ps | Researcher-assigned polarity of seed s, e.g., −1 or +1 |
| gj | Word polarity: similarity weighted by seed polarity |
Document scores then average the word polarities weighted by token frequency (Watanabe 2021, Eqs. 1–2).
Toy: trying seed words on the 14 budget speeches
Local R split the 14 speeches into 2,484 sentences (removing punctuation, numbers, and English stopwords, keeping only the 695 words with total count ≥ 8, leaving 2,432 non-empty sentences), applied TF-IDF, took 40 dimensions with SVD, normalised the vectors, and exported them here. The browser computes gj with the formula on slide 81, then averages by each speech's word frequencies to get document scores. This is not LSX's textmodel_lss() (the corpus is too small and no seed evaluation was done); it is only for getting a feel for "changing seeds, changing direction". The two default seed sets are a deliberately vague "recovery/crisis" framing chosen for these notes, not a validated measure of budget support.
Trubowitz & Watanabe (2021): the geopolitical threat index
- Texts: New York Times news summaries, 1861–2017.
- Models: Newsmap and LSS.
- Target: hostile foreign military behaviour in the reports.
- Figure 2 (learned word polarity): seeds specify hostility (slide 65 marks two groups of words on the figure, Armies and Friends); countries and relevant reports need to be identified separately; GTI aggregates the proportion of hostile military reports.
GTI is a proportion, distinct from a mean polarity score.
Validation depends on the level of analysis
| Level | Result |
|---|---|
| By decade | r = 0.82 |
| By country | r = 0.94 |
| Individual summaries | About 59% agreement |
Self-check
Validation: external benchmarks, anchors, and robustness
W6 evaluated classification with held-out human labels and F1; for W7's scaling the question is: do the estimated positions agree with external measures? Which surprising positions are worth going back to read?
From W6 evaluation to W7 validation
| Question | W6 classification practice | W7 scaling |
|---|---|---|
| What is evaluated? | Predicted categories | Positions on a specified dimension |
| What is the evidence? | Held-out human labels; F1 | External measures; rank agreement |
| What do we read? | Errors and coding boundaries | Surprising positions and their language |
Hjorth et al. test convergence between different measures, which is different from k-fold cross-validation.
Hjorth et al. (2015): validating party positions
- Question: Do text scales agree with other measures of party positions? Compares Wordscores and Wordfish.
- Scope: 254 manifestos from 33 elections.
| Country | Elections | Manifestos | Mean words |
|---|---|---|---|
| Denmark, 1945–2007 | 24 | 212 | 1,232 |
| Germany, 1980–2009 | 9 | 42 | 10,306 |
Three benchmarks: experts (published assessments of party positions), voters (mean left–right self-placement of each party's supporters), and CMP RILE (a left–right index from hand-coded manifestos). Assumption to check: do these benchmarks target the same political dimension?
Validation results differ between the two countries: Table 3
| Country | Method | CMP | Experts | Voters |
|---|---|---|---|---|
| Denmark | Wordscores | 0.7 | 0.8 | 0.8 |
| Denmark | Wordfish | 0.2 | 0.2 | 0.1 |
| Germany | Wordscores | 0.8 | 0.8 | 0.8 |
| Germany | Wordfish | 0.8 | 0.7 | 0.7 |
These are not classification accuracies. Rank agreement supports an ordering but does not establish meaningful distances.
Why did Wordfish do better in Germany?
| Explanation | What the authors report |
|---|---|
| Text length: tested | Randomly shortening German manifestos to a Danish-like average length removed about half of Germany's Wordfish advantage. |
| Political language: inferred | The shortened German texts still did better; the authors attribute the remaining advantage to more ideologically polarised language. |
This is the authors' rough attribution; language was not tested separately. (p. 4; discussion pp. 5–6; detailed shortening results are in the authors' online appendix.)
Robustness and uncertainty
- Sensitivity: swap references or seeds, change the text scope, compare reasonable preprocessing choices.
- Uncertainty: distinguish model intervals, human disagreement, and variation across settings.
- Evaluation: keep judgements that were not used in the choices above.
After removing English stopwords from the count matrix (4,885 → 4,766 words) and refitting Wordfish: Pearson correlation of θ with the original 0.984, Spearman 0.978. The overall ordering is very close, but individual speeches move—for example, Morgan goes from −0.093 to 0.078 (crossing 0).
Which choice would you change first? What evidence would you keep?
Your research abstract: validation plan builder
Research topic and abstract: due 23:59 on 23 October 2026 (slide 89; deadline as announced in W6). Use the five questions to write a scaling/measurement validation plan for your topic:
Self-check
S01–S03: corpus, count matrix, and reference design
Goal of the R practice: support for the 2010 Irish budget. Fit Wordscores and Wordfish to the same 14 speeches, compare the orderings, read the largest disagreements closely, and swap one reference to assess sensitivity (slide 91). Work in pairs and run S01–S08b in order in the same R session (including lettered sub-steps, 19 checkpoints in total).
R tools
| Task | Package | Main interface |
|---|---|---|
| Prepare texts and counts | quanteda | corpus, tokens, DFM |
| Reference-based scaling | quanteda.textmodels | textmodel_wordscores() |
| Latent count scaling | quanteda.textmodels | textmodel_wordfish() |
| Plot estimated positions | quanteda.textplots | textplot_scale1d() |
| Cross-debate scaling | wordshoal | textmodel_wordshoal() |
| Semantic scaling | LSX | textmodel_lss() |
This week's R practice uses only the first four rows. wordshoal and LSX are not installed locally; the LSS toy in Ch. 8 is a simplified demo built with base R SVD.
About the local run
The unmodified W7/classroom/W7_scaling.R was run locally (Linux aarch64) with R 4.5.3 (aarch64-conda-linux-gnu), quanteda 4.5.1, quanteda.textmodels 0.9.10, quanteda.textplots 0.96.1, ggplot2 4.0.3 using source(echo = TRUE); the full output is saved in tad/labs/W7/run_output.txt. The slides used quanteda 4.3.1, quanteda.textmodels 0.9.10, quanteda.textplots 0.96.1, and ggplot2 4.0.2 (classroom README).
Every number on slides 93–129 was checked one by one: all match except the quanteda version string in S01 (4.3.1 vs. 4.5.1), including the S04b coverage summary, the 14 raw scores in S04c, the 14 θ and se pairs in S05b, the Spearman 0.734 in S06a, and the rank changes in S08b. The code of Lab_Session_W7.R is the same as the classroom script (differing only in suppressPackageStartupMessages() wrapping library() and one comment line).
S01: packages and the built-in corpus
# S01: Packages and the built-in corpus
# install.packages(c("quanteda", "quanteda.textmodels",
# "quanteda.textplots"))
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)> library(quanteda)
Package version: 4.5.1
Unicode version: 17.0
ICU version: 78.3
Parallel computing: 2 of 2 threads used.
See https://quanteda.io for tutorials and examples.
> 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")))
quanteda textmodels textplots
"4.5.1" "0.9.10" "0.96.1"
> ndoc(corp_irish)
[1] 14The built-in corpus has 14 speeches, each one document. The version string lets you trace differences between runs; [1] marks the first printed value (slide 93). The local version is quanteda 4.5.1 and the slides use 4.3.1, but all later numbers are identical.
S02a: speakers and stable document IDs
# 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)> 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 SFThe IDs come from speech numbers, so after sorting each score can still be traced back to the right text. speaker and party describe the speeches; neither model uses the party field to fit positions (slide 95).
Speech browser (full text)
data_corpus_irishbudget2010, segmented into numbered sentences with quanteda 4.5.1Sentence numbers depend on the sentence-segmentation rules of the quanteda version (slide 41 notes 4.3.1 segmentation); under local 4.5.1, Burton's sentences 1 and 5–7 selected in S07 are the same as on slides 123 and 125.
S02b: build one working set of tokens
# 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)
> 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"
These 12 words keep their order in the speech, because this only previews tokens and nothing is counted yet. [1], [5], [9] mark token positions, not frequencies. Lower case and the absence of punctuation come from cleaning choices; the later matrix also removes word order (slide 97). The original corpus is kept for reading.
S02c: build the shared count matrix
# S02c: Build the common count matrix counts <- dfm(toks_irish) dim(counts) any(ntoken(counts) == 0) topfeatures(counts, 6)
> counts <- dfm(toks_irish) > dim(counts) [1] 14 4885 > any(ntoken(counts) == 0) [1] FALSE > topfeatures(counts, 6) the to of and in a 3598 1633 1537 1359 1231 1013
14 4885: 14 speeches and their combined vocabulary; cells are word counts. FALSE confirms that every speech still has words after cleaning. Because stopwords were kept, the is still the most common word (3,598 times)—occurrences alone cannot distinguish political positions. Both methods start from these counts, with no TF-IDF weighting and no stemming or trimming (slide 98; classroom README).
S03: define the Wordscores references
# 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)> 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 -1Lenihan is assigned +1 because he defends the budget; Bruton is assigned −1 because he criticises it. These inputs set the expected direction; the other 12 speeches stay NA because we did not supply their positions (slide 101).
Self-check
dim(counts) in S02c returns 14 4885. What is 4885?NA. This means…S04a–S04d: Wordscores
Learn word scores from two references, align the scoring vocabulary and compute coverage, predict a raw score for every speech, and finally plot positions with intervals. This chapter's interactive lab recomputes Wordscores in the browser from the same count matrix, so you can swap the references yourself.
S04a: fit Wordscores and read the word scores
# 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)> 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.403tax scores +0.665 because it is relatively more frequent in Lenihan's positive reference; fair scores −0.229 because it is relatively more frequent in Bruton's negative reference. Scores follow how the references use the words, so general positive or negative sentiment does not determine their signs (slide 103). smooth = 0: a word must appear in the reference vocabulary to receive a score (slide 102).
S04b: align the scoring vocabulary and check coverage
# 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)
> ws_counts <- dfm_match(counts, features = names(coef(ws))) > ws_coverage <- ntoken(ws_counts) / ntoken(counts) > dim(ws_counts) [1] 14 2131 > summary(ws_coverage) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.836 0.850 0.874 0.886 0.887 1.000
Of the 4,885 words, only 2,131 appear in the references and receive scores; all 14 speeches remain. Coverage is 83.6%–100%, median 87.4%. Repeated occurrences count toward coverage; this measures the language retained, not prediction accuracy (slide 105). (Supplement: which speech is the 100% one? You can see it in the "coverage" column of the lab below—of course every word of a reference text has a score.)
S04c: predict a raw score for each speech
# 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)
> 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.026The assigned +1 and −1 are used to teach the word scores; rescoring averages those word scores, giving Lenihan +0.339 and Bruton −0.339. Shared vocabulary pulls raw averages toward the centre. The reference column records the assigned inputs; ws_raw is the prediction (slides 106–107).
S04d: plot raw Wordscores positions
# 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)
The reference points sit near +0.339 and −0.339—rescored word averages, not the assigned endpoints. Burton being close to 0 reflects the average of word scores and does not mean she is neutral on the budget. The bars show about 95% uncertainty under the scoring method; reference-choice uncertainty is excluded (slide 109).
Wordscores lab: choose your own references
smooth = 0, rescaling = "none"Choose +1, −1, or "new text" for each speech and press "Compute". The algorithm is the same as the three formulas in Ch. 2, and the results match R (the class setting is checked automatically on load; the error is shown below). Try: the S08 Cowen setting, setting the two Sinn Féin speeches to −1, or using only the Green Party as the positive reference.
Supplement: hand-computed check and rescaling (not from the lecture)
The two blocks below are extra R runs added for these notes (not in the class script), using objects from the same session.
# X2: Recompute Wordscores by hand (smooth = 0, raw)
ref_m <- as.matrix(counts[ref_ids, ])
F_wr <- ref_m / rowSums(ref_m)
keep <- colSums(F_wr) > 0
P_wr <- sweep(F_wr[, keep], 2, colSums(F_wr[, keep]), "/")
S_w <- colSums(P_wr * c(1, -1))
cat("scored words:", length(S_w), "\n")
cat("max |manual - coef(ws)|:", max(abs(S_w - coef(ws)[names(S_w)])), "\n")
all_m <- as.matrix(counts[, names(S_w)])
manual_doc <- as.numeric((all_m / rowSums(all_m)) %*% S_w)
cat("max |manual doc score - ws_raw|:", max(abs(manual_doc - as.numeric(ws_pred))), "\n")> ref_m <- as.matrix(counts[ref_ids, ])
> F_wr <- ref_m / rowSums(ref_m)
> keep <- colSums(F_wr) > 0
> P_wr <- sweep(F_wr[, keep], 2, colSums(F_wr[, keep]), "/")
> S_w <- colSums(P_wr * c(1, -1))
> cat("scored words:", length(S_w), "\n")
scored words: 2131
> cat("max |manual - coef(ws)|:", max(abs(S_w - coef(ws)[names(S_w)])), "\n")
max |manual - coef(ws)|: 0
> all_m <- as.matrix(counts[, names(S_w)])
> manual_doc <- as.numeric((all_m / rowSums(all_m)) %*% S_w)
> cat("max |manual doc score - ws_raw|:", max(abs(manual_doc - as.numeric(ws_pred))), "\n")
max |manual doc score - ws_raw|: 5.662e-15 The hand computation matches textmodel_wordscores() exactly, so the three formulas in Ch. 2 are the computation used in class.
# X1: Rescaled Wordscores (LBG and MV) for comparison with raw scores ws_lbg <- predict(ws, newdata = ws_counts, rescaling = "lbg") ws_mv <- predict(ws, newdata = ws_counts, rescaling = "mv") print(data.frame(speaker = meta$speaker, raw = round(as.numeric(ws_pred), 3), lbg = round(as.numeric(ws_lbg), 3), mv = round(as.numeric(ws_mv), 3)), row.names = FALSE)
> ws_lbg <- predict(ws, newdata = ws_counts, rescaling = "lbg")
> ws_mv <- predict(ws, newdata = ws_counts, rescaling = "mv")
> print(data.frame(speaker = meta$speaker, raw = round(as.numeric(ws_pred), 3),
+ lbg = round(as.numeric(ws_lbg), 3), mv = round(as.numeric(ws_mv), 3)), row.names = FALSE)
speaker raw lbg mv
Lenihan 0.339 3.068 1.000
Bruton -0.339 -3.376 -1.000
Burton -0.001 -0.160 -0.002
Morgan 0.023 0.060 0.067
Cowen 0.180 1.556 0.531
Kenny -0.020 -0.340 -0.058
ODonnell -0.029 -0.432 -0.086
Gilmore -0.012 -0.273 -0.037
Higgins -0.040 -0.537 -0.119
Quinn -0.023 -0.372 -0.067
Gormley 0.159 1.357 0.469
Ryan -0.012 -0.271 -0.036
Cuffe 0.003 -0.123 0.010
OCaolain 0.026 0.097 0.078lbg spreads the scores out following the LBG (2003) transformation (Lenihan 3.068, Bruton −3.376), and mv fixes the two references at ±1. The ordering of the three columns is the same, but the distances are completely different—echoing Ch. 3's "compare ordering, be cautious about distances". Class uses rescaling = "none" (slide 130 also asks you to report raw/rescaled scores).
Claim-judgement practice
Self-check
ws_raw only 0.339?S05a–S05d: Wordfish
The same count matrix, no position scores—only dir to specify that Bruton is to the left of Lenihan. Read θ and its standard errors, read the words' β and ψ, then plot the positions.
S05a: fit Wordfish and fix the direction
# 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))> 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.775Bruton (−0.585) is below Lenihan (1.775) because dir chose this order. Positions are estimated from the counts, not fixed at ±1; and the direction itself does not establish the meaning of budget support (slide 111). dir uses stable IDs to find the document indices (slide 110).
S05b: read positions and model standard errors
# 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)
> 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.039Burton θ = −1.150, se = 0.016; Gormley's se = 0.075 is larger. Burton's smaller standard error gives a narrower model interval, but does not prove the scale measures budget support (slide 113). (Supplement: you can compare the processed token counts of each speech in the Ch. 10 browser to see how se relates to speech length; se also depends on other parts of the model, not only length.)
Positions and intervals (interactive)
S05c: word discrimination and baseline frequency
# 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_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.897The ψ of budget (2.711) describes baseline commonness; its very small β (0.042) means it barely changes along θ. The β of jobs (0.505) means a larger change in log expected count per unit increase in θ, with other effects fixed. ψ is not raw frequency; a positive β is not positive sentiment (slide 115). See the Ch. 5 word plot for the β/ψ of all 4,885 words.
S05d: plot Wordfish positions
# 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)
Cowen (1.794) and Lenihan (1.775) lie to the right of Burton (−1.150) on the θ axis. The approximately 95% bars use θ ± 1.96 × se; the smaller the standard error, the narrower the interval. The intervals describe model uncertainty and do not establish the meaning of budget support (slide 117).
Supplement: preprocessing sensitivity (not from the lecture)
# X3: Wordfish sensitivity to removing English stopwords (one alternative preprocessing)
counts_ns <- dfm_remove(counts, stopwords("en"))
set.seed(7197)
wf_ns <- textmodel_wordfish(counts_ns, dir = wf_dir, dispersion = "poisson")
dim(counts_ns)
round(cor(wf$theta, wf_ns$theta), 3)
round(cor(wf$theta, wf_ns$theta, method = "spearman"), 3)
print(data.frame(speaker = meta$speaker, theta = round(wf$theta, 3),
theta_nostop = round(wf_ns$theta, 3)), row.names = FALSE)> counts_ns <- dfm_remove(counts, stopwords("en"))
> set.seed(7197)
> wf_ns <- textmodel_wordfish(counts_ns, dir = wf_dir, dispersion = "poisson")
> dim(counts_ns)
[1] 14 4766
> round(cor(wf$theta, wf_ns$theta), 3)
[1] 0.984
> round(cor(wf$theta, wf_ns$theta, method = "spearman"), 3)
[1] 0.978
> print(data.frame(speaker = meta$speaker, theta = round(wf$theta, 3),
+ theta_nostop = round(wf_ns$theta, 3)), row.names = FALSE)
speaker theta theta_nostop
Lenihan 1.775 1.717
Bruton -0.585 -0.437
Burton -1.150 -0.996
Morgan -0.093 0.078
Cowen 1.794 1.925
Kenny -0.789 -0.812
ODonnell -0.493 -0.307
Gilmore -0.587 -0.375
Higgins -0.979 -1.203
Quinn -0.921 -1.235
Gormley 1.122 0.969
Ryan 0.212 0.156
Cuffe 0.793 0.570
OCaolain -0.098 -0.050Removing quanteda's English stopwords drops only 119 distinct words (4,885 → 4,766). The overall ordering is similar (Spearman 0.978), but individual speeches still move. This corresponds to "compare reasonable preprocessing choices" on slide 88.
Supplement: running a simplified Wordfish in the browser
Keep only the N words with the highest total counts from the 14 × 4,885 counts, estimate θ in the browser (priors mimic quanteda's defaults: standard deviation 3 for β and 1 for θ; no priors on α, ψ), fix the direction with Bruton < Lenihan, and compare with R's θ. Local node test (60 iterations): with all 4,885 words, Pearson 0.999 and Spearman 0.996 with R's θ; with only the top 500 words, Pearson 0.955 and Spearman 0.815. The smaller N, the more the model relies only on function words and common words.
Self-check
dir = wf_dir in S05a do?S06–S08: compare orderings, read disagreements closely, swap references
How consistently do the two models order the 12 new texts? Who is the largest disagreement? Go back to the text and read what she said. Finally, swap the positive reference and see how the ordering moves.
S06a: compare the orderings of the 12 new texts
# 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)> 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)
[1] 0.734
> print(head(comparison[c("speaker", "ws_rank", "wf_rank", "gap")], 6),
+ row.names = FALSE)
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 1The two Wordscores references are excluded. After fixing a common direction, rank 1 is the low end of each scale. ws_rank = 7, wf_rank = 1: Burton's absolute gap is 6. Spearman 0.734 summarises the overall agreement of the 12 texts: overall agreement can coexist with one large disagreement, and it is not accuracy (slides 118–119). (Supplement: including the two references, the Spearman over 14 speeches is 0.741; see X4 below.)
# X4: Spearman between Wordscores and Wordfish on all fourteen speeches round(cor(results$ws_raw, results$wf_theta, method = "spearman"), 3)
> round(cor(results$ws_raw, results$wf_theta, method = "spearman"), 3) [1] 0.741
S06b: plot the new texts on both scales
# 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)
Burton is near 0 on Wordscores but very low on Wordfish: rank 7 vs. 1. Wordscores uses two reference speeches; Wordfish fits word-count regularities across all speeches. The two axes have different units. Before treating near 0 as neutral, read her argument (slide 121).
Two scales (interactive)
Click a point (or a row in the table below) to see that speech's two ranks and the gap. The browser recomputes with the same rank() and Spearman and should get 0.734.
S07a–S07b: read the speech with the largest ranking disagreement
# 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")> read_id <- comparison$doc_id[1]
> print(comparison[1, c("doc_id", "speaker", "ws_rank", "wf_rank")],
+ row.names = FALSE)
doc_id speaker ws_rank wf_rank
ie_03 Burton 7 1
> read_sentences <- as.character(corpus_reshape(
+ corp_irish[read_id], to = "sentences"))
> cat(strwrap(read_sentences[1], width = 66), sep = "\n")
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.Burton is selected because her two model ranks differ the most: Wordscores 7, Wordfish 1. The opening "consensus" claim comes from a Goldman Sachs report she is reporting, so it does not signal her agreement (slide 123).
# 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") # For the full speech in your console: # cat(as.character(corp_irish[read_id]))
> cat(strwrap(paste(read_sentences[5:7], collapse = " "), + width = 66), sep = "\n") 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.
A "consensus budget" is something Burton says the Minister failed to deliver; she is criticising burden sharing. Words such as consensus appear inside criticism, so a score near 0 does not necessarily mean moderate support (slide 125). The full speech can be read by choosing "Burton" in the speech browser in Ch. 10.
In the local data, among the words with the smallest (most negative) Wordfish β, sharing, medicine, gang (5 times each), bailout (4 times), and consensus (3 times) appear only in Burton's speech (click them in the Ch. 5 word plot to see). These words are not in Lenihan's or Bruton's references, so they have no score in Wordscores (smooth = 0); Wordfish, however, uses them to estimate θ. This is a mechanism clue worth checking, not a validated explanation—the next step is still reading the text and independent judgement.
Close-reading answer box
Suggested reasoning (based on slides 121–125, 130)
1. It is the Goldman Sachs report's claim, which she is only reporting; the following text shows she thinks consensus was not achieved (slides 123, 125).
2. Open question. You can look up the scores of words like consensus, budget, government in the Ch. 11 lab, then compare how they are used in the sentences.
3. Open question. Slide 121: after reading her argument, do not treat near 0 as neutral; but a single sentence is not enough to decide—read more passages and get independent judgement.
4. Open question. For example, ask readers who were not involved in modelling to judge each speech's budget support without seeing party labels, then compare with the two models' orderings (slide 88: keep judgements that were not used in the choices).
S08a–S08b: swap one positive reference
# 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)> 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 1Replace Lenihan +1 with Cowen +1; Bruton −1 stays. A different reference speech supplies different word proportions, so the word scores and scoring vocabulary change even with the same endpoints (slide 127).
# 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)> 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 -3Ryan 6→9 (+3) and Ó Caoláin 10→7 (−3) are the largest absolute changes. change = after − before; both sets of ranks are recomputed within the same 11 texts (excluding Lenihan, Bruton, and Cowen). Changing the reference language changes the learned word scores, so ranks can move without any policy change (slide 129).
Reference-swap experiment: choose any speech as +1
Bruton is fixed at −1. Choose a speech to replace Lenihan as +1, and compare the rank changes between "Lenihan +1" and "new reference +1" among the common new texts (excluding Lenihan, Bruton, and the new reference). Choosing Cowen should reproduce S08b.
R checklist (19 checkpoints)
The README states that the 19 checkpoint IDs match the class script W7_scaling.R. Tick each step after you run it:
Self-check
Reading guide, common pitfalls, and glossary
The studies cited in this week's slides are summarised as cards. The repo contains no full text of any W7 paper (W7/ has no papers folder, and the student-source archive only has slides and labs), so the cards below are based only on the slides, and page numbers are the original-article pages shown on the slides; to read the full texts, download them through the library or VPN (the slides mark Hjorth et al. 2015 as CC BY-NC 3.0 open access).
Reading cards
Laver & Benoit (2002). Locating TDs in Policy Spaces: Wordscoring Dáil Speeches. Irish Political Studies 17(1): 59–73.
Laver, Benoit & Garry (2003). Extracting Policy Positions from Political Texts Using Words as Data. APSR 97(2): 311–331.
Lowe (2008). Understanding Wordscores. Political Analysis 16(4): 356–371.
Slapin & Proksch (2008). A Scaling Model for Estimating Time-Series Party Positions from Texts. AJPS 52(3): 705–722.
Lowe & Benoit (2013). Validating Estimates of Latent Traits from Textual Data Using Human Judgment as a Benchmark. Political Analysis 21(3): 298–313.
Lauderdale & Herzog (2016). Measuring Political Positions from Legislative Speech. Political Analysis 24(3): 374–394.
Watanabe (2021). Latent Semantic Scaling. Communication Methods and Measures 15(2): 81–102.
Trubowitz & Watanabe (2021). The Geopolitical Threat Index. ISQ 65(3): 852–865.
Hjorth, Klemmensen, Hobolt, Hansen & Kurrild-Klitgaard (2015). Computers, Coders, and Voters. Research & Politics 2(2): 1–9.
Benoit (2018). Scaling Text. Quants 3: Quantitative Text Analysis, Trinity College Dublin, March 23 (lecture notes).
Matching practice
Flip cards: three kinds of guidance and commonly misread numbers
Say the answer yourself first, then click the card to flip it.
Ten common pitfalls
Lenihan is assigned +1, with a raw prediction of 0.339; the reference points on the plot are rescored.
Burton is −0.001, but she is criticising the budget.
fair at −0.229 and a positive β are not sentiment.
ψ is the word baseline in the model after accounting for document baselines.
dir only chooses the direction.
Burton's se of 0.016 is narrow, but it does not prove the scale measures budget support.
Spearman 0.734 is rank agreement.
S08b recomputes ranks only within the 11 texts that are new texts under both designs.
The values in LBG Figure 1 are transformed; compare ordering.
GTI at aggregate levels r = 0.82 / 0.94; individual summaries about 59%.
Glossary
Final review, report checklist, and references
Check yourself with the 15-question final review, then compare against the "Reporting a text scaling analysis" checklist on slide 130.
Final review quiz
(The final review quiz needs JavaScript.)
Reporting a text scaling analysis
| Decision | What to report | Answer for this week's practice |
|---|---|---|
| Corpus and representation | Debate, speakers, preprocessing, and counts | 14 budget speeches from December 2009; punctuation/symbols/numbers removed, lower-cased; stopwords kept; count DFM 14 × 4,885 |
| Wordscores | Reference texts, assigned values, coverage, raw/rescaled scores | Lenihan +1, Bruton −1; smooth = 0; 2,131 scored words, coverage 83.6%–100%; raw scores |
| Wordfish | Direction, model settings, interpretation of θ | dir: Bruton < Lenihan; dispersion = "poisson"; set.seed(7197); θ is a relative position |
| Evaluation | Ranking disagreements, passages read, sensitivity | Spearman 0.734; Burton 7 vs. 1, read sentences 1 and 5–7; after the Cowen swap, Ryan +3, Ó Caoláin −3 |
What independent reader judgement could test our "budget support" interpretation? (You can reuse your answer to question 4 in the Ch. 13 answer box.)
Learning progress
References
Foundations of scaling
- Benoit, Kenneth. 2018. Scaling Text. Quants 3: Quantitative Text Analysis, Trinity College Dublin, March 23. (Lecture notes; pp. 3–27, 34–50, 54–55, 59–70)
- Laver, Michael, and Kenneth Benoit. 2002. “Locating TDs in Policy Spaces: Wordscoring Dáil Speeches.” Irish Political Studies 17(1): 59–73.
- Laver, Michael, Kenneth Benoit, and John Garry. 2003. “Extracting Policy Positions from Political Texts Using Words as Data.” American Political Science Review 97(2): 311–331.
- Slapin, Jonathan B., and Sven-Oliver Proksch. 2008. “A Scaling Model for Estimating Time-Series Party Positions from Texts.” American Journal of Political Science 52(3): 705–722.
- Lauderdale, Benjamin E., and Alexander Herzog. 2016. “Measuring Political Positions from Legislative Speech.” Political Analysis 24(3): 374–394.
Validation and semantic scaling
- Hjorth, Frederik, Robert Klemmensen, Sara Hobolt, Martin Ejnar Hansen, and Peter Kurrild-Klitgaard. 2015. “Computers, Coders, and Voters: Comparing Automated Methods for Estimating Party Positions.” Research & Politics 2(2): 1–9.
- Lowe, Will, and Kenneth Benoit. 2013. “Validating Estimates of Latent Traits from Textual Data Using Human Judgment as a Benchmark.” Political Analysis 21(3): 298–313.
- Watanabe, Kohei. 2021. “Latent Semantic Scaling: A Semisupervised Text Analysis Technique for New Domains and Languages.” Communication Methods and Measures 15(2): 81–102.
- Trubowitz, Peter, and Kohei Watanabe. 2021. “The Geopolitical Threat Index: A Text-Based Computational Approach to Identifying Foreign Threats.” International Studies Quarterly 65(3): 852–865.
Also cited in the slides
- Lowe, Will. 2008. “Understanding Wordscores.” Political Analysis 16(4): 356–371. (Slide 14)
- Park, Ju Yeon. 2021. The original continuous grandstanding measure (link to W6; slides 8–10).
Software
- quanteda, quanteda.textmodels (
textmodel_wordscores(),textmodel_wordfish(),data_corpus_irishbudget2010), quanteda.textplots (textplot_scale1d()); wordshoal; LSX (slides 90, 133).