Rationale

Agenda-setting theory proposes that the amount of attention the media gives to an issue can influence how important audiences perceive that issue to be. In this case, Fox News devoted more coverage to immigration than CNN during the months leading up to the survey. If agenda-setting theory applies, people who primarily watch Fox News should therefore be more likely than people who primarily watch CNN to identify immigration as the most important problem facing the United States.

Hypothesis

People who prefer Fox News will be more likely than people who prefer CNN to identify immigration as the most important problem facing the United States.

Variables & method

The data consisted of 600 frequent Fox News or CNN viewers who participated in a larger national survey conducted in September 2023. The independent variable was PreferredNetwork, a categorical variable indicating whether each respondent usually watched Fox News or CNN. The dependent variable was Immigration, also a categorical variable indicating whether the respondent identified immigration as the most important problem facing the United States or identified another issue as the most important problem.

A chi-square test of independence was conducted to determine whether there was a statistically significant association between respondents’ preferred news network and whether they identified immigration as the country’s most important problem.

Results & discussion

The graph and crosstabulation table below summarize the association between preferred news network and whether respondents identified immigration as the most important problem facing the United States.

Immigration as Top Issue by Preferred Network
Counts and (Column Percentages)
CNN Fox
1 Top issue 35 (11.7%) 115 (38.3%)
2 Not top issue 265 (88.3%) 185 (61.7%)

The chi-square test results are shown below.

Chi-squared Test Results
Test of Independence between Immigration and Preferred Network
Test Chi-squared Statistic Degrees of Freedom p-value
Chi-squared Test of Independence 55.476 1 0.000

The results supported the hypothesis. Among frequent Fox News viewers, 38.3% identified immigration as the most important problem facing the United States, compared with 11.7% of frequent CNN viewers. The chi-square test indicated that the association between preferred news network and identifying immigration as the top issue was statistically significant, χ²(1) = 55.476, p < .001. Given that Fox News had devoted more coverage to immigration than CNN during the period preceding the survey, the observed association is consistent with the expectation derived from agenda-setting theory.

Code

# ============================================================
# Download the TopIssue dataset
# ============================================================

# Read the data from the web
FetchedData <- read.csv("https://drkblake.com/wp-content/uploads/2023/09/TopIssue.csv")

# Save the data in the project folder
write.csv(FetchedData, "TopIssue.csv", row.names = FALSE)

# Remove the temporary object
rm(FetchedData)
# ============================================================
# Setup: Install and load required packages
# ============================================================

if (!require("tidyverse")) install.packages("tidyverse")
if (!require("gmodels")) install.packages("gmodels")
if (!require("gt")) install.packages("gt")

library(tidyverse)
library(gmodels)
library(gt)


# ============================================================
# Load the data
# ============================================================

mydata <- read.csv("TopIssue.csv")


# ============================================================
# Define Dependent (DV) and Independent (IV) variables
# ============================================================

mydata$DV <- mydata$Immigration
mydata$IV <- mydata$PreferredNetwork


# ============================================================
# Visualization: Stacked bar chart of IV by DV
# ============================================================

graph <- ggplot(mydata, aes(x = IV, fill = DV)) +
  geom_bar(colour = "black") +
  scale_fill_brewer(palette = "Paired") +
  labs(
    title = "Immigration as Top Issue by Preferred Network",
    x = "Preferred Network",
    y = "Count",
    fill = "Immigration"
  )

# Show the graph
graph


# ============================================================
# Crosstabulation of DV by IV
# ============================================================

crosstab <- mydata %>%
  count(DV, IV) %>%
  group_by(IV) %>%
  mutate(RowPct = 100 * n / sum(n)) %>%
  ungroup() %>%
  mutate(Cell = paste0(n, "\n(", round(RowPct, 1), "%)")) %>%
  select(DV, IV, Cell) %>%
  pivot_wider(names_from = IV, values_from = Cell)


# Format into gt table
crosstab_table <- crosstab %>%
  gt(rowname_col = "DV") %>%
  tab_header(
    title = "Immigration as Top Issue by Preferred Network",
    subtitle = "Counts and (Column Percentages)"
  )


# Show the polished crosstab table
crosstab_table


# ============================================================
# Chi-squared test of independence
# ============================================================

options(scipen = 999)

chitestresults <- chisq.test(mydata$DV, mydata$IV)


# ============================================================
# Format chi-squared test results
# ============================================================

chitest_summary <- tibble(
  Test = "Chi-squared Test of Independence",
  Chi_sq = chitestresults$statistic,
  df = chitestresults$parameter,
  p = chitestresults$p.value
)

chitest_table <- chitest_summary %>%
  gt() %>%
  fmt_number(columns = c(Chi_sq, p), decimals = 3) %>%
  fmt_number(columns = df, decimals = 0) %>%
  tab_header(
    title = "Chi-squared Test Results",
    subtitle = "Test of Independence between Immigration and Preferred Network"
  ) %>%
  cols_label(
    Test = "Test",
    Chi_sq = "Chi-squared Statistic",
    df = "Degrees of Freedom",
    p = "p-value"
  )


# Show the formatted results table
chitest_table