⌂ Course index
🐞 Feedback
中文
Interactive features failed to initialise, so the page has switched to a static version with all chapters expanded in order; just scroll down to read. (The interactive labs, quiz grading, progress tracking, and slide panel need JavaScript; if you are previewing inside an app and see no interactivity, use "Share → Open in Safari" or open the file in a desktop browser.)
00 · Week overview

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 Slides 8–10

Slide 8 sets W6 and W7 side by side as three rows of research tasks:

Research taskLink to W6W7 question
Assign a categoryHate speech and grandstandingWhich texts belong to the same class?
Measure a degreeJulia Park's original grandstanding scores (continuous)Where is a text on a scale?
Interpret the measureRead the errors, look at external evidenceWhat makes a position meaningful?
In plain words (supplement)

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 Slide 11

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:

  1. Problems and assumptions: explain what problem each method solves and what its main assumptions are.
  2. Connect to research: link a published application to the texts it uses and its measurement target.
  3. Three kinds of "guidance": distinguish reference scores, latent positions, and seed words.
  4. Read before fitting: read the texts before fitting a model, and plan independent checks.

This week's six research cases Slide 12

No.ArticleMethodTextsTeaching link
Study 1Laver, Benoit & Garry (2003)WordscoresParty manifestosWordscores and reference positions (Ch. 2–3)
Study 2Slapin & Proksch (2008)WordfishGerman party manifestosWordfish and change over time (Ch. 4–5)
Study 6Lowe & Benoit (2013)WordfishIrish budget speechesHuman judgement and model failure (Ch. 6)
Study 3Lauderdale & Herzog (2016)WordshoalParliamentary debatesWordshoal and debate structure (Ch. 7)
Study 4Trubowitz & Watanabe (2021)LSSNews summariesLSS and geopolitical threat (Ch. 8)
Study 5Hjorth et al. (2015)Both (Wordscores + Wordfish)Danish and German manifestosExternal 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 Slides 37, 91

  • 14 speeches on the 2010 Irish budget, debated in December 2009. Loaded directly from quanteda.textmodels::data_corpus_irishbudget2010.
  • Data/irish_budget2010.csv is a copy of the same texts and metadata (columns doc_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.R locally (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

1. What is the main difference between W7 and W6?
Slide 8: assign a category vs. measure a degree. W7 still requires reading texts and external evidence to interpret positions.Slide 8
2. Which data does this week's R practice use?
Slides 37, 91. The 58 speeches from 1991 are the data of Laver & Benoit (2002), not this week's R data.Slides 37, 91
3. On slide 12, which study compares both Wordscores and Wordfish?
Study 5's method column says "Both" = Wordscores + Wordfish, comparing external benchmarks with Danish and German manifestos.Slide 12
01 · From zero

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)

Supplement (not from the lecture)

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 Slide 71

MethodGuidance supplied by the researcherRequired structureMain output
WordscoresReference document scoresComparable reference and new textsPositions of new documents
WordfishNo position labelsOne count matrixRelative document positions
WordshoalNo position labelsThe same speakers across many debatesCommon speaker positions
LSSSeed words and their polaritySemantic relations in the corpusWord and document polarity

Anchors are not independent validation Slide 87

EvidenceWhat it doesWhat remains to be checked
Wordscores reference textsDefine the learned scalePerformance on other texts
Wordfish dirChooses the directionThe meaning of the dimension
LSS seed wordsSpecify the semantic directionWhether concept and target match in context
Independent judgementChecks the expected interpretationAgreement, range covered, and scope
Parties being separated and the two models agreeing with each other are only partial evidence. Slide 87 also warns: keep the judgements used to tune a measure separate from those used for the final evaluation.

A validation workflow: five questions Slide 89

Slide 89 distils this week's research cases into five questions (the plan builder in Ch. 9 uses them). Click each step:

→ → → →
  1. Concept: what does a high score mean?
  2. Unit: which text, speaker, or period receives a score?
  3. Design: what information and structure does the method need?
  4. Assumption: which condition is most likely to fail in your data?
  5. Evidence: what independent observation could reveal that failure?

Method chooser Slides 13, 20, 44, 62, 71

🧭Method chooserPractice · based on the "Situation" on slides 13, 20, 44, 62

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).

