Section one Start here: the three choices Unit, arena, window — the three decisions behind every agenda claim
An agenda question sounds simple and is not. Before you download anything, you have to make three decisions. Almost every confused answer in a memo comes from skipping one of them.
Whose agenda?
There is no such thing as "the agenda." There are six separate agendas, and they do not match each other. The public has one. The press has one. Congress, the President, the federal bureaucracy, and the Supreme Court each have their own. An issue can be enormous in one arena and invisible in another at the same moment.
Measured how?
Attention has to be turned into a number before you can chart it. That number is usually either a count of documents about your issue, or a share, which is that count divided by everything the arena produced in the same period. These two can move in opposite directions, so you must say which one you used.
Over what window?
A two-month window shows you a news cycle. A seventy-year window shows you a structural shift. Neither is wrong, but they answer different questions, and a spike that looks dramatic across six months often disappears entirely when you plot the same series across six decades.
The shortcut if you are in a hurry. If your memo needs one credible agenda measure and you have an hour, use the Federal Register application programming interface for what the bureaucracy is doing right now, and the Comparative Agendas Project congressional hearings file for the long view of what Congress has paid attention to. Those two are the easiest to work with and the hardest to argue with.
Section two The figures from class 19 charts from the lecture, each with the source line it carried
These are the charts from the November 12 lecture, with the source line each one carried on the slide. Every one of them was built from a dataset listed further down this page, so if a figure is the kind of thing you want in your memo, scroll to that dataset and follow its instructions.
What the public is worried about

Gallup's most important problem, 2020 to 2026
Gallup asks an open-ended question every month and sorts the answers people volunteer into categories. This chart follows six of those categories over almost seven years. Notice that the series trade places repeatedly: inflation barely exists before 2021 and then becomes the largest single answer, while COVID-19 rises from nothing and then vanishes from the reporting entirely.
Gallup, Most Important Problem; 81 survey waves. Latest field period: Oct. 1–19, 2026. Multiple responses permitted. Values below 0.5% and unreported categories are omitted; COVID-19 is not extended after separate reporting ends.

One issue can swallow the whole agenda
The same question, in three different months, broken into four broad groups. In January 2001 the economy was a quarter of all mentions. In February 2009, in the depths of the financial crisis, it was eighty-four per cent. There was almost no room left on the public agenda for anything else, which is the clearest possible illustration of why agenda space is treated as a scarce resource.
Gallup Most Important Problem, category composition, measured from the published treemaps. LPPP 6350.

What the public has actually been searching for
Nine policy terms, placed on one shared scale, over the two most recent complete months. Because all nine terms were submitted in a single Google Trends query, the numbers can be compared to each other, which is not true if you look each term up separately. Read this as a measure of attention, not of importance: guns sitting at zero means almost nobody searched for it in this window, not that nobody cares.
Google Trends, United States, web search, monthly. Pulled 11 Nov 2026.
What the press and the networks cover

Two readings of the media agenda
The top panel is the print record and the bottom panel is the evening news, coded into the same twenty-one topics so that they sit on the same scale. They are two independent measurements of the same thing, which is exactly what you want when you are trying to establish that a pattern is real rather than an artefact of one newsroom's habits.
Comparative Agendas Project. New York Times Index: 42,006 stories, 1946–2016. TV News (Uscinski), Vanderbilt Television News Archive: 53,915 ABC, CBS and NBC evening stories, 1968–2009, shown as a three-year average over the annual line. Dashed rules mark events, not breaks in the data. LPPP 6350.

Two newsrooms, the same ranking, very different weights
The scatter plot on the right is the useful part. Each dot is one topic, placed by its average share of the Times and its average share of the evening news. The two outlets rank topics almost identically, with a rank correlation of +0.71, but they weight them very differently: international affairs is far heavier on television and domestic commerce is far heavier in print. Agreement about order is not agreement about emphasis.
Comparative Agendas Project. TV News (Uscinski), Vanderbilt Television News Archive: 53,915 ABC, CBS and NBC evening stories coded to a major topic, 1968–2009. New York Times Index: a systematic random sample, 42,006 stories, 1946–2016, here restricted to the overlapping years. LPPP 6350.
What the three branches do

The legislative agenda: what Congress holds hearings about
A hearing is the cheapest signal of congressional attention there is. Holding one commits a committee's time without committing it to a vote, which is why hearings track attention better than bills do. The long decline in domestic commerce and the rise and fall of defense are both visible without any statistics at all.
Comparative Agendas Project, Congressional Hearings, 1947–2015, coded to the 21 CAP major topics. Each series is a three-year average over the annual line. Dashed rules mark events, not breaks in the data. LPPP 6350.

The executive agenda: what the President asks Congress for
Every State of the Union address since 1946, cut into individual policy statements and coded one at a time. This is the single best record of what a President chose to spend scarce attention on in a given year. The spike in international affairs after 2001 and the climb in health after 2008 are the kind of movement you can tie directly to a known event.
Comparative Agendas Project, State of the Union Speeches, 20,582 policy quasi-sentences, 1946–2025, coded to the 21 CAP major topics. Each series is a three-year average over the annual line; speech length varies a great deal year to year, so shares are steadier than counts. LPPP 6350.

The judicial agenda: what the Supreme Court agrees to hear
The Court is the one arena that openly chooses its own workload. A 1988 statute gave it near-total control over which cases it takes, and the shape of the series changes after that date. When you argue that the Court "turned toward" an issue, you are arguing about a choice, not about a caseload that arrived on its own.
Comparative Agendas Project, US Supreme Court, 10,236 cases, 1946–2023, coded to the 21 CAP major topics. Each series is a three-year average over the annual line. The 1988 rule gave the Court near-total control of its docket. LPPP 6350.

The two arenas you never get asked about
Memos almost always reach for Congress or the President. The Court and the press are coded into the same twenty-one topics, which means they sit on exactly the same scale as everything else, and almost nobody uses them. That is an opportunity rather than a problem.
Comparative Agendas Project. Supreme Court: 10,236 cases, 1946–2023. New York Times Index: a systematic random sample, 42,006 stories coded to a major topic, 1946–2016. Dashed lines mark events, not breaks in the data. LPPP 6350.
Comparing arenas against each other

Six arenas, one topic scheme, and almost no shared agenda
Each cell reports how closely two arenas rank the same topics, across every year both of them cover. A value of plus one would mean identical priorities and zero would mean no relationship at all. The striking result is how low most of these numbers are: citizens and Congress sit at +0.05, which is effectively no relationship over the long run.
Comparative Agendas Project, 20 major topics, each pair over its own longest shared window, printed beneath the number. Right panel: Google Trends and the Federal Register over the last six months, on a narrower nine-topic set. LPPP 6350.

Where the agenda actually is, right now
The same nine topics measured three different ways over the same recent months: what citizens search for, what presidential documents are issued about, and what the bureaucracy actually published final rules on. The fourth panel asks whether the three agree. Mostly they do not, and the disagreements are where the interesting memos live.
Citizens: Google Trends, United States, web search. President: Federal Register presidential documents. Bureaucracy: Federal Register final rules. All monthly, Sep 2025 to Oct 2026, converted to each arena's own share of attention so the three are comparable. LPPP 6350.
What the evidence says about how long attention lasts

The issue attention cycle, as folk wisdom
This is the story everybody already believes, drawn as a loop. The four figures that follow are what happens when you test each stage of it against data. Some of the folk wisdom survives and some of it does not.
Redrawn from a hand-drawn classroom cartoon. Not a chart; no data behind it. LPPP 6350.

The media moves the public, and then stops
An experiment in which news outlets were randomly assigned to publish stories on a broad policy area. Public discussion of that area rose by 62.6 per cent over the following week, which is a large effect. But look at the shape: more than half of the whole effect arrives in the first two days, and by day six it is essentially over.
King, Schneer & White 2017, Science 358(6364):776–80. Figure redrawn by measurement from the published figure.

Five times the coverage, gone within a week
Average seconds of network evening news devoted to guns around a mass shooting. Before the event the baseline runs at about 67 seconds a night. The day after, it hits 334 seconds. Within eight days it is back under a hundred. This is the issue attention cycle with a clock attached to it.
Luca, Malhotra & Poliquin 2020, Journal of Public Economics 181:104083. Figure redrawn by measurement from the published figure.

Search interest spikes, and then returns to the same floor
Searches for "gun control", with the Sandy Hook peak set to one hundred by Google's own normalisation. The important feature is not the spikes, which everyone expects, but the floor: quiet months sit near nine and never approach zero. Attention does not disappear between events, it returns to a low but non-zero baseline.
Reny, Newman, Holbein & Hassell 2023, PNAS Nexus 2(12):pgad407. Figure redrawn by measurement from the published figure.

Six shootings, the same decay
The effect on gun-policy posting, measured in standard deviations, for each of six separate events. Day zero runs between roughly two and four standard deviations, which is enormous. By day two, five of the six are already at or below their own baseline. The decay is not a property of one event; it repeats.
Reny, Newman, Holbein & Hassell 2023, PNAS Nexus 2(12):pgad407. Figure redrawn by measurement from the published figure.

Attention is not the same thing as participation
Two search terms, measured the same way on the same days around the same events. Searches for "gun control" rise roughly twentyfold in a single day. Searches for "register to vote" do not move at all. People pay attention; they do not necessarily do anything. That gap is the central problem of democratic accountability.
Hassell, Holbein & Baldwin 2020, American Political Science Review 114(4):1375–85. Figure redrawn by measurement from the published figure.

The window does not close at the same speed in every arena
Three different measures of post-event attention, each rescaled so that its own peak equals one hundred, so the curves can be compared. Social media is half gone within about three days. Network news takes closer to two weeks. Public search attention is still measurably elevated a month later. If you are a policy entrepreneur, which arena you are working in determines how long you have.
News seconds: Luca, Malhotra & Poliquin 2020. Searches: Hassell, Holbein & Baldwin 2020; Reny, Newman, Holbein & Hassell 2023. Social media: King, Schneer & White 2017. Different studies and measures, so read the shapes, not the gaps. LPPP 6350.

