Rationale

Agenda-setting theory proposes that issues emphasized in news coverage can become more prominent in audiences’ perceptions of what matters. News organizations have limited attention to devote to competing issues, but major events can also draw attention to related topics. I originally expected military coverage to detract from reporting on economic concerns. My preliminary MediaCloud analysis, however, found that economic coverage rose during the opening weeks of the U.S. and Israeli military campaign against Iran, which began February 28, 2026. This revised project focuses on whether the volume of U.S. economic news coverage changed following the outbreak of that war.

Hypothesis

Average weekly coverage of U.S. economic concerns differs between the four weeks before and the four weeks after the start of the Iran war.

Variables and Method

The independent variable is the period before or after the February 28, 2026, outbreak of the Iran war. The dependent variable is the weekly number of MediaCloud stories matching a consistent query for U.S. economic concerns, including inflation, consumer prices, unemployment, and cost-of-living issues. I used the MediaCloud United States collection and eight complete Saturday–Friday weeks: January 31–February 27, 2026, before the war, and February 28–March 27, 2026, after the war. The same search query is used throughout.

For the required paired-samples t-test, I pair the first week before the outbreak with the first week after it, the second with the second, etc. These pairs represent equal distances from the event, but the dats doesn’t seem to meld with my research project. I agree that an independent-samples t-test, as you recommended would be a more conventional main test for separate weeks before and after the outbreak.

Results

Weekly Economic News Coverage

The dotted line marks the start of the Iran war. The plotted points represent complete Saturday–Friday weeks.

Descriptive Statistics and Paired Differences

Weekly Economic News Coverage: Descriptive Statistics
Before_Mean Before_SD After_Mean After_SD Difference_Mean Difference_SD
1,447.50 161.60 2,598.25 306.31 1,150.75 437.52
Paired Weeks and Story Count Differences
Pair Before After PairDifferences
1 1652 2277 625
2 1293 2987 1694
3 1498 2676 1178
4 1347 2453 1106

Distribution of Pair Differences

Shapiro-Wilk Test of Paired Differences
statistic p.value method
0.9708 0.8464 Shapiro-Wilk normality test

Paired-Samples t-Test

Paired-Samples t-Test
statistic parameter p.value conf.low conf.high method
5.2603 3 0.0134 454.5535 1,846.9465 Paired t-test

Discussion

The average number of economic stories per week was 1447.5 before the outbreak and 2598.25 afterward, a change of 1150.75 stories per week. The paired-samples t-test produced t(3) = 5.26, p = 0.0134. The paired difference was statistically significant at the .05 level, supporting the hypothesis of a change in coverage.

Economic coverage was higher, on average, following the war’s outbreak, which is consistent with the possibility that military and economic topics can attract attention together. However, the t-test does not establish that the war caused any change or directly test whether military and economic coverage were related. Other events or broader news trends may explain some of the difference.

Code Used

The following is the code usedin creating this analysis:

if (!nzchar(Sys.getenv("MEDIACLOUD_KEY"))) {
  stop("No MEDIACLOUD_KEY found. Set your MediaCloud API key and knit again.")
}
mc_key <- Sys.getenv("MEDIACLOUD_KEY")

start_date <- as.Date("2026-01-31")
end_date <- as.Date("2026-03-27")
event_date <- as.Date("2026-02-28")
collection_id <- 34412234