Please answer the three questions first.

Self-check

1. Which method requires the researcher to supply "reference document scores"?
Slide 71: the guidance for Wordscores is reference document scores.Slide 71
2. What does Wordfish's dir argument supply?
Slide 87: Wordfish dir — choose an orientation; what remains to be checked is the meaning of the dimension.Slide 87
3. What is the main output of LSS?
Slide 71: LSS → word and document polarity.Slide 71
02 · Wordscores

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 Slides 4–6

Research choiceIrish Dáil study (Laver & Benoit 2002)
Political settingOctober 1991 confidence debate on the Fianna Fáil–PD government
Texts58 individual legislators' speeches in English
Measurement targetHow strongly did each speaker support or oppose the government?
Class discussion Slide 4

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 Slide 7

StepThe early parliamentary design
1. Assign reference positionsHaughey: +1; Bruton and de Rossa: −1
2. Score the vocabularyLearn word scores from these reference speeches
3. Place the other speakersCombine 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 Slide 13

  • 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)

Supplement (not from the lecture): the slides show no formulas; below they are verified by recomputing textmodel_wordscores(smooth = 0) step by step in local R

Let the assigned score of reference text r be Ar, and the relative frequency of word w in r be Fwr = countwr / total wordsr.

  1. The "conditional probability" of a word across references: Pwr = Fwr / Σr Fwr (computed only for words that appear in at least one reference).
  2. Word score: Sw = Σr Pwr · Ar.
  3. 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

🧮Toy Wordscores calculatorSupplement (not from the lecture) · 6 made-up words, 2 references, 1 new text

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.

New text raw score Sv
–
New text coverage (scored words / all words)
–
Reference A rescored on itself
–
Why isn't a rescored reference text ±1?

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 Slide 14

  • 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.

Class discussion Slide 14

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

1. In the 1991 debate of Laver & Benoit (2002), who was assigned −1?
Slide 7: Haughey +1; Bruton and de Rossa −1.Slide 7
2. A new text contains a word that appears in none of the reference texts (smooth = 0). It will…
Slides 34–35: unseen words lack scores; slides 102, 104: with smooth = 0 only reference vocabulary receives scores, and coverage is the share of words retained.Slides 35, 102, 104
3. Which of the following is not a Wordscores assumption listed on slide 14?
The Poisson count assumption belongs to Wordfish (slide 21).Slides 14, 21
03 · Study 1

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 Slide 15

  • 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 Slides 16–19

StepContent
1 · 1992 reference scores 16Labour 5.35; Liberal Democrats 8.21; Conservatives 17.21. Economic policy: lower = public services, higher = tax cuts.
2 · From texts to words 17Learn word scores from the 1992 references; then combine them using word proportions in each 1997 manifesto.
3 · 1997 positions 18Labour 9.17; Liberal Democrats 5.00; Conservatives 17.18. Labour and the Liberal Democrats swap order.
4 · Read the note 19Values are transformed; standard errors are in parentheses; compare ordering, be cautious about distances.
📊1992 → 1997 positions comparedNumbers from slides 16, 18 (original Figure 1)

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"?

Supplement (not from the lecture)

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".

Claim A: "On this economic policy dimension, Labour's estimated 1997 position lies to the right of the Liberal Democrats (toward the tax-cut end)."
1997: Labour 9.17 > LD 5.00; slide 18 says the two parties swapped order. This is a statement about ordering.Slide 18
Claim B: "Labour moved from 5.35 to 9.17, so Labour moved right by exactly 3.82 'policy units'."
The values are transformed and standard errors are in parentheses; slide 19: compare ordering; be cautious about distances.Slide 19
Claim C: "The Conservatives were 17.21 in 1992 and 17.18 in 1997, so the article proves Conservative policy did not change at all."
The scores have standard errors and are transformed; "did not change at all" is too strong an inference.Slide 19

Self-check

1. In LBG (2003) Figure 1, which party's estimated 1997 position is lowest (most toward public services)?
1997: LD 5.00, Labour 9.17, Conservatives 17.18.Slide 18
2. Where do the reference scores in LBG (2003) come from?
Slide 15: References: British 1992 manifestos and expert scores.Slide 15
3. How are the 1997 manifesto scores "combined"?
Slide 17: combine them using word proportions in each 1997 manifesto.Slide 17
04 · Wordfish

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 Slide 20

  • 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 Slides 24–26

