According to McCombs and Shaw, in Agenda Setting Theory, elements in public media frequently become prominent in the public mind. Media outlets do not necessarily influence what people think, but rather what topics are of perceived importance due to salience of those topics among the networks through repeated coverage.
Considering the theory, consumer opinions of topics and level of importance assigned to those topics may differ depending on which network they prefer to consume. Because news networks often vary in attention to certain topics, the salience of “immigration” may differ between networks thus affecting the consumer’s perceptions of the topic in terms of importance.
The proportion of consumers identifying immigration as an important problem facing the United States will differ depending on the network they primarily consume, CNN or Fox News.
Note, analysis of Fox News and CNN coverage mentioning “immigration” in the months leading up to the survey found that Fox News had consistently devoted more coverage to “immigration” than CNN.
A sample of 600 respondents was pulled from a larger data set of frequent viewers of CNN or Fox News from a national poll conducted in September 2023. Each respondent was asked, “What is the most important problem facing the U.S. right now?” Viewers who responded with “immigration” were marked with “1 top issue,” and all other answers were marked with “2 not top issue.”
The dependent variable in the analysis was a categorical measure of whether immigration was a “top issue” vs “not top issue.” The categorical independent variable was whether the respondent preferred the network CNN or Fox News.
A chi-square test of independence was conducted to examine whether the association between network preference and immigration as a top issue facing the United States was statistically significant.
The graph and crosstablulation table below summarize the association between the dependent and independent variables. The chi-square results are shown as well.
| Chi-squared Test Results | |||
| Test of Independence between DV and IV | |||
| Test | Chi-squared Statistic | Degrees of Freedom | p-value |
|---|---|---|---|
| Chi-squared Test of Independence | 55.476 | 1 | 0.000 |
| Crosstabulation of DV by IV | ||
| 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 results supported the hypothesis. According to the Crosstabulation table, about 38% of Fox viewers said “immigration” was a “top issue,” but only 12% of CNN viewers said “immigration was a”top issue.”
The p-value being below .05 shows the difference is statistically significant and is highly unlikely to have occurred by chance. Showing a significance between media outlet and importance of “immigration” to the consumer.
# ------------------------------
# Setup: Install and load packages
# ------------------------------
if (!require("tidyverse")) install.packages("tidyverse") # Data wrangling & plotting
if (!require("gmodels")) install.packages("gmodels") # Crosstabs
if (!require("gt")) install.packages("gt") # Table formatting
library(tidyverse)
library(gmodels)
library(gt)
# ------------------------------
# Load the data
# ------------------------------
# Replace "YOURFILENAME.csv" with your dataset name
mydata <- read.csv("TopIssue.csv") #Edit
# ------------------------------
# Define Dependent (DV) and Independent (IV) variables
# ------------------------------
# Replace YOURDVNAME and YOURIVNAME with actual column names in your data
mydata$DV <- mydata$Immigration #Edit
mydata$IV <- mydata$PreferredNetwork #Edit
# ------------------------------
# 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 = "Distribution of DV by IV",
x = "Independent Variable",
y = "Count",
fill = "Dependent Variable"
)
#Show the graph
graph
# ------------------------------
# Crosstabulation of DV by IV (DV = rows, IV = columns)
# ------------------------------
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 = "Crosstabulation of DV by IV",
subtitle = "Counts and (Column Percentages)"
) %>%
cols_label(
DV = "Dependent Variable"
)
# Show the polished crosstab table
crosstab_table
# ------------------------------
# Chi-squared test of independence
# ------------------------------
options(scipen = 999) # Prevents scientific notation
chitestresults <- chisq.test(mydata$DV, mydata$IV)
# ------------------------------
# Format Chi-squared test results into a table
# ------------------------------
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() %>%
# Round χ² and p-value to 3 decimals, df to integer
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 DV and IV"
) %>%
cols_label(
Test = "Test",
Chi_sq = "Chi-squared Statistic",
df = "Degrees of Freedom",
p = "p-value"
)
# Show the formatted results table
chitest_table