economy_query <- paste0(
  'language:en AND ("United States" OR "U.S." OR American',
  ' OR Trump OR "Federal Reserve" OR "Bureau of Labor Statistics")',
  ' AND (inflation OR "cost of living" OR "consumer prices"',
  ' OR "gas prices" OR "gasoline prices" OR "food prices"',
  ' OR "grocery prices" OR unemployment OR "job market")'
)
mc_counts_over_time <- function(query, start_date, end_date,
                                collection_id = 34412234) {
  response <- request(
    "https://search.mediacloud.org/api/search/count-over-time"
  ) |>
    req_headers(Authorization = paste("Token", mc_key)) |>
    req_url_query(
      q = query,
      start = as.character(start_date),
      end = as.character(end_date + 1),
      platform = "onlinenews-mediacloud",
      cs = collection_id
    ) |>
    req_timeout(120) |>
    req_retry(max_tries = 3) |>
    req_perform()

  rows <- resp_body_json(response)$count_over_time$counts
  if (is.null(rows) || length(rows) == 0) {
    stop("MediaCloud returned no daily rows. Check the query and dates.")
  }
  daily <- map_dfr(rows, as_tibble) |>
    transmute(date = as.Date(date), count = as.numeric(count)) |>
    filter(date >= start_date, date <= end_date) |>
    arrange(date)

  expected_dates <- seq(start_date, end_date, by = "day")
  if (anyNA(daily) || any(daily$count < 0) ||
      anyDuplicated(daily$date) > 0 ||
      !setequal(daily$date, expected_dates)) {
    stop("Daily rows are missing, duplicated, or invalid.")
  }
  daily
}

economic_daily <- mc_counts_over_time(
  economy_query, start_date, end_date, collection_id
)
weekly_counts <- economic_daily |>
  mutate(week = floor_date(date, unit = "week", week_start = 6)) |>
  group_by(week) |>
  summarise(stories = sum(count), days_observed = n(), .groups = "drop") |>
  mutate(
    Period = if_else(week < event_date, "Before", "After"),
    Pair = if_else(
      week < event_date,
      as.integer((event_date - week) / 7),
      as.integer((week - event_date) / 7) + 1L
    )
  )

stopifnot(nrow(weekly_counts) == 8,
          all(weekly_counts$days_observed == 7),
          sum(weekly_counts$Period == "Before") == 4,
          sum(weekly_counts$Period == "After") == 4)

# Reorder prewar weeks from nearest to farthest for matching by distance.
mydata <- weekly_counts |>
  select(Pair, Period, stories) |>
  pivot_wider(names_from = Period, values_from = stories) |>
  arrange(Pair)

stopifnot(nrow(mydata) == 4, !anyNA(mydata))
mydata$V1 <- mydata$Before
mydata$V2 <- mydata$After
mydata$PairDifferences <- mydata$V2 - mydata$V1
shapiro_res <- shapiro.test(mydata$PairDifferences)
shapiro_table <- tidy(shapiro_res) |>
  select(statistic, p.value, method) |>
  gt() |>
  tab_header(title = "Shapiro-Wilk Test of Paired Differences") |>
  fmt_number(columns = c(statistic, p.value), decimals = 4)
shapiro_table
t_res <- t.test(mydata$V2, mydata$V1, paired = TRUE)
t_table <- tidy(t_res) |>
  select(statistic, parameter, p.value, conf.low, conf.high, method) |>
  gt() |>
  tab_header(title = "Paired-Samples t-Test") |>
  fmt_number(columns = c(statistic, p.value, conf.low, conf.high), decimals = 4)
t_table
# Reshape the paired data to long format, following Dr. Blake's guide.
df_long <- mydata |>
  pivot_longer(cols = c(V1, V2), names_to = "Measure", values_to = "Value") |>
  mutate(Measure = recode(Measure, V1 = "Before", V2 = "After"))
group_means <- df_long |>
  group_by(Measure) |>
  summarise(mean_value = mean(Value), .groups = "drop")
boxplot_measures <- plot_ly() |>
  add_trace(data = df_long, x = ~Measure, y = ~Value,
            type = "box", boxpoints = "outliers",
            marker = list(color = "red", size = 4),
            line = list(color = "black"), fillcolor = "royalblue",
            name = "") |>
  add_trace(data = group_means, x = ~Measure, y = ~mean_value,
            type = "scatter", mode = "markers",
            marker = list(symbol = "diamond", size = 9, color = "black"),
            text = ~paste0("Mean = ", round(mean_value, 2)),
            hoverinfo = "text", name = "Group Mean") |>
  layout(title = "Economic Coverage Before and After the War",
         xaxis = list(title = "Period"),
         yaxis = list(title = "Weekly economic stories"),
         showlegend = FALSE)
boxplot_measures