yij ∼ Poisson(μij), log μij = αi + ψj + βj θi

Course notation: i is a document (manifesto), j is a word (Slapin & Proksch 2008, AJPS, p. 709).

SymbolMeaning (slides)In plain words (supplement)
yijObserved word countHow many times word j appears in document i
μijExpected word countHow many times the model expects it to appear
αiDocument baseline (partly length)A long speech has more of every word
ψjWord baseline (overall frequency)the is frequent in every document
θiManifesto (document) positionThe number we want
βjWord 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?

📈Expected-count curveSupplement (not from the lecture) · plugs directly into the equation on slide 24

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

🐟Mini Wordfish simulatorSupplement (not from the lecture) · simplified in-browser estimation

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.

Press "Sample and fit".
The direction is arbitrary

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 Slides 21–23

  • 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.
Possible complications Slide 21

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

1. In log μij = αi + ψj + βjθi, which parameter mainly absorbs "document length"?
Slide 25: αᵢ document baseline (partly length).Slide 25
2. A word with β close to 0 and a large ψ means…
Slide 30: top centre: und is common but has little weight.Slide 30
3. Which of the following is most likely to make Wordfish's main dimension not the political position you want?
Slide 21: possible complications — changing topics, speaking roles, genre and historical vocabulary.Slide 21
05 · Study 2

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 Slide 27

  • 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 Slides 28–29

  • 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 Slides 30–33

  • 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 Slides 30, 115

🗼Wordfish word plot (4,885 words)Real data · wf$beta, wf$psi from the local S05a fit

Each 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).

Click a point on the plot, or search for a word.
Reading tips

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 Slides 34–36

AspectWordscoresWordfish
StrengthScores new texts using reference positionsEstimates positions without supplied position scores
AssumptionsCredible reference positions; comparable language; shared word–position linksOne common dimension; conditionally independent Poisson counts; shared word effects
LimitsReference choice matters; unseen words lack scores; shared words pull raw scores inwardTopics or roles may drive the scale; small standard errors do not establish validity
Both need to be checked against the texts and independent evidence.

Self-check

1. On a word plot, a word at the very top centre means…
Slide 30: the higher on y, the more common; the closer x is to 0, the smaller the weight.Slide 30
2. Why can't positions in panels A and B of Slapin & Proksch Figure 1 be compared directly?
Slide 28: panels use different policy scopes; compare parties within each panel.Slide 28
3. Which of these is a Wordfish limit listed on slide 34?
The first three are Wordscores limits or design features; Wordfish: topics or roles may drive the scale; small standard errors do not establish validity.Slide 34
06 · Study 6

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 Slide 37

  • Texts: 14 speeches on the 2010 Irish budget.
  • Debate: December 2009.
  • Benchmark: human judgements of budget support.

Human judgement revealed a model failure Slides 38–39

  • 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.

Also visible in this week's R results (local output, Ch. 12)

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? Slides 40–41

Text A

“We have sought to do all of this in a manner that is fair and that protects the most vulnerable.”

Text B

“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).

🙈Blind-read more sentencesPractice · real data: original sentences from the 14 speeches (quanteda 4.5.1 segmentation)

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 Slide 41

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 Slides 42–43

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.)

Passage decision 1: after “As leader of the Green Party …” the speaker states the party's position on the budget—include it?
Slide 43: Keep passages that express support for or criticism of the budget.Slide 43
Passage decision 2: after “I will now comment on some specific aspects of my Department’s Estimate.” there are only administrative details with no position on the budget—include it?
Slide 43: Leave out purely administrative details with no position on the budget; reason: those details can change the vocabulary and shift the score. Decide passage by passage.Slide 43

Self-check

1. What benchmark do Lowe & Benoit (2013) use to check Wordfish?
Slide 37: Benchmark: human judgments of budget support.Slide 37
2. Slide 38 points out that which party's strong opposition looks too moderate in Wordfish?
Sinn Féin: strong opposition looks too moderate in Wordfish.Slide 38
3. Why exclude the purely administrative passages of Gormley's speech?
Slide 43: those details can change the vocabulary and shift the score.Slide 43
07 · Wordshoal

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 Slides 44–48

  • 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 Slide 49