The public's spikes are getting smaller
Each dot in the lower panel is one shooting, placed by how far above its own preceding baseline the search spike rose. School shootings average about 37 points above baseline and other mass shootings about 10. Both are falling at roughly 1.4 points a year. The same event produces less attention than it used to, which is a harder finding than it first appears.
Google Trends, United States, monthly, scaled to the series maximum. Spike is the higher of the event month and the next, minus the median of months −12 to −7. LPPP 6350.
Section three The datasets, one by one Seven files, every single column explained
Each dataset below carries a badge telling you which of two kinds it is. The difference between them decides what you are allowed to claim, so read this part before you download anything.
Every row is a single real thing: one hearing, one court case, one sentence of a speech, one published rule. Nobody has summarised it for you. You can therefore filter it, count it, and build your own measure of attention to your own issue, defined however you want to define it. This is where original work comes from.
Somebody has already rolled the underlying material up into a percentage or an index for a period. You get the summary and not the raw material. You cannot go back and re-sort it by your own definition, and you cannot recover the individual responses. These are still extremely useful, but only for the categories they already contain.
The most important thing on this page. For every one of the Comparative Agendas
Project files, the column names printed in the official codebook are not the column
names in the file you download. The codebook says MajorTopic and the
file says majortopic. The codebook says KeyID and the file says
id. The codebook describes columns that are not in the file at all, and the
file contains columns the codebook never mentions.
This is not a trick and it is not your mistake. It is simply what happens to research files over thirty years. The tables below have been checked against the actual header row of each downloaded file, so they give you both names: what the file really calls the column, and what the codebook calls it. Always write your code against the first one.
One clearing house for most of this. Seven of the files below come from the Comparative Agendas Project at the University of Texas, which codes material from many different arenas into one shared scheme of twenty-one topics. That shared scheme is the whole point: it is what lets you put Congress and the Supreme Court and the New York Times on the same axis. The full list of United States files is at comparativeagendas.net, and there are nineteen more than the ones described here.
Datasets where you get one row per document
Congressional hearings
Comparative Agendas Project, United States. The best single measure of what Congress is paying attention to, and the easiest of these files to work with.
- One row is one congressional hearing, with a title, a short description of what it was about, and a topic code assigned by a human coder.
- Coverage 1946 to 2021. The project's dataset page reports 103,077 hearings. The version used in the November 12 lecture ran only to 2015, which is why that chart stops six years short of what the file now contains.
- Format a single comma-separated values file. It is large, so it may be slow to open in Excel; section five tells you what to do about that.
- Why it is good for agenda work holding a hearing costs a committee time but does not commit it to a vote, so hearings respond to attention faster and more honestly than bills or laws do.
What this can tell you
How much of Congress's attention your issue received in any year since 1946, whether that attention rose or fell, which committee held it, and whether the hearings were tied to actual legislation or were purely symbolic.
What this cannot tell you
What anybody said at the hearing, whether a bill passed, how any member voted, or what happened after 2021. A hearing is evidence of attention, not of action.
Every column in this file, explained
The columns you will actually use are
year, Chamber, majortopic,
subtopic, title, description and
filter_Lawmaking. The rest are here so that nothing in the file
surprises you. Note that this file mixes capitalisation styles, so copy names exactly
rather than typing them.
| Column in the file | Codebook calls it | What it contains |
|---|---|---|
| (blank) | not listed | The very first column has no name at all. It is a leftover row counter from whatever program last saved the file. Ignore it, but do not be alarmed when your software labels it something like "Unnamed: 0". |
id | ID | A unique identifying number for each row. It carries no meaning of its own and exists only so that two rows can be told apart. |
source | Source | The serial number from the Congressional Information Service abstract volume, which is how you would find the full text of the hearing in a library database. |
CISYear | same | The year of the abstract volume in which this hearing's record was published, which is not always the year the hearing happened. |
Unpublished | same | A flag marking hearings that were never released for the public record. |
Chamber | same | Where the hearing was held. The value 1 means the House of Representatives, 2 means the Senate, and 3 means a joint committee or commission. |
filter_House | same | Set to 1 when the hearing was a House hearing and 0 otherwise. It duplicates part of Chamber in a form that is easier to filter on. |
filter_Senate | same | Set to 1 when the hearing was a Senate hearing and 0 otherwise. |
filter_Joint | same | Set to 1 when the hearing was held by a joint committee and 0 otherwise. |
CISCommittee | same | The three digits that follow the letter in the serial number, identifying the committee in the Congressional Information Service's own numbering. |
Sequence | same | The number that follows the committee code in the serial number, distinguishing one hearing from another within the same committee. |
Month | same | The month the hearing began, numbered 1 for January through 12 for December. Hearings that ran across several months record only the month they started. |
Congress | same | Which numbered Congress held the hearing. The 117th Congress, for example, sat during 2021 and 2022. |
year | Year | The calendar year in which the hearing started, taken from the hearing's own title. This is the column you will group by. |
FiscalYear | same | The federal fiscal year in which the hearing fell, which runs from October to September and so does not match the calendar year. |
Days | same | How many days of hearing the abstract mentions. |
Sessions | same | How many separate sessions the hearing was divided into. |
Committee1 | same | The committee that held the hearing, numbered using the Policy Agendas Project's own committee scheme rather than the Congressional Information Service's. |
Subcommittee1 | same | The specific subcommittee that held the hearing. When no subcommittee is named, the hearing is assumed to have been before the full committee. |
Committee2 | same | A second committee code, filled in when a second subcommittee was involved or when a committee from outside took part. |
Subcommittee2 | same | A second subcommittee code, used when more than one subcommittee held the hearing. |
filter_Referral | Filter_Referral | Set to 1 when the hearing mentions a specific bill by number or name, which makes it a referral hearing, and 0 when it does not. |
filter_Approp | Filter_Approp | Set to 1 when the hearing considered an appropriation or a budget, and 0 otherwise. |
filter_Agency | Filter_Agency | Set to 1 when the hearing concerned the proposed creation of a new government agency, and 0 otherwise. |
filter_Program | Filter_Program | Set to 1 when the hearing discussed a new program, and 0 otherwise. This is independent of whether a new agency was involved. |
filter_Admin | Filter_Admin | Set to 1 when the hearing concerned something the President's administration had proposed, and 0 otherwise. |
filter_Lawmaking | Filter_Lawmaking | Set to 1 when either the referral flag or the appropriations flag is 1. This is the quickest way to separate hearings that were part of actual lawmaking from hearings that were purely about attention. |
title | not listed | The title of the hearing. The codebook does not mention this column, but it is in the file and it is one of the two places to search for your keywords. |
description | not listed | The description of what the hearing was about. This is the main column to search for your issue's keywords, and the one to quote from in a memo. |
pap_majortopic | USMajorTopic | The major topic code in the older Policy Agendas Project scheme. Use this only if you are matching to an older study. |
pap_subtopic | USSubTopicCode | The subtopic code in the older Policy Agendas Project scheme. |
Change. | not listed | An undocumented working column, with a full stop as part of its name. The codebook says nothing about it. Do not use it for anything. |
majortopic | MajorTopic | The major topic code in the current Comparative Agendas Project scheme, running from 1 to 23. This is the column you will group by. The full list is in the topic table further down this page. |
subtopic | SubTopicCode | The subtopic code in the current scheme, a three or four digit number whose leading digits are the major topic. This is how you narrow from "health" to "prescription drug coverage". |
ReferralBills | same | For records from 2009 onward, the list of bills associated with the referral. |
StartDate | same | For records from 2009 onward, the first date on which the hearing was held. |
AdditionalDates | same | For records from 2009 onward, the dates of any further days of the same hearing. |
State of the Union addresses
Comparative Agendas Project, United States. The clearest record there is of what a President chose to spend attention on in a given year.
- One row is one quasi-sentence: a single statement, cut at the periods, semicolons and question marks. A long sentence that lists housing, wages and natural resources becomes three separate rows, because it made three separate policy claims.
- Coverage 1946 to 2025. The project's dataset page reports 25,109 quasi-sentences in total; about 20,582 of those carry policy content and the rest are ceremonial language.
- The one trap speeches vary enormously in length from year to year. If you count raw statements you will mostly be measuring how long the President talked. Always convert to a share of that year's policy statements.
What this can tell you
Exactly how much of a President's agenda-setting speech went to your issue, in any year since 1946, and the actual words used, because the text of every statement is in the file.
What this cannot tell you
Whether the President meant it, whether anything followed, or what the administration did in the other 364 days of the year. A State of the Union is a statement of intent.
Every column in this file, explained
| Column in the file | Codebook calls it | What it contains |
|---|---|---|
id | KeyID | A unique identifying number for each row, with no meaning of its own. |
doc_count | Count | Where this statement sits in the order of that year's address. A value of 1 is the opening statement. |
filter_PolicySentence | PolicySentence | Set to 1 when the statement makes a policy claim and 0 when it is ceremonial or rhetorical. Filter on this first, or your shares will be diluted by greetings and applause lines. |
date | Date | The date on which the address was delivered. |
oral_delivery | OralDelivery | Set to 1 when the address was spoken aloud to Congress and 0 when it was only submitted in writing, which several early ones were. |
outgoing | Outgoing | Set to 1 when this was a departing President's last address before handing over, and 0 otherwise. |
congress | Congress | Which numbered Congress was sitting when the address was delivered. |
president | President | The name of the President who delivered it. |
pres_party | PresParty | The President's party, where 100 means Democrat and 200 means Republican. These numbers are a long-standing convention in political science datasets. |
divided | Divided | Set to 1 when one party held the White House and the other held at least one chamber of Congress, and 0 when one party held both. |
control_house | ControlHouse | Which party controlled the House of Representatives, using the same 100 and 200 convention. |
control_senate | ControlSenate | Which party controlled the Senate, using the same convention. |
year, month, day | Year, Month, Day | The year, month and day of the address, split into three columns so you can group by any of them. |
source | Source | The document the coders worked from for that year's address. |
description | Description | The actual text of the statement. This is the column to search when you are looking for your issue's keywords, and the column to quote from in a memo. |
pap_majortopic | USMajorTopic | The major topic code in the older Policy Agendas Project scheme. Left blank when the statement has no policy content. |
pap_subtopic | USSubTopicCode | The subtopic code in the older scheme. Set to −555 when the statement has no policy content, which is a missing-value marker and not a real code. |
majortopic | MajorTopic | The major topic code in the current Comparative Agendas Project scheme. Blank when there is no policy content. This is the column you will group by. |
subtopic | SubTopicCode | The subtopic code in the current scheme, again set to −555 when there is no policy content. |
Supreme Court cases
Comparative Agendas Project, United States. The only arena that openly chooses its own workload, which makes its agenda unusually interpretable.
- One row is one case on the Court's docket, with a written summary and a topic code.
- Coverage the version used in class covered 1946 to 2023 and contained 10,236 cases. The project's dataset page currently reports 10,129 cases and lists an end year that is clearly a typographical error, so check the file itself rather than the listing.
- The thing that makes it interesting a 1988 statute gave the Court near-total discretion over which cases it accepts. Everything after that date is a choice.
What this can tell you
Which policy areas the Court has been willing to take up over time, how that mix shifted after it gained control of its own docket, and how a case reached the Court in the first place.
What this cannot tell you
How the Court ruled, who voted how, or anything about the lower courts, where the overwhelming majority of federal litigation actually happens.
Every column in this file, explained
The codebook for this file describes
several columns that are not in the downloaded version: a ruling
column, the vac, dis and gd flags for vacated,
dismissed and granted-or-denied, a term_b calendar-year column, and the
extra docket_x columns for bundled cases. If your analysis depends on
knowing whether the Court granted or denied a case, this file will not tell you, and
you need a different source such as the Supreme Court Database.
| Column in the file | Codebook calls it | What it contains |
|---|---|---|
id | KeyID | A unique identifying number for each row, with no meaning of its own. |
case_citation | same | The case's formal citation. The codebook warns that this column is scheduled to be removed in a future release, so do not build anything that depends on it. |
case_name | same | The name of the case. Also scheduled for removal; use description instead. |
docket_number | docket_num | The docket number, written as the year followed by a running case number. The number 97-3 means the third case filed in 1997. Cases filed by people too poor to pay the fee use 5001 and upward after the year. A value of 0 is a placeholder meaning there was no docket number. |
summary | same | The description of the case that the coders worked from, usually taken from the published summary or syllabus. This is the main column to search for keywords. |
type | same | How the case reached the Court. CERT means certiorari, which is the ordinary route and by far the most common. APPL means appeal. MOT means a motion, and MISC means a miscellaneous order such as a stay; the last two appear only when a justice wrote an opinion. |
oral | same | The date the Court began hearing argument. When no argument happened, the decision date is used instead to work out the term. |
decision | same | The date the case was decided. |
term_a | same | The Court term, which runs from October of one year to June of the next and is named for the year it started. An argument in May 1966 belongs to the 1965 term. |
year | Year | The year of oral argument, or of the decision when there was no argument. This is the column you will group by, and it is also the one to use when lining the Court up against the Gallup or New York Times series, which are organised by calendar year. |
pap_majortopic | Pap_MajorTopic | The major topic code in the older Policy Agendas Project scheme. Each case gets exactly one code, assigned on the basis of the issue brought to the Court rather than the issue it ended up deciding. |
pap_subtopic | Pap_SubTopic | The subtopic code in the older scheme. |
majortopic | MajorTopic | The major topic code in the current Comparative Agendas Project scheme. This is the column you will group by. |
subtopic | SubTopicCode | The subtopic code in the current scheme. |
source | Source | The United States Reports citation in volume and page form, so 347/0403 means volume 347, page 403. |
description | Description | The case name, for example United States v. Gilman. |
congress | Congress | The numbered Congress sitting at the time, included so the file can be matched to legislative data. |
New York Times Index
Comparative Agendas Project, United States. Seventy years of the press agenda, built by sampling a printed index rather than by reading every article.
- One row is one entry in the printed New York Times Index, which is a short editorial summary of a story rather than the story itself.
- Coverage 1946 to 2016, 56,910 entries. The chart shown in class used the 42,006 of those that carry a major topic code.
- How it was sampled, which you must disclose coders took the first entry on every odd-numbered page of the index. If that first entry had no summary, they took the next one. This is a systematic random sample, not a census, so your counts are estimates with sampling error attached.
- The weights file the index itself grew and shrank over the decades, so a raw count of sampled entries is not comparable across years. A companion file gives the number of index pages and an estimated number of articles per page for each year. The codebook's recommendation is to divide each year's counts by that year's total entries, which is the same thing as working in shares. Be warned that the weights file opens with three lines of title text before the real header row, so the first thing you see will be the project's name rather than column names.
What this can tell you
How much press attention your issue drew in any year from 1946 onward, whether the story was about government or not, which institution it involved, and whether it was national or local to New York.
What this cannot tell you
What any article said, how it framed the issue, or anything about any other newspaper. It also tells you nothing after 2016, which rules it out for anything about the present day.
Every column in this file, explained
This file has the biggest gap between
codebook and reality of any on this page. The codebook calls the twelve yes-or-no
columns Filter_NYC, Filter_President and so on. The file
calls them myNYC, President, CongressDum and
similar. There is no Filter_ prefix anywhere in it. The file also
ends with two columns that have no names at all.
All twelve of the yes-or-no columns work the same way: 1 means the condition is true of this entry and 0 means it is not.
| Column in the file | Codebook calls it | What it contains |
|---|---|---|
id | KeyID | A unique identifying number for each row, with no meaning of its own. |
year | Year | The year of the index volume the entry was drawn from. This is the column you will group by. |
Source | not described | An identifier for the index volume the entry came from. |
PageNumber | Page Number | Which page of the printed index the entry appeared on. Used only for finding the entry again. |
BeginningWords | same | The first three words of the entry exactly as printed, again used only for identification. |
Date | same | The date of the story, written as month, day and year. |
Length | same | How long the story was, where 1 is short, 2 is medium and 3 is long. The value 9 means the index did not say, which is generally true before 1974. |
FrontPage | same | Set to 1 when the story ran on the front page and 0 when it did not. Front-page placement is a reasonable proxy for how important the editors thought the story was. |
Description | same | The summary of the story. This is the column to search for your issue's keywords. |
majortopic | MajorTopic | The major topic code in the current Comparative Agendas Project scheme. This is the column you will group by. The older PAP_MajorTopic column the codebook describes is not in this file. |
NYMetro | same | Where the story was centred. The value 1 means New York City only, 2 means New York State or the surrounding region including Connecticut and New Jersey, and 3 means anywhere else, including national events that happened to take place in New York. |
Domestic | same | How the story relates to the United States. The value 1 means a purely domestic story, 2 means a foreign story with an American angle, and 3 means a foreign story with no American involvement. |
myNYC | Filter_NYC | Set to 1 when the story is New York City only. |
myNYRegion | Filter_NY_Region | Set to 1 when the story is regional to New York State and its neighbours. |
myDomestic | Filter_Domestic | Set to 1 when the story is purely domestic. |
myUSinvolvement | Filter_US_involvement | Set to 1 when the story is foreign but involves the United States. |
PublicPolicy | Filter_PublicPolicy | Set to 1 when the entry mentions any American government official, agency or action at any level. This is the single most useful filter in the file, because it separates policy coverage from sport, weather and culture. |
FederalAgency | Filter_FederalAgency | Set to 1 when the entry mentions a national agency or department head, or national park, military, diplomatic or space activity. |
President | Filter_President | Set to 1 when the entry mentions the sitting President or the White House staff, a past President's actions in office, or a presidential advisory body. Note that this is a yes-or-no flag and not the President's name, which is easy to misread. |
CongressDum | Filter_Congress | Set to 1 when the entry mentions Congress, either chamber, its members or staff, or the legislative process. The "Dum" on the end is short for dummy variable, which is social-science shorthand for a yes-or-no column. |
Courts | Filter_Courts | Set to 1 when the entry mentions court or judicial activity at any level, including grand juries, lawsuits and trials. |
StateLocalActors | Filter_StateLocalActors | Set to 1 when the entry mentions state or local officials or agencies other than courts, such as district attorneys, state legislators or school boards. Federal officials who happen to represent a state do not count. |
CandidatesCampaigns | Filter_CandidatesCampaigns | Set to 1 when the entry is about candidates, elections, campaigns, conventions, redistricting, campaign finance, party platforms or debates. |
InterestGroups | Filter_InterestGroups | Set to 1 when the entry names a specific organised group such as a union, party, foundation or non-profit. Business lobbying and foreign groups are deliberately excluded. |
Congress | not described | Which numbered Congress was sitting at the time. Note that this is a different column from CongressDum above, and confusing the two is an easy mistake to make. |
| (two blank names) | not described | The header row ends with two commas and no names after them, so most software will show two empty columns at the right-hand edge. They contain nothing. Ignore them. |
Television news stories
Collected by Joseph Uscinski from the Vanderbilt Television News Archive and distributed through the Comparative Agendas Project.
- One row is one evening news story from ABC, CBS or NBC, coded into an issue category.
- Coverage 1968 to 2010, described by the project as over 65,000 stories. The chart shown in class used 53,915 of them covering 1968 to 2009.
- How it was sampled, which you must disclose only the top two stories from each program on each available weekday were coded. The author checked this against a sample drawn from whole programs and found a correlation of 0.9, which is the basis for treating the top-two sample as unbiased. CNN and Fox appear only on the days the archive happens to hold them.
- Its own topic scheme this file does not use the standard twenty-one topics. It uses a modified list that adds categories the other files do not have, such as weather and natural disasters, fires, death notices, campaigns, family issues, religion, and culture and entertainment. The numbers 9, 11, 22, 23, 25 and 29 are not used.
- Its columns are not in the codebook the published codebook describes the coding scheme but never prints the column names. They have been read off the file itself and are listed below.
What this can tell you
What broadcast television treated as the day's leading news across four decades, which is a completely independent measurement of the media agenda from the print record.
What this cannot tell you
Anything after 2010, anything about cable news in general, and anything about the stories that ran third or later in a broadcast. It is also the one file here that will not line up with the twenty-one topic codes without manual work.
Every column in this file, explained
Read directly from the file's header row, because the codebook does not list them. Note that two of these names contain spaces and one contains a hash character, which will need quoting in most code.
| Column in the file | What it contains |
|---|---|
Year | The calendar year the story aired. This is the column you will group by. |
Month | The month the story aired, as a number from 1 to 12. |
Day of Month | The day of the month the story aired. The space in the name means you will need to write it in quotation marks in most code. |
Day of Week | Which weekday the story aired on. Only weekdays were coded, so weekends are absent entirely rather than empty. |
Channel | Which network broadcast the story. ABC, CBS and NBC are present throughout; CNN and Fox appear only on the days the Vanderbilt archive happens to hold them, so do not compare networks without first checking how many days each one actually covers. |
Story # | Whether this was the first or the second story in that night's broadcast, since only the top two were coded. The hash character in the name will need quoting in code. |
Topic | The issue category. This uses the modified scheme listed below, not the standard twenty-one topics, so you cannot join it straight onto the other files without building a crosswalk yourself. |
Quarter | Which quarter of the year the story fell in, from 1 to 4. Useful because quarterly counts are far less noisy than daily ones. |
There is no text
column in this file. You get a topic number and nothing else, which means keyword
searching is not possible here. Your only route to an issue is the Topic
code, and the categories are broad.
| 1 | Macroeconomics, including stock reports |
| 2 | Civil rights, including human rights and the treatment of prisoners |
| 3 | Health issues, excluding health care and Medicaid |
| 4 | Agriculture |
| 5 | Labor and employment |
| 6 | Education |
| 7 | Environment |
| 8 | Energy, including oil and oil prices |
| 10 | Transportation, including transportation disasters and airport security |
| 12 | Law and crime, including trials and crime reports |
| 13 | Social welfare, including health care such as Medicaid |
| 14 | Community development and housing |
| 15 | Banking, finance and domestic commerce, including corporate corruption |
| 16 | Defense |
| 17 | Space, science, technology and communications |
| 18 | Foreign trade |
| 19 | International affairs |
| 20 | Federal government operations, including press conferences and the State of the Union |
| 21 | Public lands and water management |
| 24 | State and local government administration |
| 26 | Weather and natural disasters |
| 27 | Fires |
| 28 | Culture and entertainment, including history |
| 30 | Death notices |
| 31 | Campaigns |
| 32 | Family issues |
| 33 | Immigration, including border issues |
| 34 | Religion |
| 99 | Other or miscellaneous |
Executive orders
Comparative Agendas Project, United States. What a President does without asking Congress, which is a very different signal from what a President says.
- One row is one executive order, with a short description and a topic code.
- Coverage 1945 to 2025, 4,831 orders. This is the most up-to-date of the Comparative Agendas Project files listed here, and it is also the smallest, which makes it the best one to practise on.
- Why it pairs well with the State of the Union one file records what the President asked Congress for and the other records what the President did alone. Comparing the two for the same issue in the same year is a strong memo.
What this can tell you
Which issues Presidents have acted on unilaterally, how that mix changed across administrations, and whether orders cluster at the start or the end of a term.
What this cannot tell you
Whether the order had any effect, whether it survived in court, or whether a later President revoked it.
Every column in this file, explained
| Column in the file | Codebook calls it | What it contains |
|---|---|---|
id | KeyID | A unique identifying number for each row, with no meaning of its own. |
eo_number | EONumber | The executive order's official number. Orders that carried a letter suffix are converted to decimals, so an order numbered A becomes point one, B becomes point two and C becomes point three. |
president | President | The name of the President who signed the order. |
pres_party | PresParty | The President's party, where 100 means Democrat and 200 means Republican. |
beg_term | BegTerm | Set to 1 when the order was issued in the first hundred days of a new term, and 0 otherwise. This is how you test claims about honeymoon periods. |
end_term | EndTerm | Set to 1 when the order was issued after the first of November in a term's final year, and 0 otherwise. This is how you find departing Presidents acting on the way out. |
signed_date | SignedDate | The date of signature, written as an eight-digit number in year, month, day order. |
year, month, day | Year, Month, Day | The same date split into three separate columns for convenience. year is the column you will group by. |
congress | Congress | Which numbered Congress was sitting when the order was issued. |
divided | Divided | Set to 1 when the White House and Congress were controlled by different parties, and 0 when they were not. Useful for testing whether Presidents reach for unilateral action when Congress will not cooperate. |
commemorative | not listed | A flag the codebook does not mention, marking orders that are ceremonial rather than substantive, such as proclaiming a day of observance. Consider excluding these before you count anything, or a burst of commemorative orders will look like a burst of policy attention. |
description | Description | A short description of what the order did. Search this column for your keywords. |
pap_majortopic | PAP_MajorTopic | The major topic code in the older Policy Agendas Project scheme. |
pap_subtopic | PAP_subTopicCode | The subtopic code in the older scheme. |
majortopic | MajorTopic | The major topic code in the current Comparative Agendas Project scheme. This is the column you will group by. |
subtopic | SubTopicCode | The subtopic code in the current scheme. |
The Federal Register
The United States government's own daily journal of rules, proposed rules, notices and presidential documents. This is the only source on this page that is current to today rather than to some year in the past.
- One row is one published document: a final rule, a proposed rule, a notice or a presidential document.
- Coverage 1994 to today for the full-text search, updated every business day. This is what makes it the right tool for any claim about the present.
- How you get it either through the search box on the website, which has a download button, or through the application programming interface, which is a web address that returns data instead of a web page. No account, no key and no payment are required. The official documentation states plainly that all you need is a browser.
- The one conceptual catch the Federal Register has no topic codes of the kind the Comparative Agendas Project files have. You search it by keyword, which means you are the coder, and your keyword list is the measurement instrument. That is why the keyword planner further down this page exists.
What this can tell you
Exactly what the executive branch has formally published about your issue, month by month, right up to this week, with the full text of every document available for reading.
What this cannot tell you
Anything before 1994, anything Congress or the courts did, and anything an agency decided without publishing. A keyword count here is a count of documents mentioning a word, which is not the same thing as a topic code assigned by a human.
How to build a query by hand
The address below is a complete, working
request. Paste it into a browser address bar and you will get data back immediately.
Change the words after term= to your own issue and change the dates to your
own window.
https://www.federalregister.gov/api/v1/documents.json?conditions[term]=mercury&conditions[type][]=RULE&conditions[publication_date][gte]=2024-01-01&conditions[publication_date][lte]=2026-10-31&per_page=100
What each piece of that address does, and what comes back
| Piece | What it does |
|---|---|
conditions[term] | The words to search for in the full text of the document. This is the single most important setting, because it is your definition of the issue. |
conditions[type][] | Which kind of document to return. RULE is a final rule, which is a decision that has taken effect. PRORULE is a proposed rule, which is a decision an agency is considering. NOTICE is an announcement. PRESDOCU is a presidential document. You can repeat this setting to ask for more than one kind at once. |
conditions[publication_date][gte] | The earliest publication date to include, written as year, month, day. The letters stand for "greater than or equal to". |
conditions[publication_date][lte] | The latest publication date to include. The letters stand for "less than or equal to". |
per_page | How many records to return in one response. Ask for a large number so that you are not paging through results one screen at a time. |
fields[] | Optional. Lists exactly which pieces of information you want back, which keeps the response small and readable. Repeat it once per field. |
What comes back. The response is a
block of structured text with four parts at the top level: description,
which restates your search in plain English; count, which is the total
number of matching documents and is often the only number you actually need;
total_pages; and next_page_url, which is the address to
fetch for the next batch. Then comes results, a list of the documents
themselves.
| Field | What it contains |
|---|---|
title | The official title of the document. |
type | Whether it is a Rule, a Proposed Rule, a Notice or a Presidential Document. |
abstract | The agency's own summary of what the document does. |
document_number | The unique reference number, which you should cite in a memo. |
publication_date | The date it appeared in the Federal Register. |
agencies | Which agency or agencies issued it, with an identifying number and a web address for each. |
html_url | The web page for the document, which is the link to put in a footnote. |
pdf_url | A link to the printed page image of the document. |
public_inspection_pdf_url | A link to the version released before formal publication. |
raw_text_url | A link to the complete text of the document as a plain text file. This is the field to use when you want an AI assistant to read whole rules rather than just their titles. |
excerpts | A short passage showing your search words in context, with the matches marked. |
topics | Subject terms where the agency supplied them. This is frequently empty, so do not build an analysis on it. |
More fields exist than the ones above. The interactive documentation page has a "Try it out" button that lists every valid field and lets you build a request by clicking rather than typing, which is the fastest way to learn what is available.
Datasets that are already aggregated for you
Gallup's most important problem, the long series
Comparative Agendas Project, United States. The single longest-running measure of the American public's agenda.
- The question Gallup has asked, since the 1940s, "What do you think is the most important problem facing this country today?" It is open-ended, so people answer in their own words and the answers are coded afterwards.
- One row is one year combined with one topic, carrying the share of mentions that topic received that year. You do not get individual respondents.
- Coverage 1947 to 2023, 1,575 rows.
- How the percentage is built, which matters many polls let people name more than one problem, so a single poll's percentages can add up to more than a hundred. To fix that, each poll's topic percentages are divided by that poll's own total, which makes them sum to one hundred, and then the normalised shares are averaged across all the polls in the year. The result is a share of all mentions, not the share of people who said something.
- Missing data the value −9 means no poll was taken that year, which was the case in 1941, 1943, 1944, 1953 and 1955. Several other early years rest on a single survey. If you leave −9 in your data it will destroy any average you compute.
- One more trap the column named
Percentageactually holds a proportion between zero and one, not a number out of a hundred. The codebook acknowledges the mislabelling.
What this can tell you
How much of the public's spontaneous concern went to your topic in any year since 1947, on the same twenty-one-topic scale as Congress, the courts and the press.
What this cannot tell you
What any individual said, how concern varied by party or region, how intensely people felt, or anything at a finer grain than a year. There is a quarterly version but it stops in 2012, and quarters with no polling were filled in by averaging their neighbours.
Every column in this file, explained
Checked against the file itself:
the header row is id,year,percent,majortopic,Congress. The codebook
refers to a Description column giving the topic name in words, and
that column is not in the file. You will have to join the topic numbers to
the names yourself, using the table in section four.
| Column in the file | Codebook calls it | What it contains |
|---|---|---|
id | ID | A unique identifying number for each row, with no meaning of its own. |
year | Year | The year the polls were conducted. No question was asked in 1953 or 1955. |
percent | Percentage | The share of all mentions that went to this topic in this year, stored as a proportion between zero and one despite what the name suggests. A value of 0.347958 means roughly 35 per cent. Multiply by one hundred before you put it on a chart. The very first rows, for 1946, are blank rather than zero. |
majortopic | MajorTopic | The topic code, running from 1 to 21 plus 25. The code 25 is the "don't know or other" category and should normally be excluded before you compute shares. |
Congress | not listed | Which numbered Congress was sitting that year. The codebook does not mention this column, but it is in the file, and it is useful for joining this series to legislative data. Note that it is the only column in this file with a capital letter. |
Gallup's most important problem, 2020 to 2026, month by month
Compiled for LPPP 6350 from Gallup's own published releases. This is the file behind the first chart in the gallery above.
- Why it exists the Comparative Agendas Project file is annual and stops in 2023. If you need the public's agenda during the last few years at monthly resolution, it has to be assembled from Gallup's individual monthly releases, which is what this is.
- One row is one month, with a column for each of six tracked categories.
- Coverage January 2020 to October 2026, 81 survey waves.
- It is deliberately honest about gaps a companion file records, for every month and category, the raw value as Gallup printed it, whether that value was a reported number or a dash meaning less than half a per cent, Gallup's own category label, and the web address of the release it came from. Every number can be traced back to its source document.
Ask before you use this one. These two files live in the course materials rather than on a public archive. If you want them for a memo, ask and they will be posted. The point of listing them here is that assembling a series like this yourself is a perfectly good piece of memo work, and now you know what it involves: find the releases, read the numbers off, record where each one came from, and be explicit about what a dash means.
The columns in both files
| Column | What it contains |
|---|---|
month | The month of the survey wave, written as year then month. |
government | The percentage naming government, poor leadership or Congress as the most important problem. |
immigration | The percentage naming immigration. |
inflation | The percentage naming inflation or the high cost of living. Blank before Gallup began reporting it separately. |
economy | The percentage naming the economy in general terms. |
covid | The percentage naming coronavirus or disease. Deliberately not carried forward after Gallup stopped reporting it separately. |
race | The percentage naming race relations or racism. |
economic_net | Gallup's own combined total for all economic problems, which is not the sum of the individual economic columns above. |
source_url | The web address of the Gallup release the row was read from. |
wave_note | Any note about that particular survey wave. |
| Column | What it contains |
|---|---|
month | The month of the survey wave. |
issue | Which tracked category this row records. |
value_percent | The value used in the chart, as a number. |
raw_value | Exactly what Gallup printed, including a dash where the category fell below half a per cent. |
status | How the value was obtained: a reported whole number, or a dash treated as zero, and so on. This is the column that keeps the file honest. |
original_category | Gallup's own wording for the category, which changes over time. |
source_url | The web address of the release. |
pdf_id | Gallup's internal identifier for the release document. |
Google Trends
Google. A measure of what people were curious enough about to type into a search box, available within a day or two of the present.
- What the numbers mean Trends does not give you a count of searches. It gives you an index from 0 to 100, where 100 is the highest point in whatever window and place you asked about, and every other point is scaled against it. A value of 50 means half the peak. The index is built from a sample of searches rather than all of them.
- The single most important rule the scale is created fresh for every query. Looking up two terms separately gives you two numbers that cannot be compared, because each was scaled against its own peak. If you want to compare terms, you must put them in the same query. Every comparison in the lecture was done this way.
- How to download it go to Google Trends, enter your terms, set the country and the date range, and use the download control on the "interest over time" panel. It gives you a comma-separated values file with one row per period.
- Known limitations terms that few people search return zero, because Trends only reports on terms with enough volume. Repeated searches by the same person in a short period are removed. Queries containing apostrophes and other special characters are filtered out. And because it is a sample, two downloads of the same query can differ slightly.
What this can tell you
Whether public curiosity about your issue rose or fell, when exactly it moved, and how it compares to other issues measured in the same query. It is unbeatable for speed and for pinning a spike to a date.
What this cannot tell you
How many people searched, who they were, what they thought, or whether the issue matters. Searching about something is evidence of attention and nothing more. It also cannot be compared across separately run queries, which is the mistake almost everyone makes.
Section four The 21 topic codes The scheme that lets you put Congress and the Court on one axis
Six of the files above are coded into this one scheme, and that is what makes them comparable. When a chart in the lecture put Congress and the Supreme Court on the same axis, this table is the reason it was allowed to.
Three rules that are worth knowing before you use these. First, every single record gets exactly one code, so an issue that genuinely spans two areas has been forced into one of them by a human coder. Second, subtopic codes begin with their major topic's number, so every subtopic of transportation, which is 10, falls between 1000 and 1099. Third, coding follows the predominant policy area and not the group affected or the tool used, so a mental health program for veterans is coded as health rather than as veterans' affairs.
The numbers 11 and 22 are not used. That is not an error in your file.
| Code | Topic | Examples of what lands here |
|---|---|---|
| 1 | Macroeconomics | Inflation, unemployment as an economic condition, interest rates, the federal budget deficit, taxation in general |
| 2 | Civil rights | Discrimination, voting rights, minority and disability rights, privacy, freedom of speech, abortion |
| 3 | Health | Health insurance, drug coverage, medical research, hospitals, mental health, tobacco |
| 4 | Agriculture | Farm subsidies, food inspection, agricultural trade, animal and crop disease |
| 5 | Labor | Worker safety, employment training, the minimum wage, unions, parental leave |
| 6 | Education | Schools, higher education, student loans, special education, vocational training |
| 7 | Environment | Air and water pollution, drinking water, recycling, species protection, climate |
| 8 | Energy | Electricity, oil and gas, nuclear power, coal, alternative energy, conservation |
| 9 | Immigration | Immigration law, refugees, border enforcement, citizenship |
| 10 | Transportation | Roads, aviation, rail, mass transit, maritime, vehicle safety |
| 12 | Law and crime | Policing, prisons, drug enforcement, courts, firearms, juvenile crime, family issues |
| 13 | Social welfare | Poverty assistance, food programs, child care, elderly and disabled assistance, social services |
| 14 | Housing | Housing assistance, homelessness, urban and rural development, community development |
| 15 | Domestic commerce | Banking, securities, bankruptcy, small business, consumer protection, insurance, copyright |
| 16 | Defense | Military readiness and procurement, veterans' affairs, arms control, intelligence, military aid |
| 17 | Technology | Space, science research, telecommunications, broadcasting, computers, weather forecasting |
| 18 | Foreign trade | Trade agreements, tariffs, export promotion, exchange rates, competitiveness |
| 19 | International affairs | Foreign aid, diplomacy, international organisations, human rights abroad, developing countries |
| 20 | Government operations | The civil service, government procurement, postal service, the census, elections and campaign finance, the District of Columbia |
| 21 | Public lands | National parks, water resources, public land management, Native American affairs, territories |
| 23 | Culture | Arts, entertainment and cultural policy |
The examples above are illustrative. The authoritative definitions, including every subtopic, are in the master codebook. Read the entry for your own topic before you commit to it, because several issues sit somewhere you would not guess: abortion is coded under civil rights, firearms under law and crime, and veterans' affairs under defense.
Section five From download to answer, step by step Empty folder to defensible claim, step by step
This assumes you have never done this before. Every step says exactly what to type, where the file goes, and how to tell whether it worked. Work through it once with any dataset and you will not need it again.
Read this before you start. An AI assistant will answer confidently about a column that does not exist in your file. It will invent plausible column names, silently drop rows it could not parse, and produce a tidy-looking table built on nothing. This is not a reason to avoid using one. It is the reason step four and step nine exist, and skipping either of them is how people end up defending a number they cannot reproduce.
-
Write down your question in one sentence
Before you touch a file, finish this sentence: "I want to know whether attention to ___ in ___ went up or down between ___ and ___." Fill in the issue, the arena, and the two years. If you cannot finish that sentence, no dataset will help you, and you will spend an hour downloading things and come away with nothing.
-
Pick the file that can actually answer it
Match the arena in your sentence to a dataset in section three, then check two things against it before you download anything:
- Does its coverage include both of your years? Several of these files end well before the present. Congressional hearings stop in 2021, the Supreme Court file in 2023, the New York Times Index in 2016, and the television news file in 2010. If your question is about this year, the Federal Register is the only option on this page.
- Is it a one-row-per-document file or an already-aggregated one? If you need to define your issue yourself rather than accept somebody else's category, you need a one-row-per-document file.
-
Download it, and know where it went
Click the download link. Your browser will put the file in your Downloads folder without asking. On a Mac that is
/Users/yourname/Downloadsand on Windows it isC:\Users\yourname\Downloads.- Move it somewhere deliberate. Make a folder for this memo, for example
Documents/memo4-agenda, and move the file into it. Everything afterwards is easier if you know where the file is, and Downloads is where files go to get lost. - If the file arrives as a .zip, double-click it. On both Mac and Windows that creates a folder of the same name beside it. The file you want is inside.
- If the file opens in a browser tab instead of downloading, which happens with some of these links, right-click the link and choose "Save link as" or "Download linked file".
- Move it somewhere deliberate. Make a folder for this memo, for example
-
Open it and look at it, before you do anything clever
Double-click the file. It will open in Excel or Numbers. Spend two minutes doing exactly three things, and write the answers down somewhere you can see them:
- Read the header row and copy the column names into a note. These are the real names, including capital letters and underscores, and they are what you will hold the AI assistant to. Expect them to differ from the codebook, sometimes a lot: the tables in section three give you both spellings for every file.
- Scroll to the bottom and note how many rows there are.
- Find the earliest and latest year actually present, which is not always what the documentation claims.
If the file is too big for Excel to open, which will happen with congressional hearings and the New York Times Index, you do not need Excel. Upload the file directly to your AI assistant, or open it in Google Sheets, which handles larger files. You can also just read the first few lines: on a Mac, open the Terminal application and type
head -3followed by a space and then drag the file onto the window, which fills in its path, then press return. -
Put the file in front of your AI assistant
How you do this depends on which one you use, and all three of these work:
- Upload it. Every major assistant has a paperclip or plus button that attaches a file to the conversation. This is the simplest route and the one to use first.
- Point a desktop tool at the folder. Assistants that run on your computer can be given access to a folder and then told the filename. This is better for large files, because nothing has to be uploaded.
- Ask it to write code instead. If the file is very large, ask for a short script you run yourself. You do not have to understand the script to check its output against the raw file.
-
First prompt: make it describe the file back to you
Do not ask your real question yet. Ask it to tell you what it sees. If what comes back does not match the notes you made in step four, stop, because everything after this point would be built on sand.
I have attached a comma-separated values file. Before answering anything else, do exactly this and nothing more: 1. List every column name, spelled exactly as it appears in the header row. 2. Tell me how many rows the file has, not counting the header. 3. For each column, show me three example values taken from real rows. 4. Tell me the earliest and the latest year that actually appear in the data. 5. Tell me which columns have blank or missing values, and how many. Do not summarise the file, do not draw conclusions, and do not guess at anything that is not in the file. If a column I might expect is absent, say so plainly.
-
Second prompt: find your issue inside the file
This is the step where you turn a policy issue into a filter. Fill in your own terms, or use the planner in the next section to generate this prompt already filled in. The reason the prompt asks for both a keyword search and a topic-code count is that the two will disagree, and the disagreement is informative: it tells you whether the official coders saw your issue the same way you do.
My policy issue is: [YOUR ISSUE]. The words and phrases that would appear in a document about it are: [TERM 1], [TERM 2], [TERM 3], [TERM 4], [TERM 5]. Using the attached file, do two separate things and keep them clearly apart. FIRST, a keyword search. Search the text description column for any of my terms, case-insensitively. Tell me how many rows match, show me ten matching rows in full, and show me ten rows that contain one of my terms but that you think are NOT really about my issue, so I can see what my terms are catching by accident. SECOND, a topic-code count. Ignore my keywords entirely. Count how many rows fall into each major topic code, and tell me which code my issue most likely belongs to based on what you see in the matching rows. Then tell me how much the two sets overlap, and name the biggest disagreement between them. Quote real values from the file. Do not infer, estimate, or fill in gaps.
-
Third prompt: build the series you are going to plot
Attention has to become a number per period. Ask for counts and shares together, every time, because they can move in opposite directions and you need to know which story you are telling.
Now build me a table with one row per year, covering [START YEAR] to [END YEAR], with these four columns: year n_issue how many rows that year matched my issue n_total how many rows there were that year in total share n_issue divided by n_total, as a percentage with one decimal place Rules: - Include years with zero matches as rows with zero, do not skip them. - Do not fill in, interpolate, or smooth any year. - If a year is missing from the file entirely, list it separately as missing rather than showing it as zero. - At the end, tell me the three years with the highest share and the three with the lowest, and say in one sentence whether the count and the share tell the same story or different ones. Give me the table as text I can paste into a spreadsheet.
-
Check the work against the raw file. This step is not optional.
Pick one year from the table you just received, ideally a high one, and verify it by hand. Open the file in Excel, filter to that year, filter to your keyword, and count the rows. If the number does not match, the whole table is wrong and you need to find out why before you go further.
I want to check your work. For the single year [YEAR]: 1. List every row you counted as matching my issue, showing the row number from the file and the full text of the description column. 2. State the exact filter you applied, written out so I could reproduce it by hand in Excel. 3. Tell me every row you excluded that contained one of my terms, and why you excluded it. If you cannot produce this list from the file itself, say so directly instead of reconstructing it from memory.
-
Make the figure, and label it honestly
Whatever you plot, the caption has to carry four things, because a reader cannot evaluate your claim without them: the source, the unit of observation, the coverage years, and whether you are showing a count or a share. The source lines under every figure in section two are models for this.
Make a single line chart of the share column against year, from the table above. - Label the vertical axis with what the number actually is, including the word "share" and the units. - Do not start the vertical axis anywhere other than zero. - Mark no more than three events on the chart, and only events I give you. - Write a caption that states: the dataset name, what one row in it is, the years covered, and that the line is a share rather than a count. - Do not add a trend line, and do not describe the pattern as a trend unless I ask you to test for one.
-
Write the sentence you came for
Go back to the sentence from step one and fill it in with the number you now have. Then add the limitation that matters most, which is usually either the coverage end date or the fact that your keyword list is a judgement call rather than an official code. A memo that states its own limitation is more persuasive than one that hopes nobody notices.
Section six Build your keyword plan Your list of search terms is your measurement instrument
For the Federal Register, and for any keyword search in the other files, your list of search terms is your measurement instrument. A thin list undercounts your issue and a sloppy one catches things that have nothing to do with it. Fill this in and the page will write your prompts for you, with your own terms already in place.
How to think about each box. Policy documents are written in the government's vocabulary, not the newspaper's. A rule about what you would call "food stamps" says "Supplemental Nutrition Assistance Program" and then says "SNAP" forty times. If your list only has the words you would use in conversation, you will find almost nothing and conclude, wrongly, that nobody is paying attention.
These are yours. Copy each one into your AI assistant in order, with the data file attached. Anything still in square brackets is something only you can decide.
Section seven Before you write it up Five things that turn a confident memo into a wrong one
Five things that turn a confident memo into a wrong one. Every one of these has happened in this course before.
These files end on different dates
Congressional hearings stop in 2021. The Supreme Court file stops in 2023. The New York Times Index stops in 2016 and the television news file stops in 2010. A chart that puts them side by side and runs to the right-hand edge is telling a reader that attention collapsed, when in fact the data simply ran out. Either cut every series at the earliest common end date, or mark clearly where each one stops.
A share and a count are different claims
Congress held far more hearings in the 1970s than it does now. An issue can therefore hold a larger share of a shrinking agenda while the absolute number of hearings about it falls. Both facts are true and they support opposite sentences. Say which one you computed, and when they disagree, that disagreement is usually the most interesting thing you have found.
A keyword count is not a topic code
When a human coder assigns a topic to a hearing, they have read the description and made a judgement. When you count documents containing a word, you have done something cruder, and it will both miss documents that discuss your issue in other language and catch documents that mention your word in passing. Keyword counts are legitimate. Call them what they are, and report how many false matches you found.
Google Trends numbers only compare within one query
Every Trends query is scaled so that its own peak equals one hundred. Two terms looked up separately produce two numbers that mean nothing next to each other. If you want to say one issue drew more search attention than another, both terms have to have been in the same query. This is the single most common error made with this source.
Your assistant will invent a column
Asked for something a file does not contain, an AI assistant will frequently produce a clean, plausible, entirely fabricated answer rather than saying it cannot. The defence is cheap: make it list the real column names first, and verify one year by hand against the raw file. If it cannot show you the rows it counted, it did not count them.
What a good claim sounds like
"Congressional hearings mentioning lead in drinking water rose from 0.2 per cent of all hearings in 2014 to 1.1 per cent in 2016, the year after Flint, and had returned to 0.4 per cent by 2019. Source: Comparative Agendas Project congressional hearings file, one row per hearing, 1946 to 2021; shares computed by the author from a keyword search of the description field, which is a coarser instrument than the project's own topic codes."
Section eight How these figures were made The Python behind every chart on this page
Every chart on this page was produced by a short Python script reading a data file that is also on this page. Both are below. Nothing here is hidden behind a plotting tool you cannot see into, and you are welcome to take any of it apart, change it, or reuse it for your own issue.
What you need to run them
Python 3, with matplotlib and numpy installed. On
most machines that is one line in a terminal:
pip install matplotlib numpy. Nothing else is required, and
none of these scripts goes to the internet — they read the files in
data/ and write a picture.
How to run one
From inside this folder, each script takes the data folder and the name of
the image to write. For example:
python3 code/gallupmip.py data/gallup_most_important_problem_2020_2026.csv mine.png
— which will reproduce the first figure on this page exactly.
A few take an extra argument; the comment at the top of each file says what
it expects.
The typeface is included
These set their type in Questrial, which is the typeface for this course.
Questrial-Regular.ttf sits beside this page and each script
loads it from there, so your output should match what you see above. If you
move a script somewhere else and the font is not found it simply falls back
to the matplotlib default; the numbers are unaffected.
What the public says is the most important problem — gallupmip.py
Reads the monthly Gallup percentages straight out of the comma-separated values file and draws one line per category, with each line labelled at its right-hand end instead of in a separate legend box.
Image: fig/gallup_most_important_problem_2020_2026.png
Reads: data/gallup_most_important_problem_2020_2026.csv
# -*- coding: utf-8 -*-
"""Gallup Most Important Problem, 2020-2026, with the series keyed on the
figure itself rather than in slide text boxes.
python3 -I code/gallupmip.py <data.csv> <out.png>
"""
import csv, os, sys
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib import font_manager as fm
SRC, OUT = sys.argv[1], sys.argv[2]
_ttf = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'Questrial-Regular.ttf')
if os.path.exists(_ttf):
fm.fontManager.addfont(_ttf)
F = 'Questrial'
GROUND = '#0C1120'; INK = '#F0F3F7'; INK2 = '#B4BDC9'
INK3 = '#8792A3'; INK4 = '#59626F'; HAIR = '#242C39'
# column -> (label on the figure, colour) — colours sampled from the version
# used in the Lecture 18 deck so the two stay in step
SERIES = [
('government', 'Government', '#69A5E4'),
('immigration', 'Immigration', '#FFD7A3'),
('inflation', 'Inflation', '#E0736A'),
('economy', 'Economy (general)', '#5DC587'),
('covid', 'COVID-19', '#B699E4'),
('race', 'Race relations', '#8792A3'),
]
rows = list(csv.DictReader(open(SRC)))
months = [r['month'] for r in rows]
x = list(range(len(months)))
fig = plt.figure(figsize=(16, 5.2), dpi=100)
fig.patch.set_facecolor(GROUND)
ax = fig.add_axes([0.052, 0.175, 0.73, 0.70])
ax.set_facecolor(GROUND)
ends = []
for col, lab, c in SERIES:
xs, ys = [], []
for i, r in enumerate(rows):
v = r[col].strip()
if v == '':
continue
xs.append(i); ys.append(float(v))
ax.plot(xs, ys, color=c, lw=2.0, solid_capstyle='round')
if xs:
ends.append([ys[-1], lab, c, xs[-1]])
# keep the end labels from colliding
ends.sort(key=lambda e: -e[0])
SEP = 2.6
for i in range(1, len(ends)):
if ends[i - 1][0] - ends[i][0] < SEP:
ends[i][0] = ends[i - 1][0] - SEP
for yv, lab, c, xe in ends:
ax.annotate(lab, xy=(len(months) - 0.6, yv), xycoords='data',
xytext=(6, 0), textcoords='offset points',
color=c, fontsize=15, fontfamily=F, va='center')
ax.set_ylim(0, 52)
ax.set_xlim(-0.5, len(months) - 0.5)
ticks = [i for i, m in enumerate(months) if m.endswith('-01')]
ax.set_xticks(ticks)
ax.set_xticklabels([months[i][:4] for i in ticks], fontsize=14,
fontfamily=F, color=INK3)
ax.set_yticks([0, 10, 20, 30, 40, 50])
ax.set_yticklabels(['0%', '10%', '20%', '30%', '40%', '50%'], fontsize=13,
fontfamily=F, color=INK3)
ax.tick_params(length=0, pad=8)
for sp in ax.spines.values():
sp.set_visible(False)
ax.grid(axis='y', color=HAIR, lw=0.9)
ax.set_axisbelow(True)
fig.text(0.052, 0.945, 'What the public says is the most important problem',
color=INK, fontsize=22, fontfamily=F)
fig.text(0.052, 0.895,
'Select volunteered responses from U.S. adults, January 2020 to '
'October 2026', color=INK3, fontsize=14, fontfamily=F)
fig.text(0.052, 0.045,
'Gallup, Most Important Problem; 81 survey waves. Latest field '
'period: Oct. 1–19, 2026. Multiple responses permitted. Values '
'below 0.5% and unreported categories are omitted;',
color=INK4, fontsize=11.5, fontfamily=F)
fig.text(0.052, 0.012,
'COVID-19 is not extended after separate reporting ends. LPPP 6350.',
color=INK4, fontsize=11.5, fontfamily=F)
fig.savefig(OUT, facecolor=GROUND)
print('saved', OUT)
What the public has actually been on, these last two months — rightnow.py
Turns the Google Trends monthly series into one average per topic over the two most recent complete months, sorts them, and draws a lollipop for each. The warm colour marks the top three; it is emphasis, not a separate category.
Image: fig/out_10_rightnow_lollipop.png
Reads: data/citizen_google_trends.json
# -*- coding: utf-8 -*-
"""Two figures: what the public is on right now, and how the class compares."""
import json, sys, os
import matplotlib
matplotlib.use('Agg')
from matplotlib import font_manager as fm, pyplot as plt
DDIR, OUTDIR = sys.argv[1], sys.argv[2]
STUDENTS = sys.argv[3] if len(sys.argv) > 3 else 'DEMO'
fm.fontManager.addfont(os.path.expanduser(
'~/mnt/UVA/Fall 2026/Slides/Questrial-Regular.ttf'))
plt.rcParams['font.family'] = 'Questrial'
G, INK, INK2, INK3, INK4, HAIR = ('#0C1120', '#F0F3F7', '#B4BDC9', '#8792A3',
'#59626F', '#242C39')
WARM, ACC, TEAL, ALERT, MARK = '#FFD7A3', '#6BA8E8', '#5FC98A', '#E8776D', '#E57200'
TOPIC = ['Immigration', 'Health care', 'Taxes', 'Education', 'Abortion',
'Guns', 'Climate', 'Crime', 'Housing']
g = json.load(open(os.path.join(DDIR, 'citizen_google_trends.json')))
mi = {m: i for i, m in enumerate(g['months'])}
LAST2 = ['2026-09', '2026-10']
share = {}
tot = sum(sum(g['series'][t][mi[m]] for m in LAST2) for t in TOPIC)
for t in TOPIC:
share[t] = 100.0 * sum(g['series'][t][mi[m]] for m in LAST2) / tot
# ---------------------------------------------------------------- lollipop
order = sorted(TOPIC, key=lambda t: share[t])
fig, ax = plt.subplots(figsize=(13.333, 7.5))
fig.patch.set_facecolor(G); ax.set_facecolor(G)
for s in ax.spines.values(): s.set_visible(False)
ax.grid(axis='x', color=HAIR, lw=.8); ax.set_axisbelow(True)
ax.tick_params(colors=INK3, labelsize=12, length=0)
for i, t in enumerate(order):
hot = share[t] >= sorted(share.values())[-3]
c = WARM if hot else ACC
ax.plot([0, share[t]], [i, i], color=c, lw=3, alpha=.55 if not hot else .9,
solid_capstyle='round', zorder=2)
ax.plot(share[t], i, 'o', ms=17, mfc=c, mec=G, mew=2, zorder=3)
ax.text(share[t] + .75, i, '%.0f%%' % share[t], color=c, fontsize=13,
va='center')
ax.set_yticks(range(len(order)))
ax.set_yticklabels(order, color=INK2, fontsize=15)
ax.set_xlim(0, max(share.values()) * 1.16)
ax.set_ylim(-.7, len(order) - .3)
ax.set_xlabel('share of search attention across these nine topics, '
'September–October 2026 (%)',
color=INK2, fontsize=12.5, labelpad=10)
fig.suptitle('What the public has actually been on, these last two months',
color=INK, fontsize=22, x=.035, ha='left', y=.962)
fig.text(.035, .902, 'Google Trends, United States, web search, the two most '
'recent complete months.', color=INK3, fontsize=12.5, ha='left')
fig.text(.035, .03,
'Search interest is a measure of public attention, not of importance. '
'Shares are within this nine-topic set, so they sum to 100. LPPP 6350.',
color=INK4, fontsize=9, ha='left')
fig.subplots_adjust(left=.145, right=.975, top=.845, bottom=.145)
fig.savefig(os.path.join(OUTDIR, 'out_10_rightnow_lollipop.png'), dpi=170,
facecolor=G)
# --------------------------------------------------------------- benchmark
if STUDENTS == 'DEMO':
stud = {'Immigration': 22, 'Health care': 9, 'Taxes': 7, 'Education': 5,
'Abortion': 6, 'Guns': 11, 'Climate': 14, 'Crime': 16, 'Housing': 10}
demo = True
else:
stud = json.load(open(STUDENTS)); demo = False
sv = sum(stud.values()) or 1
stud = {t: 100.0 * stud.get(t, 0) / sv for t in TOPIC}
order = sorted(TOPIC, key=lambda t: share[t])
fig, ax = plt.subplots(figsize=(13.333, 7.5))
fig.patch.set_facecolor(G); ax.set_facecolor(G)
for s in ax.spines.values(): s.set_visible(False)
ax.grid(axis='x', color=HAIR, lw=.8); ax.set_axisbelow(True)
ax.tick_params(colors=INK3, labelsize=12, length=0)
for i, t in enumerate(order):
a, b = stud[t], share[t]
c = ALERT if a > b else TEAL
ax.plot([a, b], [i, i], color=c, lw=3.4, alpha=.75,
solid_capstyle='round', zorder=2)
ax.plot(a, i, 'o', ms=15, mfc=MARK, mec=G, mew=2, zorder=4)
ax.plot(b, i, 'o', ms=15, mfc=ACC, mec=G, mew=2, zorder=4)
ax.text(max(a, b) + .8, i, '%+.0f' % (a - b), color=c, fontsize=12.5,
va='center')
ax.set_yticks(range(len(order)))
ax.set_yticklabels(order, color=INK2, fontsize=15)
hi = max(max(stud.values()), max(share.values())) * 1.17
ax.set_xlim(0, hi); ax.set_ylim(-1.5, len(order) - .3)
ax.plot(hi * .30, -1.15, 'o', ms=15, mfc=MARK, mec=G, mew=2, clip_on=False)
ax.text(hi * .325, -1.15, 'what this class said', color=MARK, fontsize=13,
va='center')
ax.plot(hi * .60, -1.15, 'o', ms=15, mfc=ACC, mec=G, mew=2, clip_on=False)
ax.text(hi * .625, -1.15, 'what the search data says', color=ACC, fontsize=13,
va='center')
ax.set_xlabel('share of attention (%)', color=INK2, fontsize=12.5, labelpad=10)
fig.suptitle('You said the agenda was one thing. The data says another.',
color=INK, fontsize=22, x=.035, ha='left', y=.962)
fig.text(.035, .902,
'Orange is the share of your answers that named each topic. Blue is its '
'share of US search attention over September–October 2026.',
color=INK3, fontsize=12.5, ha='left')
if demo:
ax.text(hi * .5, len(order) * .52, 'ILLUSTRATIVE — no responses yet',
color='#3A4350', fontsize=34, ha='center', va='center',
rotation=14, zorder=1)
fig.text(.035, .03,
'Student answers coded to the same nine topics as the search series; a '
'response naming several topics counts once for each. LPPP 6350.',
color=INK4, fontsize=9, ha='left')
fig.subplots_adjust(left=.145, right=.975, top=.845, bottom=.145)
fig.savefig(os.path.join(OUTDIR, 'out_11_class_vs_data.png'), dpi=170,
facecolor=G)
print('saved out_10_rightnow_lollipop.png, out_11_class_vs_data.png')
print(' last-2-month ranking:', ', '.join(
'%s %.0f%%' % (t, share[t]) for t in sorted(TOPIC, key=lambda t: -share[t])))
Where the agenda actually is, right now — now2x2.py
Four panels on one figure, each a different arena measured over the same recent window, plus a fourth panel that asks whether the arenas agree.
Image: fig/out_9_now_2x2.png
Reads: data/citizen_google_trends.json, data/executive_federal_register.json, data/president_federal_register.json
# -*- coding: utf-8 -*-
"""Where the agenda is right now: three arenas, one topic set, 14 months."""
import json, sys, os
import matplotlib
matplotlib.use('Agg')
from matplotlib import font_manager as fm, pyplot as plt
DDIR, OUT = sys.argv[1], sys.argv[2]
fm.fontManager.addfont(os.path.expanduser(
'~/mnt/UVA/Fall 2026/Slides/Questrial-Regular.ttf'))
plt.rcParams['font.family'] = 'Questrial'
G, INK, INK2, INK3, INK4, HAIR = ('#0C1120', '#F0F3F7', '#B4BDC9', '#8792A3',
'#59626F', '#242C39')
TOPIC = ['Immigration', 'Health care', 'Taxes', 'Education', 'Abortion',
'Guns', 'Climate', 'Crime', 'Housing']
CMAP = {'Immigration': '#E8776D', 'Health care': '#6BA8E8', 'Taxes': '#FFD7A3',
'Education': '#5FC98A', 'Abortion': '#C49BE0', 'Guns': '#E57200',
'Climate': '#4FB3BF', 'Crime': '#D4A0B8', 'Housing': '#9BA6B5'}
ALIAS = {'Climate': ['Climate', 'Climate & energy']}
MONTHS = ['2025-09', '2025-10', '2025-11', '2025-12', '2026-01', '2026-02',
'2026-03', '2026-04', '2026-05', '2026-06', '2026-07', '2026-08',
'2026-09', '2026-10']
HL = 6 # the last six months
def load(fn):
return json.load(open(os.path.join(DDIR, fn)))
def align(d):
"""One arena, aligned to MONTHS, each topic as a share of the month total."""
mi = {m: i for i, m in enumerate(d['months'])}
raw = {}
for t in TOPIC:
for key in ALIAS.get(t, [t]):
if key in d['series']:
raw[t] = [d['series'][key][mi[m]] if m in mi else None
for m in MONTHS]
break
else:
raw[t] = [None] * len(MONTHS)
out = {t: [] for t in TOPIC}
for i in range(len(MONTHS)):
tot = sum(raw[t][i] for t in TOPIC if raw[t][i] is not None)
for t in TOPIC:
v = raw[t][i]
out[t].append(100.0 * v / tot if (v is not None and tot) else None)
return out
PANEL = [('Citizens', 'what people search for',
align(load('citizen_google_trends.json'))),
('The President', 'presidential documents issued',
align(load('president_federal_register.json'))),
('The bureaucracy', 'final rules published',
align(load('executive_federal_register.json')))]
fig, axes = plt.subplots(2, 2, figsize=(13.333, 7.5))
fig.patch.set_facecolor(G)
xs = list(range(len(MONTHS)))
cut = len(MONTHS) - HL
for ax, (name, sub, data) in zip(axes.flat[:3], PANEL):
ax.set_facecolor(G)
for s in ax.spines.values(): s.set_visible(False)
ax.grid(axis='y', color=HAIR, lw=.7); ax.set_axisbelow(True)
ax.tick_params(colors=INK3, labelsize=9, length=0)
ax.axvspan(cut - .5, len(MONTHS) - .5, color='#161E2E', zorder=0)
rank = sorted(TOPIC, key=lambda t: -sum(
v for v in data[t][cut:] if v is not None))
for t in TOPIC:
y = data[t]
lead = t in rank[:4]
ax.plot(xs[:cut + 1], y[:cut + 1], color=CMAP[t],
lw=2.0 if lead else 1.0, alpha=.32 if lead else .16, zorder=2)
ax.plot(xs[cut:], y[cut:], color=CMAP[t], lw=2.6 if lead else 1.1,
alpha=1.0 if lead else .30, zorder=3,
solid_capstyle='round')
top = max(max(v for v in data[t] if v is not None) for t in TOPIC)
ax.set_ylim(-top * .06, top * 1.26)
ax.set_xlim(-.5, len(MONTHS) - .5 + 3.2)
# push the end labels apart so none of them overprint
lo, hi = ax.get_ylim()
gap = (hi - lo) * .085
lab = sorted([(data[t][-1], t) for t in rank[:4]
if data[t][-1] is not None])
placed = []
for yv, t in lab:
y = yv if not placed else max(yv, placed[-1][0] + gap)
placed.append((y, t))
over = placed[-1][0] - (hi - gap * .4) if placed else 0
if over > 0:
placed = [(y - over, t) for y, t in placed]
for y, t in placed:
ax.text(len(MONTHS) - .2, y, t, color=CMAP[t], fontsize=9.5,
va='center')
ax.set_xticks([0, 4, 8, cut, 13])
ax.set_xticklabels(['Sep\n2025', 'Jan\n2026', 'May', 'last 6\nmonths',
'Oct'], fontsize=8.5)
ax.set_title('%s · %s' % (name, sub), color=INK, fontsize=13,
loc='left', pad=8)
ax.set_ylabel('share of attention (%)', color=INK4, fontsize=9)
# fourth panel: the comparison the three above are building to
ax = axes.flat[3]
ax.set_facecolor(G)
for s in ax.spines.values(): s.set_visible(False)
ax.grid(axis='x', color=HAIR, lw=.7); ax.set_axisbelow(True)
ax.tick_params(colors=INK3, labelsize=9, length=0)
MK = {'Citizens': 'o', 'The President': 's', 'The bureaucracy': '^'}
CA = {'Citizens': '#E8776D', 'The President': '#5FC98A',
'The bureaucracy': '#6BA8E8'}
mean6 = {n: {t: (sum(v for v in d[t][cut:] if v is not None) /
max(1, len([v for v in d[t][cut:] if v is not None])))
for t in TOPIC} for n, _, d in PANEL}
order = sorted(TOPIC, key=lambda t: -mean6['Citizens'][t])
ys = list(range(len(order)))[::-1]
for y, t in zip(ys, order):
vals = [mean6[n][t] for n, _, _ in PANEL]
ax.plot([min(vals), max(vals)], [y, y], color=HAIR, lw=4,
solid_capstyle='round', zorder=1)
for n, _, _ in PANEL:
ax.plot(mean6[n][t], y, MK[n], ms=7, mfc=CA[n], mec=G, mew=1.1, zorder=3)
ax.set_yticks(ys); ax.set_yticklabels(order, color=INK2, fontsize=9.5)
ax.set_ylim(-1.9, len(order) - .3)
ax.set_xlabel('mean share over the last 6 months (%)', color=INK4, fontsize=9)
ax.set_title('Do they agree? · last 6 months only', color=INK,
fontsize=13, loc='left', pad=8)
xmax = max(mean6[n][t] for n, _, _ in PANEL for t in TOPIC) * 1.06
ax.set_xlim(-xmax * .03, xmax)
for i, (n, _, _) in enumerate(PANEL):
ax.plot(xmax * (.04 + i * .30), -1.45, MK[n], ms=7, mfc=CA[n], mec=G,
mew=1.1, clip_on=False, zorder=4)
ax.text(xmax * (.08 + i * .30), -1.45, n, color=CA[n], fontsize=9.5,
va='center')
fig.suptitle('Where the agenda actually is, right now',
color=INK, fontsize=21, x=.035, ha='left', y=.975)
fig.text(.035, .925,
'Same nine topics in every panel. Each line is one topic’s share of that '
'arena’s attention that month. The shaded band is the last six months.',
color=INK3, fontsize=11, ha='left')
fig.text(.035, .018,
'Citizens: Google Trends US web search. President: Federal Register presidential documents. Bureaucracy: Federal Register final rules. '
'All monthly, Sep 2025 – Oct 2026,\nconverted to each arena’s own share of attention so the three are comparable. '
'Media and Congress have no comparable monthly feed and are not shown. LPPP 6350.',
color=INK4, fontsize=8.2, ha='left', linespacing=1.7)
fig.subplots_adjust(left=.062, right=.985, top=.845, bottom=.105,
wspace=.26, hspace=.46)
fig.savefig(OUT, dpi=170, facecolor=G)
print('saved', os.path.basename(OUT))
for n, _, d in PANEL:
r = sorted(TOPIC, key=lambda t: -mean6[n][t])[:3]
print(' %-16s last 6 months top: %s' % (n, ', '.join(
'%s %.0f%%' % (t, mean6[n][t]) for t in r)))
The four long arena time series — plainseries.py
Draws one bare chart per arena from the Comparative Agendas Project files and writes a companion file of label positions, so the event markers and series names can sit on the slide as editable text rather than being burned into the image. The versions on this page have those labels drawn back on.
Image: fig/series_congress.png and the three other arenas
Reads: data/cap_legislative.txt, data/cap_judicial.txt, data/cap_sotu.txt, data/cap_media_index.txt, data/cap_media_tv.txt
# -*- coding: utf-8 -*-
"""Bare CAP time series: lines, axes and event rules only.
Every word that is not an axis tick is left off the image and written to a
sidecar JSON in slide inches, so the deck builder can lay it down as real
PowerPoint text.
python3 -I code/plainseries.py <datadir> <outdir>
"""
import json, os, sys, statistics as st
import matplotlib
matplotlib.use('Agg')
from matplotlib import font_manager as fm, pyplot as plt
DDIR, OUT = sys.argv[1], sys.argv[2]
os.makedirs(OUT, exist_ok=True)
fm.fontManager.addfont(os.path.expanduser(
'~/mnt/UVA/Fall 2026/Slides/Questrial-Regular.ttf'))
plt.rcParams['font.family'] = 'Questrial'
G, INK, INK2, INK3, INK4, HAIR = ('#0C1120', '#F0F3F7', '#B4BDC9', '#8792A3',
'#59626F', '#242C39')
PAL = ['#FFD7A3', '#6BA8E8', '#B48BE0', '#5FC98A', '#E8776D', '#E57200']
LAB = {'1': 'Macroeconomics', '2': 'Civil rights', '3': 'Health',
'4': 'Agriculture', '5': 'Labor', '6': 'Education', '7': 'Environment',
'8': 'Energy', '9': 'Immigration', '10': 'Transportation',
'12': 'Law & crime', '13': 'Social welfare', '14': 'Housing',
'15': 'Domestic commerce', '16': 'Defense', '17': 'Technology',
'18': 'Foreign trade', '19': 'Intl affairs', '20': 'Govt operations',
'21': 'Public lands'}
# where the picture sits on the 13.333 x 7.5 slide
IMG = dict(x=0.96, y=1.96, w=11.413, h=4.58)
FIGSIZE = (IMG['w'], IMG['h'])
DPI = 200
def read(fn):
rows = open(os.path.join(DDIR, fn)).read().strip().split(chr(10))
codes = rows[0].split()[1].split(',')
out = {}
for r in rows[1:]:
y, vals = r.split(':')
v = [float(x) for x in vals.split(',')]
tot = sum(v) or 1.0
out[int(y)] = {c: 100.0 * x / tot for c, x in zip(codes, v)}
return out
def roll(v, w=3):
n, h = len(v), w // 2
return [sum(v[max(0, i - h):min(n, i + h + 1)]) /
float(min(n, i + h + 1) - max(0, i - h)) for i in range(n)]
def to_slide(ax, x, y):
"""data point -> inches on the slide"""
bb = ax.get_position()
(x0, x1), (y0, y1) = ax.get_xlim(), ax.get_ylim()
fx = bb.x0 + (x - x0) / float(x1 - x0) * bb.width
fy = bb.y0 + (y - y0) / float(y1 - y0) * bb.height
return IMG['x'] + fx * IMG['w'], IMG['y'] + (1.0 - fy) * IMG['h']
def style(ax, xticks, ylab, ymax):
ax.set_facecolor(G)
for sp in ax.spines.values():
sp.set_visible(False)
ax.grid(axis='y', color=HAIR, lw=.7)
ax.set_axisbelow(True)
ax.tick_params(colors=INK3, labelsize=9.5, length=0)
ax.set_xticks(xticks)
ax.set_ylim(0, ymax)
ax.set_ylabel(ylab, color=INK3, fontsize=9.5)
def series(ax, yrs, d, codes, cols, smooth, labels, xpad, sep=0.225):
"""Draw the lines and place end labels.
Separation has to be enforced in slide inches, not data units: the same
gap in percentage points is a different number of inches in every panel,
and 13pt type needs about a fifth of an inch whatever the y-axis says."""
sm = {c: (roll([d[y][c] for y in yrs]) if smooth else [d[y][c] for y in yrs])
for c in codes}
for c in codes:
if smooth:
ax.plot(yrs, [d[y][c] for y in yrs], color=cols[c], lw=0.8,
alpha=.22, solid_capstyle='round', zorder=2)
ax.plot(yrs, sm[c], color=cols[c], lw=2.4, solid_capstyle='round',
zorder=3)
rows = []
for c in codes:
sx, sy = to_slide(ax, yrs[-1] + xpad, sm[c][-1])
rows.append([sy, sx, c])
rows.sort(key=lambda r: -r[0]) # lowest on the slide first
for i in range(1, len(rows)):
if rows[i - 1][0] - rows[i][0] < sep:
rows[i][0] = rows[i - 1][0] - sep
for sy, sx, c in rows:
labels.append({'t': LAB[c], 'x': sx, 'y': sy, 'col': cols[c],
'sz': 13.0, 'kind': 'series'})
def events(ax, evs, labels, ytop, minsep=1.55, drop=0.27):
"""Dashed rule per event; labels drop to a second row when they crowd."""
pts = []
for x, t in evs:
ax.axvline(x, color=INK4, lw=.9, ls=(0, (2, 3)), zorder=1)
sx, sy = to_slide(ax, x, ytop)
pts.append([sx, sy, t])
rows = []
for i, (sx, sy, t) in enumerate(pts):
r = 1 if (i and sx - pts[i - 1][0] < minsep and rows[i - 1] == 0) else 0
rows.append(r)
labels.append({'t': t, 'x': sx, 'y': sy + drop * r, 'col': INK3,
'sz': 11.0, 'kind': 'event'})
def save(fig, name, labels, meta):
fig.savefig(os.path.join(OUT, name + '.png'), dpi=DPI, facecolor=G)
plt.close(fig)
meta['labels'] = labels
meta['img'] = IMG
json.dump(meta, open(os.path.join(OUT, name + '.json'), 'w'), indent=1)
print(' %-22s %d editable labels' % (name + '.png', len(labels)))
# ---------------------------------------------------------------- 1. media
NYT, TV = read('cap_media_index.txt'), read('cap_media_tv.txt')
CODES = ['19', '16', '20', '12', '15']
COLS = dict(zip(CODES, PAL))
fig, (a1, a2) = plt.subplots(2, 1, figsize=FIGSIZE, sharex=True)
fig.patch.set_facecolor(G)
labels = []
yn, yt = sorted(NYT), sorted(TV)
hi = max(max(max(roll([s[y][c] for y in sorted(s)])) for c in CODES)
for s in (NYT, TV)) * 1.20
for ax, s, ys in ((a1, NYT, yn), (a2, TV, yt)):
style(ax, list(range(1950, 2021, 10)), 'share of stories (%)', hi)
ax.set_xlim(1944, 2030)
fig.subplots_adjust(left=.052, right=.832, top=.985, bottom=.075, hspace=.14)
series(a1, yn, NYT, CODES, COLS, False, labels, 1.5)
series(a2, yt, TV, CODES, COLS, True, labels, 1.5)
events(a1, [(1968, 'Tet'), (1974, 'Watergate'),
(1991, 'Gulf War'), (2001, '9/11'), (2008, 'crash')],
labels, hi * 0.865)
events(a2, [(1974, 'Watergate'), (1991, 'Gulf War'), (2001, '9/11'),
(2008, 'crash')], labels, hi * 0.865)
for ax, t in ((a1, 'PRESS'), (a2, 'TV NEWS')):
sx, sy = to_slide(ax, 1946, hi * 0.975)
labels.append({'t': t, 'x': sx, 'y': sy, 'col': INK3, 'sz': 12.0,
'kind': 'panel'})
save(fig, 'media_nyt_tv', labels,
{'title': 'Two readings of the media agenda',
'kicker': 'THE PRESS AND THE EVENING NEWS',
'source': 'Comparative Agendas Project. New York Times Index: 42,006 stories, 1946–2016. TV News (Uscinski), Vanderbilt Television News Archive: 53,915 ABC, CBS and NBC evening stories, 1968–2009, shown as a three-year average over the annual line. Dashed rules mark events, not breaks in the data. LPPP 6350.'})
# ------------------------------------------------------------- 2. Congress
CON = read('cap_legislative.txt')
CODES = ['20', '21', '16', '3', '15']
COLS = dict(zip(CODES, PAL))
fig, ax = plt.subplots(figsize=FIGSIZE)
fig.patch.set_facecolor(G)
labels = []
ys = sorted(CON)
hi = max(max(roll([CON[y][c] for y in ys])) for c in CODES) * 1.22
style(ax, list(range(1950, 2016, 10)), 'share of hearings (%)', hi)
ax.set_xlim(1945, 2028)
fig.subplots_adjust(left=.052, right=.832, top=.975, bottom=.085)
series(ax, ys, CON, CODES, COLS, True, labels, 1.2)
events(ax, [(1965, 'Great Society'), (1974, 'Budget Act'), (1981, 'Reagan'),
(1995, 'GOP majority'), (2001, '9/11'), (2010, 'ACA')],
labels, hi * 0.865)
save(fig, 'congress', labels,
{'title': 'What Congress holds hearings about',
'kicker': 'THE LEGISLATIVE AGENDA, 1947–2015',
'source': 'Comparative Agendas Project, Congressional Hearings, 1947–2015, coded to the 21 CAP major topics. Each series is a three-year average over the annual line. Dashed rules mark events, not breaks in the data. LPPP 6350.'})
# --------------------------------------------------------- 3. Supreme Court
CRT = read('cap_judicial.txt')
CODES = ['12', '2', '15', '5', '20']
COLS = dict(zip(CODES, PAL))
fig, ax = plt.subplots(figsize=FIGSIZE)
fig.patch.set_facecolor(G)
labels = []
ys = sorted(CRT)
hi = max(max(roll([CRT[y][c] for y in ys])) for c in CODES) * 1.22
style(ax, list(range(1950, 2021, 10)), 'share of cases (%)', hi)
ax.set_xlim(1944, 2036)
fig.subplots_adjust(left=.052, right=.832, top=.975, bottom=.085)
series(ax, ys, CRT, CODES, COLS, True, labels, 1.2)
events(ax, [(1954, 'Brown'), (1973, 'Roe'), (1988, 'docket control'),
(2000, 'Bush v. Gore'), (2010, 'Citizens Utd'), (2022, 'Dobbs')],
labels, hi * 0.865)
save(fig, 'courts', labels,
{'title': 'What the Supreme Court takes',
'kicker': 'THE JUDICIAL AGENDA, 1946–2023',
'source': 'Comparative Agendas Project, US Supreme Court, 10,236 cases, 1946–2023, coded to the 21 CAP major topics. Each series is a three-year average over the annual line. The 1988 rule gave the Court near-total control of its docket. LPPP 6350.'})
# ------------------------------------------------------- 4. the President
SOTU = read('cap_sotu.txt')
CODES = ['1', '19', '16', '3', '20']
COLS = dict(zip(CODES, PAL))
fig, ax = plt.subplots(figsize=FIGSIZE)
fig.patch.set_facecolor(G)
labels = []
ys = sorted(SOTU)
hi = max(max(roll([SOTU[y][c] for y in ys])) for c in CODES) * 1.22
style(ax, list(range(1950, 2026, 10)), 'share of policy sentences (%)', hi)
ax.set_xlim(1944, 2038)
fig.subplots_adjust(left=.052, right=.832, top=.975, bottom=.085)
series(ax, ys, SOTU, CODES, COLS, True, labels, 1.2)
events(ax, [(1964, 'Great Society'), (1981, 'Reagan'), (1993, 'Clinton'),
(2002, '9/11'), (2009, 'crash'), (2021, 'Biden')],
labels, hi * 0.865)
save(fig, 'president', labels,
{'title': 'What the President asks Congress for',
'kicker': 'THE STATE OF THE UNION, 1946\u20132025',
'source': 'Comparative Agendas Project, State of the Union Speeches, '
'20,582 policy quasi-sentences, 1946\u20132025, coded to the 21 CAP '
'major topics. Each series is a three-year average over the annual '
'line; speech length varies a great deal year to year, so shares are '
'steadier than counts. LPPP 6350.'})
Two newsrooms, the same ranking, very different weights — tvnews.py
Puts the television news series beside the New York Times Index series, then plots each topic once as a point so the two codings can be compared directly against a forty-five degree line.
Image: fig/out_18_tv_vs_press.png
Reads: data/cap_media_tv.txt, data/cap_media_index.txt
# -*- coding: utf-8 -*-
"""Two independent readings of the media agenda: NYT Index vs network TV news."""
import sys, os, statistics as st
import matplotlib
matplotlib.use('Agg')
from matplotlib import font_manager as fm, pyplot as plt
DDIR, OUT = sys.argv[1], sys.argv[2]
fm.fontManager.addfont(os.path.expanduser(
'~/mnt/UVA/Fall 2026/Slides/Questrial-Regular.ttf'))
plt.rcParams['font.family'] = 'Questrial'
G, INK, INK2, INK3, INK4, HAIR = ('#0C1120', '#F0F3F7', '#B4BDC9', '#8792A3',
'#59626F', '#242C39')
ACC, WARM, ALERT, TEAL, VIO = '#6BA8E8', '#FFD7A3', '#E8776D', '#5FC98A', '#B48BE0'
LAB = {'1': 'Macroeconomics', '2': 'Civil rights', '3': 'Health',
'4': 'Agriculture', '5': 'Labor', '6': 'Education', '7': 'Environment',
'8': 'Energy', '9': 'Immigration', '10': 'Transportation',
'12': 'Law & crime', '13': 'Social welfare', '14': 'Housing',
'15': 'Domestic commerce', '16': 'Defense', '17': 'Technology',
'18': 'Foreign trade', '19': 'Intl affairs', '20': 'Govt operations',
'21': 'Public lands'}
COL = {'19': WARM, '16': ACC, '12': ALERT, '1': TEAL, '20': VIO,
'15': '#E57200', '3': '#7FD4C1', '10': '#9AA7B8'}
def roll(v, w=3):
n, h = len(v), w // 2
return [sum(v[max(0, i - h):min(n, i + h + 1)]) /
float(min(n, i + h + 1) - max(0, i - h)) for i in range(n)]
def read(fn):
rows = open(os.path.join(DDIR, fn)).read().strip().split(chr(10))
codes = rows[0].split()[1].split(',')
out = {}
for r in rows[1:]:
y, vals = r.split(':')
v = [float(x) for x in vals.split(',')]
tot = sum(v) or 1
out[int(y)] = {c: 100.0 * x / tot for c, x in zip(codes, v)}
return out
def spearman(x, y):
def rk(v):
o = sorted(range(len(v)), key=lambda i: v[i]); r = [0] * len(v); i = 0
while i < len(o):
j = i
while j + 1 < len(o) and v[o[j + 1]] == v[o[i]]: j += 1
for k in range(i, j + 1): r[o[k]] = (i + j) / 2.0 + 1
i = j + 1
return r
a, b = rk(x), rk(y); ma, mb = st.mean(a), st.mean(b)
nu = sum((p - ma) * (q - mb) for p, q in zip(a, b))
de = (sum((p - ma) ** 2 for p in a) * sum((q - mb) ** 2 for q in b)) ** .5
return nu / de if de else 0.0
TV, NYT = read('cap_media_tv.txt'), read('cap_media_index.txt')
YRS = sorted(set(TV) & set(NYT))
TOP = [c for c in LAB if c in TV[YRS[0]] and c in NYT[YRS[0]]]
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(13.333, 7.5),
gridspec_kw={'width_ratios': [1.62, 1]})
fig.patch.set_facecolor(G)
for ax in (ax1, ax2):
ax.set_facecolor(G)
for s in ax.spines.values(): s.set_visible(False)
ax.grid(color=HAIR, lw=.7); ax.set_axisbelow(True)
ax.tick_params(colors=INK3, labelsize=10, length=0)
# ---- panel 1: the TV agenda over time -----------------------------------
ty = sorted(TV)
SHOW = ['19', '16', '12', '1', '20']
SM = {c: roll([TV[y][c] for y in ty]) for c in SHOW}
for c in SHOW:
ax1.plot(ty, [TV[y][c] for y in ty], color=COL[c], lw=1.0, alpha=.26,
solid_capstyle='round', zorder=2)
ax1.plot(ty, SM[c], color=COL[c], lw=2.6, solid_capstyle='round', zorder=3)
placed = []
for yv, c in sorted((SM[c][-1], c) for c in SHOW):
yy = yv if not placed else max(yv, placed[-1][0] + 2.9)
placed.append((yy, c))
for yy, c in placed:
ax1.text(ty[-1] + 1.3, yy, LAB[c], color=COL[c], fontsize=10.5, va='center')
ax1.set_xlim(ty[0] - 1, ty[-1] + 16)
ax1.set_xticks(list(range(1970, 2011, 10)))
top1 = max(max(SM[c]) for c in SHOW)
ax1.set_ylim(0, top1 * 1.33)
ax1.set_ylabel('share of evening-news stories (%)', color=INK2, fontsize=10.5)
ax1.set_title('Network TV news · ABC, CBS and NBC, 1968–2009',
color=INK, fontsize=15, loc='left', pad=30)
ax1.text(0, 1.035, 'bold line is a three-year average; the faint line behind '
'it is each year on its own', color=INK3, fontsize=10.5, ha='left',
va='bottom', transform=ax1.transAxes)
ax1.grid(axis='x', visible=False)
for x, t in [(1973, 'Watergate'), (1979, 'Iran\nhostages'),
(1991, 'Gulf War'), (2001, '9/11'), (2008, 'financial\ncrisis')]:
ax1.axvline(x, color=INK4, lw=.9, ls=(0, (2, 3)), zorder=1)
ax1.text(x, top1 * 1.29, t, color=INK3, fontsize=9, ha='center', va='top',
linespacing=1.3)
# ---- panel 2: do the two measures agree? --------------------------------
mt = {c: st.mean([TV[y][c] for y in YRS]) for c in TOP}
mn = {c: st.mean([NYT[y][c] for y in YRS]) for c in TOP}
hi = max(max(mt.values()), max(mn.values())) * 1.34
ax2.plot([0, hi], [0, hi], color=INK4, lw=1.0, ls=(0, (3, 4)), zorder=1)
for c in TOP:
big = mt[c] + mn[c] > 8
ax2.scatter([mn[c]], [mt[c]], s=76 if big else 38,
color=COL.get(c, INK4), alpha=.95 if big else .5,
edgecolors='none', zorder=3)
if big:
left = mn[c] > .55 * hi
ax2.annotate(LAB[c], (mn[c], mt[c]), textcoords='offset points',
xytext=(-10 if left else 10, -3),
ha='right' if left else 'left',
color=COL.get(c, INK2), fontsize=10, zorder=4)
ax2.set_xlim(0, hi); ax2.set_ylim(0, hi)
ax2.set_xlabel('share of NYT stories (%)', color=INK2, fontsize=10.5)
ax2.set_ylabel('share of TV news stories (%)', color=INK2, fontsize=10.5)
ax2.set_title('Same topics, two newsrooms', color=INK, fontsize=15,
loc='left', pad=30)
ax2.text(0, 1.035, 'each dot is one topic’s average share, 1968–2009',
color=INK3, fontsize=10.5, ha='left', va='bottom',
transform=ax2.transAxes)
rho = spearman([mn[c] for c in TOP], [mt[c] for c in TOP])
yearly = [spearman([NYT[y][c] for c in TOP], [TV[y][c] for c in TOP])
for y in YRS]
ax2.text(.975, .96, 'rank correlation +%.2f' % rho, transform=ax2.transAxes,
color=INK, fontsize=14, va='top', ha='right')
ax2.text(.975, .895, 'year by year, median +%.2f' % st.median(yearly),
transform=ax2.transAxes, color=INK3, fontsize=10.5, va='top',
ha='right')
ax2.text(.975, .845, 'dotted line = identical shares',
transform=ax2.transAxes, color=INK4, fontsize=9.5, va='top',
ha='right')
fig.suptitle('Two newsrooms, the same ranking — very different weights',
color=INK, fontsize=21, x=.035, ha='left', y=.975)
fig.text(.035, .922,
'Two independent codings of the same topics. They rank the news alike — but television weights war much heavier, and business much lighter.',
color=INK3, fontsize=11.5, ha='left')
fig.text(.035, .028,
'Comparative Agendas Project. TV News (Uscinski), Vanderbilt Television News Archive: 53,915 ABC, CBS and NBC evening stories coded to a major topic, 1968–2009; 1968 covers August onward. ' + chr(10) +
'New York Times Index: a systematic random sample, 42,006 stories, 1946–2016, here restricted to the overlapping years. Dashed lines mark events, not breaks in the data. LPPP 6350.',
color=INK4, fontsize=8.4, ha='left', linespacing=1.7)
fig.subplots_adjust(left=.068, right=.985, top=.805, bottom=.135, wspace=.30)
fig.savefig(OUT, dpi=170, facecolor=G)
print('saved', os.path.basename(OUT))
print(' topic-level rho %.2f yearly median %.2f min %.2f (%d)'
% (rho, st.median(yearly), min(yearly), YRS[yearly.index(min(yearly))]))
print(' TV defense 2000 %.1f%% -> 2001 %.1f%%' % (TV[2000]['16'], TV[2001]['16']))
The two arenas you never get asked about — mediacourts.py
The Supreme Court docket and the press, stacked, both coded to the same twenty-one topic scheme so the vertical scales mean the same thing.
Image: fig/out_12_media_courts.png
Reads: data/cap_judicial.txt, data/cap_media_index.txt
# -*- coding: utf-8 -*-
"""The two arenas nobody asks about: what the Court takes, what the press runs."""
import sys, os
import matplotlib
matplotlib.use('Agg')
from matplotlib import font_manager as fm, pyplot as plt
DDIR, OUT = sys.argv[1], sys.argv[2]
fm.fontManager.addfont(os.path.expanduser(
'~/mnt/UVA/Fall 2026/Slides/Questrial-Regular.ttf'))
plt.rcParams['font.family'] = 'Questrial'
G, INK, INK2, INK3, INK4, HAIR = ('#0C1120', '#F0F3F7', '#B4BDC9', '#8792A3',
'#59626F', '#242C39')
LAB = {'1': 'Macroeconomics', '2': 'Civil rights', '3': 'Health',
'12': 'Law & crime', '15': 'Domestic commerce', '16': 'Defense',
'19': 'Intl affairs', '20': 'Govt operations'}
COL = {'12': '#E8776D', '2': '#C49BE0', '20': '#6BA8E8', '15': '#FFD7A3',
'3': '#5FC98A', '19': '#FFD7A3', '16': '#6BA8E8', '1': '#E8776D'}
def read(fn):
rows = open(os.path.join(DDIR, fn)).read().strip().split('\n')
codes = rows[0].split()[1].split(',')
yrs, data = [], {c: [] for c in codes}
for r in rows[1:]:
y, vals = r.split(':')
v = [float(x) for x in vals.split(',')]
tot = sum(v) or 1
yrs.append(int(y))
for c, x in zip(codes, v):
data[c].append(100.0 * x / tot)
return yrs, data
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(13.333, 7.5),
gridspec_kw={'height_ratios': [1.45, 1]})
fig.patch.set_facecolor(G)
for ax in (ax1, ax2):
ax.set_facecolor(G)
for s in ax.spines.values(): s.set_visible(False)
ax.grid(axis='y', color=HAIR, lw=.7); ax.set_axisbelow(True)
ax.tick_params(colors=INK3, labelsize=10, length=0)
# ---- Supreme Court -------------------------------------------------------
yrs, d = read('cap_judicial.txt')
SHOW = ['12', '2', '20', '15', '3']
for c in SHOW:
ax1.plot(yrs, d[c], color=COL[c], lw=2.4, solid_capstyle='round')
ax1.text(yrs[-1] + 1.2, d[c][-1], LAB[c], color=COL[c], fontsize=10.5,
va='center')
ax1.set_xlim(yrs[0] - 1, yrs[-1] + 17)
ax1.set_xticks(list(range(1950, 2021, 10)))
ax1.set_ylim(0, 48)
ax1.set_ylabel('share of the Court’s cases (%)', color=INK2, fontsize=10.5)
ax1.set_title('The Supreme Court · what it agreed to hear, 1946–2023',
color=INK, fontsize=15, loc='left', pad=10)
EV1 = [(1954, 'Brown'), (1973, 'Roe'), (1988, 'Court gains\ncontrol of docket'),
(2000, 'Bush v. Gore'), (2010, 'Citizens United'), (2022, 'Dobbs')]
for x, t in EV1:
ax1.axvline(x, color=INK4, lw=.9, ls=(0, (2, 3)), zorder=1)
ax1.text(x, 45.6, t, color=INK3, fontsize=9, ha='center', va='top',
linespacing=1.3)
# ---- the press -----------------------------------------------------------
yrs2, d2 = read('cap_media_index.txt')
SHOW2 = ['19', '16', '20', '12', '1']
for c in SHOW2:
ax2.plot(yrs2, d2[c], color=COL[c], lw=2.2, solid_capstyle='round')
placed = []
for yv, c in sorted((d2[c][-1], c) for c in SHOW2):
yy = yv if not placed else max(yv, placed[-1][0] + 2.7)
placed.append((yy, c))
for yy, c in placed:
ax2.text(yrs2[-1] + 1.4, yy, LAB[c], color=COL[c], fontsize=10.5,
va='center')
ax2.set_xlim(yrs2[0] - 1, yrs2[-1] + 13)
ax2.set_xticks(list(range(1950, 2016, 10)))
ax2.set_ylabel('share of NYT stories (%)', color=INK2, fontsize=10.5)
ax2.set_title('The press · New York Times, 1946–2016',
color=INK, fontsize=15, loc='left', pad=10)
top2 = max(max(d2[c]) for c in SHOW2)
ax2.set_ylim(0, top2 * 1.3)
for x, t in [(1950, 'Korea'), (1968, 'Tet'), (1974, 'Watergate'),
(1991, 'Gulf War'), (2001, '9/11'), (2008, 'financial\ncrisis')]:
ax2.axvline(x, color=INK4, lw=.9, ls=(0, (2, 3)), zorder=1)
ax2.text(x, top2 * 1.26, t, color=INK3, fontsize=9, ha='center', va='top',
linespacing=1.3)
fig.suptitle('The two arenas you never get asked about',
color=INK, fontsize=21, x=.035, ha='left', y=.975)
fig.text(.035, .925,
'Both coded to the same 21 topics as the public, Congress and the '
'President — so they sit on the same scale as everything else today.',
color=INK3, fontsize=11.5, ha='left')
fig.text(.035, .022,
'Comparative Agendas Project. Supreme Court: 10,236 cases, 1946–2023. '
'New York Times Index: a systematic random sample, 42,006 stories coded to a major topic,\n'
'1946–2016. Dashed lines mark events, not breaks in the data. LPPP 6350.',
color=INK4, fontsize=8.4, ha='left', linespacing=1.7)
fig.subplots_adjust(left=.075, right=.985, top=.845, bottom=.115, hspace=.42)
fig.savefig(OUT, dpi=170, facecolor=G)
print('saved', os.path.basename(OUT))
print(' Court, law & crime: %.0f%% in %d -> %.0f%% in %d'
% (d['12'][0], yrs[0], d['12'][-1], yrs[-1]))
print(' Press, intl affairs: %.0f%% in 2000 -> %.0f%% in 2001'
% (d2['19'][yrs2.index(2000)], d2['19'][yrs2.index(2001)]))
Six arenas, one topic scheme, and almost no shared agenda — arenacorr.py
Computes a rank correlation between every pair of arenas over the longest window the two of them share, then draws the result as a lower-triangular heat map. The right-hand panel repeats the exercise on the last six months only.
Image: fig/out_15_arena_correlations.png
Reads: all seven data/cap_*.txt files
# -*- coding: utf-8 -*-
"""Do the arenas attend to the same things? Each pair over its own longest
overlapping window, not the single window the short media series would force."""
import json, sys, os, statistics as st
import matplotlib
matplotlib.use('Agg')
from matplotlib import font_manager as fm, pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
DDIR, OUT = sys.argv[1], sys.argv[2]
fm.fontManager.addfont(os.path.expanduser(
'~/mnt/UVA/Fall 2026/Slides/Questrial-Regular.ttf'))
plt.rcParams['font.family'] = 'Questrial'
G, INK, INK2, INK3, INK4 = '#0C1120', '#F0F3F7', '#B4BDC9', '#8792A3', '#59626F'
CMAP = LinearSegmentedColormap.from_list(
'house', ['#A83A32', '#6B2F31', '#1B212C', '#2E6CB8', '#6BC9A8'])
MAJOR = [str(i) for i in list(range(1, 11)) + list(range(12, 22))]
FILES = [('Citizens', 'cap_gallup.txt'), ('Press', 'cap_media_index.txt'),
('TV news', 'cap_media_tv.txt'),
('Congress', 'cap_legislative.txt'), ('Courts', 'cap_judicial.txt'),
('President', 'cap_execorders.txt')]
def read(fn):
rows = open(os.path.join(DDIR, fn)).read().strip().split('\n')
codes = rows[0].split()[1].split(',')
out = {}
for r in rows[1:]:
y, vals = r.split(':')
out[int(y)] = dict(zip(codes, [float(x) for x in vals.split(',')]))
return out
SER = {n: read(f) for n, f in FILES}
def spearman(x, y):
def rk(v):
o = sorted(range(len(v)), key=lambda i: v[i]); r = [0] * len(v); i = 0
while i < len(o):
j = i
while j + 1 < len(o) and v[o[j + 1]] == v[o[i]]: j += 1
for k in range(i, j + 1): r[o[k]] = (i + j) / 2.0 + 1
i = j + 1
return r
a, b = rk(x), rk(y); ma, mb = st.mean(a), st.mean(b)
nu = sum((p - ma) * (q - mb) for p, q in zip(a, b))
de = (sum((p - ma) ** 2 for p in a) * sum((q - mb) ** 2 for q in b)) ** .5
return nu / de if de else 0.0
def profile(name, yrs, topics):
d = SER[name]
tot = {t: sum(d[y].get(t, 0.0) for y in yrs if y in d) for t in topics}
s = sum(tot.values()) or 1
return [100.0 * tot[t] / s for t in topics]
def pairwise(a, b):
ya, yb = set(SER[a]), set(SER[b])
yrs = sorted(ya & yb)
topics = [t for t in MAJOR
if t in next(iter(SER[a].values())) and t in next(iter(SER[b].values()))]
if len(yrs) < 3 or len(topics) < 5:
return None, None, None
return (spearman(profile(a, yrs, topics), profile(b, yrs, topics)),
(yrs[0], yrs[-1]), len(topics))
fig, (axL, axR) = plt.subplots(1, 2, figsize=(13.333, 7.5),
gridspec_kw={'width_ratios': [1.52, 1]})
fig.patch.set_facecolor(G)
for ax in (axL, axR): ax.set_facecolor(G)
N5 = [n for n, _ in FILES]
NTS = set()
M = [[None] * len(N5) for _ in N5]
W = [[None] * len(N5) for _ in N5]
for i, a in enumerate(N5):
for j, b in enumerate(N5):
if j < i:
M[i][j], W[i][j], nt = pairwise(a, b)
if nt: NTS.add(nt)
import numpy as np
disp = np.full((len(N5), len(N5)), np.nan)
for i in range(len(N5)):
for j in range(len(N5)):
if M[i][j] is not None: disp[i][j] = M[i][j]
axL.imshow(disp, cmap=CMAP, vmin=-1, vmax=1, aspect='auto')
for i in range(len(N5)):
for j in range(len(N5)):
if M[i][j] is None: continue
v, w = M[i][j], W[i][j]
axL.text(j, i - .13, '%+.2f' % v, ha='center', va='center',
color='#FFFFFF' if abs(v) > .45 else INK2, fontsize=15)
axL.text(j, i + .25, '%d–%d' % w, ha='center', va='center',
color=INK3, fontsize=9.5)
axL.set_xticks(range(len(N5) - 1)); axL.set_yticks(range(1, len(N5)))
axL.set_xticklabels(N5[:-1], color=INK2, fontsize=12, rotation=20, ha='right')
axL.set_yticklabels(N5[1:], color=INK2, fontsize=12)
axL.set_xlim(-.5, len(N5) - 1.5); axL.set_ylim(len(N5) - .5, .5)
axL.tick_params(colors=INK3, length=0)
for s in axL.spines.values(): s.set_visible(False)
axL.set_title('Every pair over its own longest window', color=INK,
fontsize=15, loc='left', pad=30)
axL.text(0, 1.03, 'Comparative Agendas Project, %d major topics' % max(NTS),
color=INK3, fontsize=10.5, ha='left', va='bottom',
transform=axL.transAxes)
# ---- the three with a live monthly feed ---------------------------------
TOPIC = ['Immigration', 'Health care', 'Taxes', 'Education', 'Abortion',
'Guns', 'Climate', 'Crime', 'Housing']
ALIAS = {'Climate': ['Climate', 'Climate & energy']}
LAST = ['2026-05', '2026-06', '2026-07', '2026-08', '2026-09', '2026-10']
def recent(fn):
d = json.load(open(os.path.join(DDIR, fn)))
mi = {m: i for i, m in enumerate(d['months'])}
tot = {}
for t in TOPIC:
for k in ALIAS.get(t, [t]):
if k in d['series']:
tot[t] = sum(d['series'][k][mi[m]] for m in LAST if m in mi)
break
else:
tot[t] = 0
s = sum(tot.values()) or 1
return [100.0 * tot[t] / s for t in TOPIC]
N3 = ['Citizens', 'President', 'Bureaucracy']
P3 = {'Citizens': recent('citizen_google_trends.json'),
'President': recent('president_federal_register.json'),
'Bureaucracy': recent('executive_federal_register.json')}
d3 = np.full((3, 3), np.nan)
for i, a in enumerate(N3):
for j, b in enumerate(N3):
if j < i: d3[i][j] = spearman(P3[a], P3[b])
axR.imshow(d3, cmap=CMAP, vmin=-1, vmax=1, aspect='auto')
for i in range(3):
for j in range(3):
if np.isnan(d3[i][j]): continue
axR.text(j, i, '%+.2f' % d3[i][j], ha='center', va='center',
color='#FFFFFF' if abs(d3[i][j]) > .45 else INK2, fontsize=17)
axR.set_xticks(range(2)); axR.set_yticks(range(1, 3))
axR.set_xticklabels(N3[:-1], color=INK2, fontsize=12, rotation=20, ha='right')
axR.set_yticklabels(N3[1:], color=INK2, fontsize=12)
axR.set_xlim(-.5, 1.5); axR.set_ylim(2.5, .5)
axR.tick_params(colors=INK3, length=0)
for s in axR.spines.values(): s.set_visible(False)
axR.set_title('Right now · last 6 months', color=INK, fontsize=15,
loc='left', pad=30)
axR.text(0, 1.03, '9 topics, monthly data through October 2026',
color=INK3, fontsize=10.5, ha='left', va='bottom',
transform=axR.transAxes)
sm = plt.cm.ScalarMappable(cmap=CMAP, norm=plt.Normalize(-1, 1))
cb = fig.colorbar(sm, ax=[axL, axR], orientation='horizontal', fraction=.030,
pad=.17, aspect=46)
cb.set_label('rank correlation between two arenas’ topic profiles',
color=INK2, fontsize=11.5)
cb.ax.tick_params(colors=INK3, labelsize=10, length=0)
cb.outline.set_visible(False)
fig.suptitle('Six arenas, one topic scheme — and almost no shared agenda',
color=INK, fontsize=21, x=.035, ha='left', y=.973)
fig.text(.035, .918,
'Each cell is how closely two arenas rank the same topics, over every '
'year both of them cover. +1 is identical priorities, 0 unrelated, below 0 inverted.',
color=INK3, fontsize=11.5, ha='left')
fig.text(.035, .022,
'Media is measured twice and independently: the CAP New York Times Index, 1946–2016, and the CAP TV News series — ABC, CBS and NBC evening broadcasts, 1968–2010, 54,000 stories. Every cell uses each year \n'
'both its sources cover, printed beneath the number. Right panel: Google Trends and the Federal Register, a narrower nine-topic set and two sources sharing one instrument, so its values are not comparable with the left. LPPP 6350.',
color=INK4, fontsize=8.5, ha='left', linespacing=1.7)
fig.subplots_adjust(left=.105, right=.975, top=.805, bottom=.275, wspace=.40)
fig.savefig(OUT, dpi=170, facecolor=G)
print('saved', os.path.basename(OUT))
for i, a in enumerate(N5):
for j, b in enumerate(N5):
if M[i][j] is not None:
print(' %-10s vs %-10s %+.2f %d-%d' % (a, b, M[i][j], *W[i][j]))
The window does not close at the same speed in every arena — window.py
Rescales four separate attention measures so each one peaks at a hundred, then finds the point at which each has lost half of its spike.
Image: fig/out_16_window_length.png
Reads: measurements listed in the archive note below
# -*- coding: utf-8 -*-
"""How long does the window stay open? Three arenas, same event type."""
import sys, os
import matplotlib
matplotlib.use('Agg')
from matplotlib import font_manager as fm, pyplot as plt
OUT = sys.argv[1]
fm.fontManager.addfont(os.path.expanduser(
'~/mnt/UVA/Fall 2026/Slides/Questrial-Regular.ttf'))
plt.rcParams['font.family'] = 'Questrial'
G, INK, INK2, INK3, INK4, HAIR = ('#0C1120', '#F0F3F7', '#B4BDC9', '#8792A3',
'#59626F', '#242C39')
# network news seconds, days -16..+16 (Luca, Malhotra & Poliquin 2020)
NEWS = {0: 295.4, 1: 333.7, 2: 237.5, 3: 179.2, 4: 164.9, 5: 160.1, 6: 137.7,
7: 139.7, 8: 82.6, 9: 99.4, 10: 92.6, 11: 102.6, 12: 63.1, 13: 95.8,
14: 95.0, 15: 99.4, 16: 102.2}
NEWS_BASE = 66.9
# "gun control" searches, days 0..30 (Hassell, Holbein & Baldwin 2020)
SEARCH = {0: 4.1, 1: 81.8, 5: 72.1, 10: 54.2, 15: 31.2, 20: 22.6, 30: 16.6}
SEARCH_BASE = 2.5
# #guncontrol tweets, mean of six shootings in SD (Reny et al. 2023)
TW = [[1.93, .15, -.46, -.81, -1.17, -1.42, -1.67, -1.70, -2.08],
[3.16, 1.72, 1.48, 1.26, .63, .30, -.07, -.06, -.01],
[2.00, 2.33, .08, -1.03, -1.53, -1.63, -1.56, -1.56, -1.81],
[3.27, .91, -.48, -.95, -1.03, -1.05, -1.14, -1.17, -1.27],
[2.00, .92, -.18, -.57, -.95, -1.20, -1.48, -1.48, -1.94],
[3.85, 1.75, -1.28, -1.37, -1.59, -1.60, -1.50, -1.37, -1.31]]
TWEETS = {d: sum(r[d] for r in TW) / len(TW) for d in range(9)}
# a randomly-timed news story in ANY policy area (King, Schneer & White 2017)
GENERIC = {1: 19.4, 2: 15.3, 3: 11.6, 4: 8.1, 5: 4.9, 6: 2.1}
def pct(series, base):
pk = max(series.values())
return {d: 100.0 * (v - base) / (pk - base) for d, v in sorted(series.items())}
def halflife(cur):
xs = sorted(cur)
for a, b in zip(xs, xs[1:]):
if cur[a] >= 50 >= cur[b]:
return a + (cur[a] - 50) * (b - a) / (cur[a] - cur[b])
return None
# label positions set by hand: four curves finish close together
CURVES = [
('Network news coverage', '#FFD7A3', pct(NEWS, NEWS_BASE), (16.9, 16)),
('Public search', '#6BA8E8', pct(SEARCH, SEARCH_BASE), (30.7, 18)),
('Social media', '#B48BE0', pct(TWEETS, min(TWEETS.values())), (8.6, 2)),
('Any news story, any topic', '#59626F', pct(GENERIC, 0.0), (6.4, 28)),
]
fig, ax = plt.subplots(figsize=(13.333, 7.5))
fig.patch.set_facecolor(G); ax.set_facecolor(G)
for s in ax.spines.values(): s.set_visible(False)
ax.grid(color=HAIR, lw=.7); ax.set_axisbelow(True)
ax.tick_params(colors=INK3, labelsize=11, length=0)
ax.axhline(50, color=INK4, lw=1, ls=(0, (3, 4)), zorder=1)
ax.text(22.5, 53, 'half the spike gone', color=INK4, fontsize=10)
for name, col, cur, lpos in CURVES:
xs = sorted(cur)
ax.plot(xs, [cur[d] for d in xs], color=col, lw=3,
solid_capstyle='round', zorder=3)
ax.plot(xs, [cur[d] for d in xs], 'o', ms=6, mfc=col, mec=G, mew=1.4,
zorder=4)
hl = halflife(cur)
if hl:
ax.plot([hl, hl], [0, 50], color=col, lw=1, ls=(0, (2, 3)), zorder=2)
ax.text(hl, -7.5, '%.0f d' % round(hl), color=col, fontsize=11.5,
ha='center')
ax.text(lpos[0], lpos[1], name, color=col, fontsize=12, va='center')
ax.set_xlim(-.6, 37.5); ax.set_ylim(-11, 108)
ax.set_xticks([0, 5, 10, 15, 20, 25, 30])
ax.set_xlabel('days since the shooting', color=INK2, fontsize=13, labelpad=12)
ax.set_ylabel('share of the spike still there (%)', color=INK2, fontsize=13)
fig.suptitle('The window does not close at the same speed in every arena',
color=INK, fontsize=21, x=.035, ha='left', y=.963)
fig.text(.035, .905,
'Each curve is one measure of attention after a mass shooting, '
'rescaled so its own peak above baseline is 100. Dashed drops mark the half-life.',
color=INK3, fontsize=12, ha='left')
fig.text(.035, .025,
'News seconds: Luca, Malhotra & Poliquin 2020, J Pub Econ 181:104083. Searches: Hassell, Holbein & Baldwin 2020, APSR 114(4):1375–85. '
'Posts: Reny, Newman, Holbein & Hassell 2023,\nPNAS Nexus 2(12), mean of six shootings. Benchmark: King, Schneer & White 2017, Science 358(6364):776–80 — a randomly timed story in any policy area. '
'Different studies and measures, so read the shapes, not the gaps. LPPP 6350.',
color=INK4, fontsize=8.4, ha='left', linespacing=1.7)
fig.subplots_adjust(left=.082, right=.80, top=.845, bottom=.175)
fig.savefig(OUT, dpi=170, facecolor=G)
print('saved', os.path.basename(OUT))
for name, _, cur, _ in CURVES:
hl = halflife(cur)
last = sorted(cur)[-1]
print(' %-26s half-life %-6s still %.0f%% at day %d'
% (name, ('%.1f d' % hl) if hl else 'n/a', cur[last], last))
The public’s spikes are getting smaller — spikes.py
Finds each event in the monthly Google Trends series, measures the spike against the median of the twelve to seven months before it, and fits a trend line through the spike sizes over time.
Image: fig/out_17_spike_sizes.png
Reads: Google Trends monthly series for "gun control"
# -*- coding: utf-8 -*-
"""Are the public's gun-control spikes shrinking?"""
import csv, sys, os, statistics as st
import matplotlib
matplotlib.use('Agg')
from matplotlib import font_manager as fm, pyplot as plt
CSVP, OUT = sys.argv[1], sys.argv[2]
fm.fontManager.addfont(os.path.expanduser(
'~/mnt/UVA/Fall 2026/Slides/Questrial-Regular.ttf'))
plt.rcParams['font.family'] = 'Questrial'
G, INK, INK2, INK3, INK4, HAIR = ('#0C1120', '#F0F3F7', '#B4BDC9', '#8792A3',
'#59626F', '#242C39')
ALERT, ACC, WARM = '#E8776D', '#6BA8E8', '#FFD7A3'
SCHOOL = [('2007-04', 'Virginia Tech'), ('2012-12', 'Sandy Hook'),
('2015-10', 'Umpqua'), ('2018-02', 'Stoneman Douglas'),
('2018-05', 'Santa Fe'), ('2022-05', 'Uvalde')]
OTHER = [('2009-11', 'Fort Hood'), ('2012-07', 'Aurora'),
('2015-12', 'San Bernardino'), ('2016-06', 'Orlando'),
('2017-10', 'Las Vegas'), ('2017-11', 'Sutherland Springs'),
('2018-11', 'Thousand Oaks'), ('2019-08', 'El Paso'),
('2021-03', 'Boulder'), ('2023-01', 'Monterey Park'),
('2023-10', 'Lewiston')]
rows = list(csv.DictReader(open(CSVP)))
months = [r['Time'][:7] for r in rows]
val = [float(r['gun control']) for r in rows]
idx = {m: i for i, m in enumerate(months)}
def spike(m):
"""Peak in the event month or the one after, over the -12..-7 median."""
i = idx.get(m)
if i is None or i < 12:
return None, None
base = st.median(val[i - 12:i - 6])
peak = max(val[i:i + 2])
return peak - base, base
ev = []
for lst, kind, col in ((SCHOOL, 'school shooting', ALERT),
(OTHER, 'other mass shooting', ACC)):
for m, name in lst:
s, b = spike(m)
if s is None: continue
ev.append({'m': m, 'name': name, 'kind': kind, 'col': col,
'spike': s, 'x': int(m[:4]) + (int(m[5:7]) - .5) / 12.0})
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(13.333, 7.5),
gridspec_kw={'height_ratios': [1, 1.12]})
fig.patch.set_facecolor(G)
for ax in (ax1, ax2):
ax.set_facecolor(G)
for s in ax.spines.values(): s.set_visible(False)
ax.grid(axis='y', color=HAIR, lw=.7); ax.set_axisbelow(True)
ax.tick_params(colors=INK3, labelsize=10.5, length=0)
xs = [int(m[:4]) + (int(m[5:7]) - .5) / 12.0 for m in months]
ax1.plot(xs, val, color=WARM, lw=1.9, solid_capstyle='round', zorder=3)
for e in ev:
ax1.plot([e['x'], e['x']], [0, 104], color=e['col'], lw=.9,
ls=(0, (2, 3)), alpha=.7, zorder=1)
ax1.set_ylim(0, 108); ax1.set_xlim(2004, 2027)
ax1.set_ylabel('search interest', color=INK2, fontsize=10.5)
ax1.set_title('“Gun control” on Google, every month since 2004',
color=INK, fontsize=15, loc='left', pad=9)
ax1.annotate('Sandy Hook', (2012.96, 100), xytext=(2010.4, 86),
color=ALERT, fontsize=10.5,
arrowprops=dict(arrowstyle='-', color=ALERT, lw=.9))
for e in ev:
ax2.plot(e['x'], e['spike'], 'o', ms=13, mfc=e['col'], mec=G, mew=1.8,
zorder=4)
n = len(ev)
mx = st.mean([e['x'] for e in ev]); my = st.mean([e['spike'] for e in ev])
den = sum((e['x'] - mx) ** 2 for e in ev)
b = sum((e['x'] - mx) * (e['spike'] - my) for e in ev) / den
a = my - b * mx
ax2.plot([2006, 2025], [a + b * 2006, a + b * 2025], color=INK2, lw=2,
ls=(0, (6, 4)), zorder=3)
ax2.text(2025.3, a + b * 2025, '%+.1f points\nper year' % b, color=INK2,
fontsize=11.5, va='center')
for e in ev:
if e['spike'] > 14:
ax2.text(e['x'], e['spike'] + 3.2, e['name'], color=e['col'],
fontsize=9.5, ha='center')
ax2.set_xlim(2004, 2027); ax2.set_ylim(-4, max(e['spike'] for e in ev) * 1.26)
ax2.set_ylabel('spike above baseline', color=INK2, fontsize=10.5)
ax2.set_xlabel('year', color=INK2, fontsize=11.5, labelpad=8)
ax2.set_title('How big each spike was, and whether they are shrinking',
color=INK, fontsize=15, loc='left', pad=9)
ymax = max(e['spike'] for e in ev)
for i, (k, c) in enumerate((('school shooting', ALERT),
('other mass shooting', ACC))):
ax2.plot(2005.0, ymax * (1.10 - i * .13), 'o', ms=11, mfc=c, mec=G, mew=1.6)
ax2.text(2005.5, ymax * (1.10 - i * .13), k, color=c, fontsize=11,
va='center')
sch = [e['spike'] for e in ev if e['kind'] == 'school shooting']
oth = [e['spike'] for e in ev if e['kind'] == 'other mass shooting']
fig.suptitle('The public’s spikes are getting smaller',
color=INK, fontsize=21, x=.035, ha='left', y=.975)
fig.text(.035, .922,
'School shootings average %.0f points above baseline, other mass '
'shootings %.0f. Both are falling about %.1f points a year.'
% (st.mean(sch), st.mean(oth), -b),
color=INK3, fontsize=11.5, ha='left')
fig.text(.035, .022,
'Google Trends, United States, monthly, scaled so the series maximum is 100. Spike = the higher of the event month and the next, minus the median of months −12 to −7. '
'%d events.\nSandy Hook is pinned at 100 by Google’s own normalisation, which lifts the early end. A monthly series cannot separate two events in one month. LPPP 6350.' % n,
color=INK4, fontsize=8.4, ha='left', linespacing=1.7)
fig.subplots_adjust(left=.075, right=.90, top=.835, bottom=.115, hspace=.42)
fig.savefig(OUT, dpi=170, facecolor=G)
print('saved', os.path.basename(OUT))
print(' school n=%d mean %.1f | other n=%d mean %.1f | slope %+.2f/yr'
% (len(sch), st.mean(sch), len(oth), st.mean(oth), b))
for e in sorted(ev, key=lambda e: -e['spike'])[:5]:
print(' %-20s %s %+.1f' % (e['name'], e['m'], e['spike']))
Coverage peaks the day after, and is gone inside a week — seconds.py
A straight redraw of the published event-study figure, with the before and after periods coloured separately and the pre-period baseline computed from days minus sixteen to minus three.
Image: fig/out_3_seconds.png
Reads: measurements embedded in the script
# -*- coding: utf-8 -*-
"""Average seconds of network news gun coverage around a mass shooting.
Luca, Malhotra & Poliquin 2020, Journal of Public Economics 181:104083,
measured from the published figure. Rebuilt with an explicit key.
python3 -I code/seconds.py <out.png>
"""
import os, sys
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib import font_manager as fm
from matplotlib.lines import Line2D
OUT = sys.argv[1]
_ttf = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'Questrial-Regular.ttf')
if os.path.exists(_ttf):
fm.fontManager.addfont(_ttf)
F = 'Questrial'
G = '#0C1120'; INK = '#F0F3F7'; INK2 = '#B4BDC9'; INK3 = '#8792A3'
INK4 = '#59626F'; HAIR = '#242C39'; ALERT = '#E8776D'
D = [(-16, 41.5), (-15, 67.9), (-14, 88.6), (-13, 65.5), (-12, 86.6),
(-11, 67.5), (-10, 53.1), (-9, 61.9), (-8, 75.4), (-7, 55.1),
(-6, 47.9), (-5, 73.1), (-4, 75.8), (-3, 76.2), (-2, 113.0),
(-1, 81.4), (0, 295.4), (1, 333.7), (2, 237.5), (3, 179.2),
(4, 164.9), (5, 160.1), (6, 137.7), (7, 139.7), (8, 82.6),
(9, 99.4), (10, 92.6), (11, 102.6), (12, 63.1), (13, 95.8),
(14, 95.0), (15, 99.4), (16, 102.2)]
BASE = sum(v for d, v in D if -16 <= d <= -3) / 14.0
fig = plt.figure(figsize=(16, 7.2), dpi=100)
fig.patch.set_facecolor(G)
ax = fig.add_axes([0.065, 0.165, 0.90, 0.645])
ax.set_facecolor(G)
pre = [(d, v) for d, v in D if d < 0]
post = [(d, v) for d, v in D if d >= 0]
ax.plot([d for d, _ in pre], [v for _, v in pre], color=INK3, lw=2.6,
marker='o', ms=5, mfc=INK3, mec=G, mew=1.2)
ax.plot([d for d, _ in post], [v for _, v in post], color=ALERT, lw=2.6,
marker='o', ms=5, mfc=ALERT, mec=G, mew=1.2)
ax.plot([pre[-1][0], post[0][0]], [pre[-1][1], post[0][1]], color=ALERT,
lw=2.6)
ax.axvline(0, color=INK2, lw=1.4, alpha=0.75)
ax.axhline(BASE, color=INK4, lw=1.2, ls=(0, (5, 4)))
ax.annotate('the shooting', xy=(0, 352), xytext=(4, 0),
textcoords='offset points', color=INK2, fontsize=14,
fontfamily=F, va='top')
ax.annotate('baseline %.0f seconds' % BASE, xy=(-16.5, BASE - 19),
color=INK4, fontsize=13.5, fontfamily=F)
ax.annotate('334 s', xy=(1, 333.7), xytext=(16, -10),
textcoords='offset points', color=ALERT, fontsize=16,
fontfamily=F)
ax.set_xlim(-17, 17); ax.set_ylim(0, 380)
ax.set_xticks(range(-16, 17, 4))
ax.set_yticks([0, 100, 200, 300])
for t in ax.get_xticklabels() + ax.get_yticklabels():
t.set_fontfamily(F); t.set_fontsize(14); t.set_color(INK3)
ax.tick_params(length=0, pad=8)
for sp in ax.spines.values():
sp.set_visible(False)
ax.grid(axis='y', color=HAIR, lw=0.9); ax.set_axisbelow(True)
ax.set_xlabel('days relative to a mass shooting', color=INK2, fontsize=15,
fontfamily=F, labelpad=12)
ax.set_ylabel('average seconds of network news', color=INK2, fontsize=15,
fontfamily=F, labelpad=12)
leg = ax.legend(handles=[
Line2D([], [], color=INK3, lw=2.6, marker='o', ms=6, mec=G,
label='before the shooting'),
Line2D([], [], color=ALERT, lw=2.6, marker='o', ms=6, mec=G,
label='the day of, and after'),
Line2D([], [], color=INK4, lw=1.2, ls=(0, (5, 4)),
label='pre-period baseline, days −16 to −3')],
loc='upper left', frameon=False, fontsize=14, labelcolor=INK2,
handlelength=2.6, borderpad=0.0, labelspacing=0.55)
for t in leg.get_texts():
t.set_fontfamily(F)
fig.text(0.065, 0.935, 'Coverage peaks the day after, and is gone inside a '
'week', color=INK, fontsize=23, fontfamily=F)
fig.text(0.065, 0.885, 'Average seconds of gun coverage on the ABC, CBS and '
'NBC evening news, by day relative to a mass shooting',
color=INK3, fontsize=14.5, fontfamily=F)
fig.text(0.065, 0.045, 'Luca, Malhotra & Poliquin 2020, Journal of Public '
'Economics 181:104083. Figure redrawn by measurement from the '
'published figure. LPPP 6350.', color=INK4, fontsize=12,
fontfamily=F)
fig.savefig(OUT, facecolor=G)
print('saved', OUT, 'baseline %.1f' % BASE)
The data files
Everything the scripts read is in data/ beside this page. The
Comparative Agendas Project files were aggregated from the full downloads
described in section three, so they are counts or shares per year per topic
rather than one row per document — if you want the document-level files,
go and get them from the links in that section. No student survey responses are
included here.
cap_*.txt
One file per arena. The first line lists the topic codes in column order; every line after it is a year, a colon, and then that year’s value for each topic in the same order.
citizen_google_trends.json
Monthly Google Trends search interest for nine policy terms, United States, joined across two comparison pulls on a shared term so that all nine sit on one scale.
executive_federal_register.json
Monthly counts of final rules whose full text mentions each term, taken from the Federal Register application programming interface.
gallup_most_important_problem_*.csv
The monthly series, and a second file giving the source document and the reported value behind every single number in it.
Six figures on this page have no script here, and why
The figures redrawn from published articles — the King, Schneer and White decay, the gun-control search series, the six-panel posting study, the search-interest comparison, and the issue-attention cycle diagram — were produced in an earlier pass whose build scripts were not kept. What was kept is the thing that actually matters for replication: the measurements themselves, taken pixel by pixel off the published figures and checked by drawing the measured points back over the source image.
Those measurements, and the method used to take them, are written up in the course notes rather than here. If you want them, ask and they will be posted alongside this page. The honest summary is that these five are redrawings of other people’s published results, not analyses of raw data, and the paper of record is cited under each one.