→ →

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 Slides 50–54

  • 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.
The common scale summarises the positions legislators expressed in the debates they took part in. The second-stage model treats "debate positions where the legislator did not speak" as missing at random.

Linking debate positions: the second stage Slides 72–74

zij = aj + bj θi + εij
QuantityMeaning
zijStage 1: speaker i's Wordfish position in debate j
θiThe speaker's common position
bjDirection and strength of the debate's link to the common dimension
Missing zijThe 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 Slide 75

🧭Direction-alignment demoBased on the constructed example on slide 75; the interactive extension is a supplement (not from the lecture), not Wordshoal fit output

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.

Class discussion Slide 75

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 Slides 55–60

  • 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 legislatorsCorrelation r with government statusReading
Wordfish0.31Government and opposition scores overlap
Wordshoal0.94Much 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 Slide 61

SpeakerBudgetHealthForeign affairs
ASpeaksSpeaks—
BSpeaks—Speaks
C—SpeaksSpeaks

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

1. In the 30th Dáil, what are the correlations of Wordfish and Wordshoal positions with government status?
Slide 59: Wordfish r = 0.31; Wordshoal r = 0.94.Slide 59
2. Why is this week's Irish budget data not suitable for Wordshoal?
Slide 61: A single budget debate provides no cross-debate structure.Slide 61
3. How does Wordshoal's second stage handle "a legislator did not speak in a debate"?
Note on slides 50–54: the second-stage model treats missing debate positions as missing at random.Slide 50
08 · LSS

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 Slide 62

  • 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.
Hostility (+1)

enemy, foe, hostile

Friendliness (−1)

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 Slide 63

  • 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.
Class discussion Slide 63

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 Slides 76–80

StepInformation used
Define the two endsConcept-specific seed words and polarity
Estimate semantic relationsWord co-occurrence, usually across sentences
Score wordsSimilarity to seed words in a reduced semantic space
Score documentsFrequency-weighted average of word scores
Units matter: learning at the sentence level can support scoring at the article level, then aggregating to country-year (the GTI application).

From vectors to word polarity Slide 81

Use singular value decomposition (SVD) to reduce sentence–word counts to k dimensions:

gj = (1 / |S|) Σs∈S cos(vs, vj) ps
QuantityMeaning
vjWord vector learned from sentence contexts
psResearcher-assigned polarity of seed s, e.g., −1 or +1
gjWord 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

🌱Mini LSS (simplified)Supplement (not from the lecture) · real corpus, simplified implementation, not LSX

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.

Word polarity gj: top 12 / bottom 12 (excluding seeds)
Document scores of the 14 speeches (standardised)

Trubowitz & Watanabe (2021): the geopolitical threat index Slides 64–67

  • 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, not a mean polarity Slide 65

GTI is a proportion, distinct from a mean polarity score.

Validation depends on the level of analysis Slides 68–70

LevelResult
By decader = 0.82
By countryr = 0.94
Individual summariesAbout 59% agreement
Check the same unit your claim is about. A high correlation at an aggregate level does not mean every single summary is classified correctly. (Trubowitz & Watanabe 2021, Fig. 4; fn. 18)

Self-check

1. In the formula on slide 81, what is ps?
p ₛ: researcher-assigned polarity of seed s.Slide 81
2. In the GTI validation, roughly what is the agreement at the level of individual summaries?
Slide 69: individual summaries: about 59% agreement; r = 0.82 (decades) and 0.94 (countries) are aggregate levels.Slides 68–69
3. Which of the following best fits a case where the "target" assumption may fail?
Slide 63: Target: polarity relates to the actor or issue we intend to measure; slide 65: countries and relevant reports need to be identified separately.Slides 63, 65
09 · Validation

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 Slide 82

QuestionW6 classification practiceW7 scaling
What is evaluated?Predicted categoriesPositions on a specified dimension
What is the evidence?Held-out human labels; F1External measures; rank agreement
What do we read?Errors and coding boundariesSurprising 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 Slides 83–84

  • Question: Do text scales agree with other measures of party positions? Compares Wordscores and Wordfish.
  • Scope: 254 manifestos from 33 elections.
CountryElectionsManifestosMean words
Denmark, 1945–2007242121,232
Germany, 1980–200994210,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 Slide 85

📋Original Table 3: mean Spearman rank correlations across electionsTranscribed from slide 85 (Hjorth et al. 2015, p. 7)
CountryMethodCMPExpertsVoters
DenmarkWordscores0.70.80.8
DenmarkWordfish0.20.20.1
GermanyWordscores0.80.80.8
GermanyWordfish0.80.70.7

These are not classification accuracies. Rank agreement supports an ordering but does not establish meaningful distances.

Why did Wordfish do better in Germany? Slide 86

ExplanationWhat the authors report
Text length: testedRandomly shortening German manifestos to a Danish-like average length removed about half of Germany's Wordfish advantage.
Political language: inferredThe shortened German texts still did better; the authors attribute the remaining advantage to more ideologically polarised language.
Limits of the evidence

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 Slide 88

  • 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.
A local preprocessing sensitivity example (supplement, not from the lecture; R output in Ch. 12, X3)

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).

Class discussion Slide 88

Which choice would you change first? What evidence would you keep?

Your research abstract: validation plan builder Slide 89

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:

🧭Plan builderPractice · exports Markdown
Markdown

Self-check

1. According to Hjorth et al. Table 3, what is the mean Spearman correlation between Danish Wordfish and the voter benchmark?
Denmark, Wordfish: CMP 0.2, experts 0.2, voters 0.1.Slide 85
2. How did the authors test the "text length" explanation?
Slide 86: Randomly shorten German manifestos to a Danish-like average; about half the advantage disappears.Slide 86
3. "The Spearman correlation between Wordscores and Wordfish is high" best supports which conclusion?
Slides 85, 87, 119: rank agreement describes ordering; it is not accuracy; agreement between models is only partial evidence.Slides 85, 87, 119
10 · R practice 1

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 Slide 90

TaskPackageMain interface
Prepare texts and countsquantedacorpus, tokens, DFM
Reference-based scalingquanteda.textmodelstextmodel_wordscores()
Latent count scalingquanteda.textmodelstextmodel_wordfish()
Plot estimated positionsquanteda.textplotstextplot_scale1d()
Cross-debate scalingwordshoaltextmodel_wordshoal()
Semantic scalingLSXtextmodel_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

Environment and verification

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 Slides 92–93

R · S01 (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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] 14

The 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 Slides 94–95

R · S02a (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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

The 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) Slides 96, 122

📜Full text of the 14 speeches with keyword searchReal data · data_corpus_irishbudget2010, segmented into numbered sentences with quanteda 4.5.1
Sentences
–
Tokens after processing (S02c)
–
Keyword occurrences
–

Sentence 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 Slides 96–97

R · S02b (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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 Slides 98–99

R · S02c (W7/classroom/W7_scaling.R)
# S02c: Build the common count matrix
counts <- dfm(toks_irish)
dim(counts)
any(ntoken(counts) == 0)
topfeatures(counts, 6)
R console output (run locally: 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)
> 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 Slides 100–101

R · S03 (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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

Lenihan 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

1. dim(counts) in S02c returns 14 4885. What is 4885?
Slide 99: fourteen speeches and their combined vocabulary. The number of scored words is 2,131 in S04b.Slides 99, 105
2. Why does the, appearing 3,598 times, not affect our judgement of political positions?
Slide 99: we kept stopwords, so the remains common: occurrences alone do not distinguish political positions.Slide 99
3. In S03 the reference values of the other 12 speeches are NA. This means…
Slides 101, 107: NA marks twelve speeches whose reference positions were not supplied.Slides 101, 107
11 · R practice 2

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 Slides 102–103

R · S04a (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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

tax 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 Slides 104–105

R · S04b (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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 Slides 106–107

R · S04c (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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

The 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 Slides 108–109

R · S04d (W7/classroom/W7_scaling.R)
# 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)
S04d raw Wordscores positions with 95% intervals (redrawn locally)
Output of running S04d locally (click to enlarge). The original figure is on slide 109.

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

🧪Recompute Wordscores in the browserReal data · the 14 × 4,885 count matrix from S02c; 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.

Scored words
–
Median coverage of new texts
–
Spearman of new texts with Wordfish θ
–

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.

R · X2 (W7/work/extra_W7.R, supplement, not a class script)
# 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")
R console output (supplement, run locally; not in the class script)
> 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.

R · X1 (W7/work/extra_W7.R, supplement, not a class script)
# 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)
R console output (supplement, run locally; not in the class script)
> 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.078

lbg 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

Claim A: "The word score of fair is −0.229, so fair is a negative word in this debate."
The score only means it is relatively more common in Bruton's reference; general sentiment does not determine the sign.Slide 103
Claim B: "Burton's raw score is −0.001, which means she is neutral about the budget."
Being close to 0 is an average of word scores and does not establish neutral budget support (the close reading in Ch. 13 shows she is in fact criticising).Slides 109, 121
Claim C: "Cowen (0.180) and Gormley (0.159) have the highest raw scores among the 12 new texts, and are closest to the Lenihan end in the ordering."
This describes the ordering in the S04c output; both belong to government parties (supplementary background). But "closest to Lenihan's wording" is still not validated budget support.Slide 107

Self-check

1. Lenihan is assigned +1; why is ws_raw only 0.339?
Slide 107: shared vocabulary pulls raw averages toward the centre.Slide 107
2. Which kind of uncertainty is not included in the bars of S04d?
Slide 109: reference-choice uncertainty is excluded. S08 in Ch. 13 checks exactly this.Slide 109
3. What does coverage in S04b measure?
Slides 104–105: share of each speech's processed tokens that remain; repeated occurrences count.Slides 104–105
12 · R practice 3

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 Slides 110–111

R · S05a (W7/classroom/W7_scaling.R)
# 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))
R console output (run locally: 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)
> 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

Bruton (−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 Slides 112–113

R · S05b (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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

Burton θ = −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)

📍Wordfish θ ± 1.96 seReal data · local S05b output

S05c: word discrimination and baseline frequency Slides 114–115

R · S05c (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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

The ψ 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 Slides 116–117

R · S05d (W7/classroom/W7_scaling.R)
# 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)
S05d Wordfish positions with 95% intervals (redrawn locally)
Output of running S05d locally (click to enlarge). The original figure is on slide 117.

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)

R · X3 (W7/work/extra_W7.R, supplement, not a class script)
# 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)
R console output (supplement, run locally; not in the class script)
> 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.050

Removing 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

🐟Fit Wordfish with only the N most common wordsSupplement (not from the lecture) · real counts, simplified algorithm (alternating Poisson iterations), not quanteda's implementation

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.

Press "Fit" (about 1–3 seconds).

Self-check

1. What does dir = wf_dir in S05a do?
Slides 110–111: dir asks for Bruton below Lenihan; positions are estimated, not fixed at −1/+1.Slides 110–111
2. Which of the 14 speeches has the largest Wordfish se?
S05b: Gormley 0.075, Cuffe 0.073, Ryan 0.065; Burton 0.016 is the smallest.Slide 113
3. What does β = 0.505 for jobs mean?
Slide 115: stronger log expected-count change per theta unit, with other effects fixed; positive beta is not positive sentiment.Slide 115
13 · R practice 4

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 Slides 118–119

R · S06a (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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   1

The 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.)

R · X4 (W7/work/extra_W7.R, supplement, not a class script)
# X4: Spearman between Wordscores and Wordfish on all fourteen speeches
round(cor(results$ws_raw, results$wf_theta, method = "spearman"), 3)
R console output (supplement, run locally; not in the class script)
> round(cor(results$ws_raw, results$wf_theta, method = "spearman"), 3)
[1] 0.741

S06b: plot the new texts on both scales Slides 120–121

R · S06b (W7/classroom/W7_scaling.R)
# 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)
S06b scatter plot of the two scales (redrawn locally)
Output of running S06b locally (click to enlarge). The original figure is on slide 121.

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) Slides 119, 121

🔀Wordscores vs. Wordfish: 12 new textsReal data · local S04c, S05b output

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 Slides 122–125

R · S07a (W7/classroom/W7_scaling.R)
# 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")
R console output (run locally: 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)
> 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).

R · S07b (W7/classroom/W7_scaling.R)
# 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]))
R console output (run locally: 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)
> 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.

Supplement (not from the lecture): why do the two models differ so much on Burton? A checkable clue

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

📝S07 close-reading questionsPractice · copy as R comments and paste back into W7_scaling.R
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 Slides 126–129

R · S08a (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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

Replace 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).

R · S08b (W7/classroom/W7_scaling.R)
# 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)
R console output (run locally: 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)
> 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

Ryan 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

🔁Generalising S08Real data · Wordscores recomputed in the browser (same computation as Ch. 11)

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

1. What is the best reading of the Spearman 0.734 in S06a?
Slide 119: overall agreement can coexist with one large disagreement. It is not accuracy.Slide 119
2. In S08b, which two speakers have the largest absolute rank changes?
Ryan 6→9 (+3); Ó Caoláin 10→7 (−3).Slide 129
3. Why does S08b compare only 11 speeches?
Slide 128: recalculate both rankings within the same eleven texts.Slide 128
14 · Readings and glossary

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. Slides 4–7, 131

Texts58 individual legislators' English speeches from the October 1991 confidence debate on the Fianna Fáil–PD government.
TargetHow strongly each speaker supported or opposed the government.
DesignHaughey +1; Bruton and de Rossa −1 (pp. 61–66); word scores → positions of other speakers.
TakeawayThe interpretation is limited to "support for this government within this debate".

Laver, Benoit & Garry (2003). Extracting Policy Positions from Political Texts Using Words as Data. APSR 97(2): 311–331. Slides 13, 15–19, 131

TextsBritish 1992 manifestos + expert scores as references; 1997 manifestos as new texts.
ResultsFigure 1 (p. 314): 1992 Lab 5.35 / LD 8.21 / Con 17.21; 1997 Lab 9.17 / LD 5.00 / Con 17.18.
CautionValues are transformed, standard errors in parentheses; compare ordering, be cautious about distances.
TakeawayReferences → words → new texts; pp. 314–315 discuss scope; pp. 326–328 include the 1991 Dáil debate.

Lowe (2008). Understanding Wordscores. Political Analysis 16(4): 356–371. Slide 14

RoleSource of the Wordscores model interpretation on slide 14.
TakeawayFour assumptions: reference scores measure the concept, comparable language, coverage, transferability.

Slapin & Proksch (2008). A Scaling Model for Estimating Time-Series Party Positions from Texts. AJPS 52(3): 705–722. Slides 20–33, 131

TextsGerman party manifestos 1990–2005.
Modely ∼ Poisson(μ), log μ = α + ψ + βθ (p. 709); no reference scores, fit jointly across elections.
EvidenceFigure 1 (p. 714) party positions; Figure 2 (p. 715) word plot.
TakeawayA common time scale requires comparable word use; policy scopes differ across panels.

Lowe & Benoit (2013). Validating Estimates of Latent Traits from Textual Data Using Human Judgment as a Benchmark. Political Analysis 21(3): 298–313. Slides 37–41, 132

Texts14 speeches on the 2010 Irish budget (December 2009), this week's R data.
BenchmarkHuman judgements of budget support.
ResultsMost positions roughly agree; Sinn Féin's strong opposition looks too moderate in Wordfish (manuscript Figure 3, p. 32).
TakeawayA second political distinction complicates a single dimension; independent human judgement is needed.

Lauderdale & Herzog (2016). Measuring Political Positions from Legislative Speech. Political Analysis 24(3): 374–394. Slides 44–61, 72–75, 131

DataThe 29th and 30th Irish Dáil; the 104th–113th US Senate.
MethodWordshoal: Wordfish in each debate → second-stage linking (§3.2); missing positions treated as missing at random.
Results30th Dáil correlation with government status: Wordfish r = 0.31, Wordshoal r = 0.94 (Figure 2, p. 382).
TakeawayThe main dimension follows government/opposition; left–right needs its own evidence.

Watanabe (2021). Latent Semantic Scaling. Communication Methods and Measures 15(2): 81–102. Slides 62–63, 76–81, 132

MethodSeed words → SVD semantic space → word polarity gj (Eqs. 1–2) → document scores (frequency-weighted average).
TakeawayFour assumptions: seeds, semantics, aggregation, target; the learning unit and the scoring unit can differ.

Trubowitz & Watanabe (2021). The Geopolitical Threat Index. ISQ 65(3): 852–865. Slides 64–70, 132

TextsNew York Times summaries 1861–2017; Newsmap + LSS.
TargetHostile foreign military behaviour in the reports; GTI is the proportion of hostile military reports.
ValidationDecades r = 0.82; countries r = 0.94; individual summaries about 59% agreement (Fig. 4; fn. 18).
TakeawayValidate at the unit your claim is about.

Hjorth, Klemmensen, Hobolt, Hansen & Kurrild-Klitgaard (2015). Computers, Coders, and Voters. Research & Politics 2(2): 1–9. Slides 82–86, 132

Scope254 manifestos from 33 elections: Denmark 24 elections / 212 manifestos (mean 1,232 words), Germany 9 / 42 (10,306 words).
BenchmarksExperts, voters, CMP RILE.
ResultsTable 3 (p. 7): Denmark Wordfish 0.2 / 0.2 / 0.1; other combinations 0.7–0.8.
TakeawayShortening the German texts removed about half the advantage; the language explanation is inferred, not tested separately.

Benoit (2018). Scaling Text. Quants 3: Quantitative Text Analysis, Trinity College Dublin, March 23 (lecture notes). Slides 131, 133

RoleLecture-note source for the conceptual explanations (pp. 3–27, 34–50, 54–55, 59–70), e.g., the Gormley example on pp. 64–66 and the validation framework on p. 59.
Full textNot in the repo.

Matching practice

🗂Match the studiesPractice · based on the slides
Not answered yet.

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

1. Treating the assigned reference value as the prediction

Lenihan is assigned +1, with a raw prediction of 0.339; the reference points on the plot are rescored.Slides 107, 109

2. Reading a raw score near 0 as "neutral"

Burton is −0.001, but she is criticising the budget.Slides 109, 121, 125

3. Reading the sign of a word score or β as sentiment

fair at −0.229 and a positive β are not sentiment.Slides 103, 115

4. Treating ψ as raw frequency

ψ is the word baseline in the model after accounting for document baselines.Slide 115

5. Thinking dir gives the dimension meaning

dir only chooses the direction.Slides 87, 111

6. Small standard error = valid

Burton's se of 0.016 is narrow, but it does not prove the scale measures budget support.Slides 34, 113, 117

7. Correlation between models = accuracy

Spearman 0.734 is rank agreement.Slide 119

8. Comparing ranks across different sets of speeches

S08b recomputes ranks only within the 11 texts that are new texts under both designs.Slides 128–129

9. Directly comparing transformed distances

The values in LBG Figure 1 are transformed; compare ordering.Slide 19

10. Validating at the wrong level

GTI at aggregate levels r = 0.82 / 0.94; individual summaries about 59%.Slides 68–70

Glossary

15 · Final review

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

Not answered yet

(The final review quiz needs JavaScript.)

Reporting a text scaling analysis Slide 130

DecisionWhat to reportAnswer for this week's practice
Corpus and representationDebate, speakers, preprocessing, and counts14 budget speeches from December 2009; punctuation/symbols/numbers removed, lower-cased; stopwords kept; count DFM 14 × 4,885
WordscoresReference texts, assigned values, coverage, raw/rescaled scoresLenihan +1, Bruton −1; smooth = 0; 2,131 scored words, coverage 83.6%–100%; raw scores
WordfishDirection, model settings, interpretation of θdir: Bruton < Lenihan; dispersion = "poisson"; set.seed(7197); θ is a relative position
EvaluationRanking disagreements, passages read, sensitivitySpearman 0.734; Burton 7 vs. 1, read sentences 1 and 5–7; after the Cowen swap, Ryan +3, Ó Caoláin −3
Back to Lowe & Benoit Slide 130

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 Slides 131–133

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).
These notes are based on the NTLDEV 7191 W7 slides (Yen-Chieh Liao, class date 2026-10-23; 133-page PDF, compiled 2026-10-30), W7/classroom/W7_scaling.R and README, W7/lab/Lab_Session_W7.R and README, and Data/README.md; every number was re-checked against the local run and the slides. R output is from a local rerun (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). Reading cards are based only on the slides (no full texts in the repo). Passages and toy demos marked "Supplement (not from the lecture)" are additional explanation. Prepared 2026-11-06.
NTLDEV 7191 Text as Data · W7 interactive self-study notes · based on the 2026-10-23 lecture slides (2026-11-06)