---
title: "manuscript"
editor: visual
---

+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+
| Zero-Sum Item                                                                                               | Social Identity Variable to Use               |
+=============================================================================================================+===============================================+
| (**ZEROSUM_1**) Life is so devised that when somebody gains, others have to lose.                           | `SOCIALSTATUS`                                |
|                                                                                                             |                                               |
|                                                                                                             | `INCOME`                                      |
|                                                                                                             |                                               |
|                                                                                                             | `EDUCATION`                                   |
+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+
| (**ZEROSUM_2**) When some people are getting poorer, it means that other people are getting richer.         | `SOCIALSTATUS`                                |
|                                                                                                             |                                               |
|                                                                                                             | `INCOME`                                      |
+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+
| (**ZEROSUM_3**) The wealth of a few is acquired at the expense of many.                                     | `SOCIALSTATUS`                                |
|                                                                                                             |                                               |
|                                                                                                             | `INCOME`                                      |
+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+
| (**ZEROSUM_4**) As women face less sexism, men end up facing more sexism.                                   | `GENDER_cat`                                  |
+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+
| (**ZEROSUM_5**) Less discrimination against minorities means more discrimination against whites.            | `RACIALIDENTITY.4`                            |
|                                                                                                             |                                               |
|                                                                                                             | `SOCIALSTATUS`                                |
+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+
| (**ZEROSUM_6**) More opportunity for transwomen means less opportunity for people assigned female at birth. | `GENDER_cat`                                  |
|                                                                                                             |                                               |
|                                                                                                             | `SEXUAL_IDENTITY`                             |
+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+
| (**ZEROSUM_7**) More healthcare access for undocumented immigrants means less access for U.S. citizens.     | No direct social identity measured in dataset |
+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+
| (**ZEROSUM_8**) If there is equal pay for women, men will get lower wages.                                  | `GENDER_cat`                                  |
|                                                                                                             |                                               |
|                                                                                                             | `SOCIALSTATUS`                                |
+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+
| (**ZEROSUM_9**) LGBTQ+ rights mean less freedom for religious groups.                                       | `RELIGIOUS_Identity`                          |
|                                                                                                             |                                               |
|                                                                                                             | `SEXUAL_IDENTITY`                             |
+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+
| (**ZEROSUM_10**) Accessible healthcare for people with disabilities means longer wait times for others.     | No disability variable in dataset             |
|                                                                                                             |                                               |
|                                                                                                             | `SOCIALSTATUS`                                |
+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+
| (**ZEROSUM_11**) Universal healthcare means worse healthcare for those who can afford private insurance.    | `SOCIALSTATUS`                                |
|                                                                                                             |                                               |
|                                                                                                             | `INCOME`                                      |
+-------------------------------------------------------------------------------------------------------------+-----------------------------------------------+

# Analysis Plan

A total of 11 zero-sum belief items (`ZEROSUM_1`:`ZEROSUM_11`) covering economic, gender, racial, healthcare, and LGBTQ+ domains were analyzed. Analyses were conducted in R using series of two-way analysis of covariance (ANCOVA) models. Each model evaluated one zero-sum belief item as the outcome variable with subjective social status (SSS) as a continuous predictor and political party (Democrat, Republican, Independent) as a categorical predictor, along with their interaction term: $$\text{ZEROSUM}_i ~ \text{SOCIALSTATUS} \times \text{POLITICALPARTY}$$ {#eq-ANCOVA analysis equation}

ANCOVA was selected over ANOVA for the `SOCIALSTATUS` predictor because SSS is measured on a continuous scale. Treating SSS as continuous in a regression framework allows estimation of whether the linear relationship between SSS and zero-sum beliefs differs across political party groups. `POLITICALPARTY` was coded as a categorical factor with Democrat as the reference group, allowing for direct comparisons between Republicans and Independents relative to Democrats.

Models were estimated in R using `lm()`. The F-statistic and model R-squared for each ANCOVA are reported to characterize overall model fit. Individual regression coefficients, standard errors, t-values, and p-values are inspected to characterize specific main effects and interactions.

We used the `ggeffects` package to predicted marginal means plots to visualize and interpret significant interaction patterns.

## Additional Social Identity Variables

The manuscript also documents ANOVA analyses with categorical social identity variables for specific items (`INCOME_3`, `GENDER_cat`, `RACIALIDENTITY.4`, `SEXUAL_IDENTITY_binary`). These are addressed as complementary analyses and are not the primary focus of this plan. The core ANCOVA series centers on SOCIALSTATUS × POLITICALPARTY.

# Result

| Item | Zero-sum belief statement | Significant. interaction? | R² |
|----|----|:--:|:--:|
| ZEROSUM_1 | Life is so devised that when somebody gains, others have to lose. | No | -.016 |
| ZEROSUM_2 | When some people are getting poorer, it means that other people are getting richer. | No | .015 |
| **ZEROSUM_3** | **The wealth of a few is acquired at the expense of many.** | **Yes, *p* = .002** | **.012** |
| **ZEROSUM_4** | **As women face less sexism, men end up facing more sexism.** | **Yes, *p* = .003** | **.111** |
| ZEROSUM_5 | Less discrimination against minorities means more discrimination against whites. | No | .139 |
| **ZEROSUM_6** | **More opportunity for transwomen means less opportunity for people assigned female at birth.** | **Yes, *p* \< .001** | **.212** |
| ZEROSUM_7 | More healthcare access for undocumented immigrants means less access for U.S. citizens. | No | .157 |
| ZEROSUM_8 | If there is equal pay for women, men will get lower wages. | No | .165 |
| **ZEROSUM_9** | **LGBTQ+ rights mean less freedom for religious groups.** | **Yes, *p* \< .001** | **.204** |
| ZEROSUM_10 | Accessible healthcare for people with disabilities means longer wait times for others. | No | .262 |
| ZEROSUM_11 | Universal healthcare means worse healthcare for those who can afford private insurance. | No | .185 |

*Note.* Bold text indicates statistically significant SOCIALSTATUS × POLITICALPARTY interaction (*p* \< .05). R² from `lm()` summary output.

## Two-Way ANCOVA (Subjective Social Status x Political Party) on Zero-Sum Beliefs

As a supplementary set of exploratory ANCOVAs, subjective social status (SSS; continuous) and political party affiliation (Democrat \[reference\], Republican, Independent) were entered as predictors along with their two-way interaction for each of the 11 zero-sum belief items.

The four models for which the interaction terms (SSS x Political Party) achieved significance are reported below (ZEROSUM_3, ZEROSUM_4, ZEROSUM_6, ZEROSUM_9). For these models, SSS consistently functioned as a significant linear predictor, and political party intercept differences and interaction terms revealed meaningful moderation patterns that are described and visualized in the predicted marginal means plots (see appendix B).

### ZEROSUM_3: The Wealth of the Few Is Acquired at the Expense of Many

The overall ANCOVA model for ZEROSUM_3 was statistically significant, F(5, 109) = 4.06, p = .002, R-squared = .157, indicating that the model explained approximately 15.7% of variance in endorsement of this economic zero-sum belief.

Among individual predictors, SSS was a significant negative predictor for Democrats, b = −0.39, SE = 0.15, t(109) = −2.66, p = .009, indicating that higher status Democrats endorsed this belief less strongly. Republicans differed significantly from Democrats at the intercept, b = −2.49, SE = 1.12, t(109) = −2.22, p = .029, reflecting lower predicted ZEROSUM_3 scores for Republicans at low SSS values. The SSS x Republican interaction approached significance, b = 0.36, SE = 0.19, t(109) = 1.90, p = .059, suggesting a trend toward a flatter SSS slope for Republicans relative to Democrats.

### ZEROSUM_4: Reduced Sexism Against Women Implies More Sexism Against Men

The overall ANCOVA model for ZEROSUM_4 was statistically significant, F(5, 109) = 3.83, p = .003, R-squared = .149, explaining approximately 14.9% of variance.

Among individual predictors, SSS was a significant positive predictor for Democrats, b = 0.43, SE = 0.16, t(109) = 2.71, p = .008, indicating that higher status Democrats were more likely to endorse gender-based zero-sum beliefs. Republicans differed significantly from Democrats at the intercept, b = 4.28, SE = 1.22, t(109) = 3.50, p \< .001, and Independents also differed from Democrats at the intercept, b = 2.65, SE = 1.19, t(109) = 2.22, p = .029. Critically, both interaction terms were significant: SSS x Independent, b = −0.44, SE = 0.22, t(109) = −2.03, p = .045, and SSS x Republican, b = −0.57, SE = 0.21, t(109) = −2.75, p = .007.

### ZEROSUM_6: More Opportunity for Transwomen Means Less Opportunity for Cisgender Women

The overall ANCOVA model for ZEROSUM_6 was statistically significant, F(5, 109) = 7.14, p \< .001, R-squared = .247, explaining approximately 24.7% of variance.

Among individual predictors, SSS was a significant positive predictor for Democrats, b = 0.50, SE = 0.19, t(109) = 2.68, p = .008. Republicans differed from Democrats at the intercept, b = 5.41, SE = 1.44, t(109) = 3.75, p \< .001, reflecting substantially higher ZEROSUM_6 scores for Republicans at low SSS. The Independent vs. Democrat intercept difference approached significance, b = 2.73, SE = 1.41, t(109) = 1.94, p = .055. The SSS x Republican interaction was significant, b = −0.60, SE = 0.25, t(109) = −2.43, p = .017.

### ZEROSUM_9: LGBTQ+ Rights Mean Less Freedom for Religious Groups

The overall ANCOVA model for ZEROSUM_9 was highly significant, F(5, 109) = 6.86, p \< .001, R-squared = .239, explaining approximately 23.9% of variance.

Among individual predictors, SSS was a significant positive predictor for Democrats, b = 0.48, SE = 0.16, t(109) = 2.95, p = .004. Republicans differed significantly from Democrats at the intercept, b = 3.47, SE = 1.24, t(109) = 2.79, p = .006, and Independents also differed, b = 2.75, SE = 1.21, t(109) = 2.27, p = .025. The SSS x Independent interaction was significant, b = −0.46, SE = 0.22, t(109) = −2.06, p = .042, while the SSS x Republican interaction was not significant, b = −0.34, SE = 0.21, t(109) = −1.58, p = .116.

## Two-way ANCOVA (only SSS)

```{r}
#| label: run install scripts
#| echo: false
#| output: false
#| warning: false
#| error: false
#| results: false

# Run install.R to ensure packages are installed
source("install.R")
```

```{r}
#| label: run cleaning scripts
#| echo: false
#| output: false
#| warning: false
#| error: false
#| results: false
# Run clean.R to prepare data
source("clean.R")
```

```{r}
#| label: load library
#| echo: false
#| error: false
#| warning: false
#| output: false
#| results: false

library(ggplot2)
library(dplyr)
library(tidyr)
library(ggrain)  
library(rmarkdown)
library(readr)
library(patchwork)
library(codebookr)
library(dplyr, warn.conflicts = FALSE)
library(haven)
library(codebook)
library(rempsyc)
library(car)
library(knitr)
library(broom)
library(ggdist)
library(patchwork)
library(car)
library(dataMaid)
library(devtools)
library(MBESS)
library(apaTables)
library(ggpubr)
library(psych)
library(forcats)
library(corrplot)
library(kableExtra)
```

```{r}
#| label: import alldata
#| error: true
#| warning: true
alldata <- read.csv("data/alldata.csv")
```

```{r}
#| label: import select_data
#| error: true
#| warning: true
select_data <- read.csv("data/select_data.csv")
```

```{r}
#| label: import select data form clean.R file

str(select_data)
```

```{r}
#| label: party colors and racial colors for plots

party_colors <- c("Democrat" = "#0015BC", "Republican" = "#E9141D", "Independent" = "#732C7B")

# Define the zesty_four palette
zesty_four <- c("#E69F00", "#009E73", "#999999", "#CC79A7") 

race_colors <- c(
  "Asian" = "#E69F00",
  "Black" = "#009E73",
  "Mixed/Other" = "#999999",
  "White" = "#CC79A7"
)

sexual_colors <- c(
  "Straight" = "#1F78B4",   # muted blue
  "LGBTQ+" = "#E31A1C"      # muted red
)
```

### ZEROSUM_1:

```{r}
zerosum1_social <- lm(ZEROSUM_1 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum1_social)
```

```{r}
#| fig-width: 7
#| fig-height: 5
#| dpi: 300

library(ggeffects)

zerosum1_social_plot <- ggpredict(zerosum1_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

zerosum1_social_plot$group <- factor(
  zerosum1_social_plot$group,
  levels = c("Democrat", "Independent", "Republican")
)

plot(zerosum1_social_plot) +
  scale_color_manual(values = party_colors) +
  scale_fill_manual(values = party_colors) +
  scale_x_continuous(breaks = 1:10,   limits = c(1, 10)) +
  scale_y_continuous(breaks = 1:7) +
  coord_cartesian(xlim = c(1, 10), ylim = c(1, 7)) +
  labs(
    title = "Life is so devised that when somebody gains, others have to lose.",
    x = "Subjective Social Status",
    y = "Level of Agreement Score",
    color = "Political Affiliation"
  ) +
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )

```

### ZEROSUM_2:

```{r}
zerosum2_social <- lm(ZEROSUM_2 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum2_social)
```

```{r}
#| fig-width: 7
#| fig-height: 5
#| dpi: 300

library(ggeffects)

zerosum2_social_plot <- ggpredict(zerosum2_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

zerosum2_social_plot$group <- factor(
  zerosum2_social_plot$group,
  levels = c("Democrat", "Independent", "Republican")
)

plot(zerosum2_social_plot) +
  scale_color_manual(values = party_colors) +
  scale_fill_manual(values = party_colors) +
  scale_x_continuous(breaks = 1:10,   limits = c(1, 10)) +
  scale_y_continuous(breaks = 1:7) +
  coord_cartesian(xlim = c(1, 10), ylim = c(1, 7)) +
  labs(
    title = "When some people are getting poorer, \n it means that other people are getting richer.",
    x = "Subjective Social Status",
    y = "Level of Agreement Score",
    color = "Political Affiliation"
  ) +
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )
```

### ZEROSUM_3:

```{r}
zerosum3_social <- lm(ZEROSUM_3 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum3_social)
```

```{r}
#| fig-width: 7
#| fig-height: 5
#| dpi: 300

library(ggeffects)

zerosum3_social_plot <- ggpredict(zerosum3_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

zerosum3_social_plot$group <- factor(
  zerosum3_social_plot$group,
  levels = c("Democrat", "Independent", "Republican")
)

plot(zerosum3_social_plot) +
  geom_point(
    data = select_data,
    aes(x = SOCIALSTATUS, y = ZEROSUM_3, color = POLITICALPARTY),
    alpha = 0.3,
    size = 1.5,
    position = position_jitter(width = 0.45, height = 0.4),
    inherit.aes = FALSE   
  ) +
  scale_color_manual(values = party_colors) +
  scale_fill_manual(values = party_colors) +
  scale_x_continuous(breaks = 1:10,   limits = c(1, 10)) +
  scale_y_continuous(breaks = 1:7) +
  coord_cartesian(xlim = c(1, 10), ylim = c(1, 7)) +
  labs(
    title = "The wealth of a few is acquired at the expense of many.",
    x = "Subjective Social Status",
    y = "Level of Agreement Score",
    color = "Political Affiliation"
  ) +
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )

```

### ZEROSUM_4:

```{r}
zerosum4_social <- lm(ZEROSUM_4 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum4_social)
```

```{r}
#| fig-width: 7
#| fig-height: 5
#| dpi: 300

library(ggeffects)

zerosum4_social_plot <- ggpredict(zerosum4_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

zerosum4_social_plot$group <- factor(
  zerosum4_social_plot$group,
  levels = c("Democrat", "Independent", "Republican")
)

plot(zerosum4_social_plot) +
  scale_color_manual(values = party_colors) +
  scale_fill_manual(values = party_colors) +
  scale_x_continuous(breaks = 1:10, limits = c(1, 10)) +
  scale_y_continuous(breaks = 1:7) +
  coord_cartesian(xlim = c(1, 10), ylim = c(1, 7)) +
  labs(
    title = "As women face less sexism, men end up facing more sexism.",
    x = "Subjective Social Status",
    y = "Level of Agreement Score",
    color = "Political Affiliation"
  )+
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )
```

### ZEROSUM_5:

```{r}
zerosum5_social <- lm(ZEROSUM_5 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum5_social)
```

```{r}
#| fig-width: 7
#| fig-height: 5
#| dpi: 300

library(ggeffects)

zerosum5_social_plot <- ggpredict(zerosum5_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

zerosum5_social_plot$group <- factor(
  zerosum5_social_plot$group,
  levels = c("Democrat", "Independent", "Republican")
)

plot(zerosum5_social_plot) +
  scale_color_manual(values = party_colors) +
  scale_fill_manual(values = party_colors) +
  scale_x_continuous(breaks = 1:10,   limits = c(1, 10)) +
  scale_y_continuous(breaks = 1:7) +
  coord_cartesian(xlim = c(1, 10), ylim = c(1, 7)) +
  labs(
    title = "Less discrimination against minorities \n means more discrimination against whites.",
    x = "Subjective Social Status",
    y = "Level of Agreement Score",
    color = "Political Affiliation"
  ) +
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )
```

### ZEROSUM_6:

```{r}
zerosum6_social <- lm(ZEROSUM_6 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum6_social)
```

```{r}
#| fig-width: 7
#| fig-height: 5
#| dpi: 300

library(ggeffects)

zerosum6_social_plot <- ggpredict(zerosum6_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

zerosum6_social_plot$group <- factor(
  zerosum6_social_plot$group,
  levels = c("Democrat", "Independent", "Republican")
)

plot(zerosum6_social_plot) +
  scale_color_manual(values = party_colors) +
  scale_fill_manual(values = party_colors) +
  scale_x_continuous(breaks = 1:10, limits = c(1,10)) +
  scale_y_continuous(breaks = 1:7) +
  coord_cartesian(xlim = c(1, 10), ylim = c(1, 7)) +
  labs(
    title = "More opportunity for transwomen means less opportunity \n for people who are assigned female at birth",
    x = "Subjective Social Status",
    y = "Level of Agreement Score",
    color = "Political Affiliation"
  )+
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )
```

### ZEROSUM_7:

```{r}
zerosum7_social <- lm(ZEROSUM_7 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum7_social)
```

```{r}
#| fig-width: 7
#| fig-height: 5
#| dpi: 300

library(ggeffects)

zerosum7_social_plot <- ggpredict(zerosum7_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

zerosum7_social_plot$group <- factor(
  zerosum7_social_plot$group,
  levels = c("Democrat", "Independent", "Republican")
)

plot(zerosum7_social_plot) +
  scale_color_manual(values = party_colors) +
  scale_fill_manual(values = party_colors) +
  scale_x_continuous(breaks = 1:10,   limits = c(1, 10)) +
  scale_y_continuous(breaks = 1:7) +
  coord_cartesian(xlim = c(1, 10), ylim = c(1, 7)) +
  labs(
    title = "More healthcare access for undocumented immigrants \n means less access for U.S. citizens.",
    x = "Subjective Social Status",
    y = "Level of Agreement Score",
    color = "Political Affiliation"
  ) +
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )
```

### ZEROSUM_8:

```{r}
zerosum8_social <- lm(ZEROSUM_8 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum8_social)
```

```{r}
#| fig-width: 7
#| fig-height: 5
#| dpi: 300

library(ggeffects)

zerosum8_social_plot <- ggpredict(zerosum8_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

zerosum8_social_plot$group <- factor(
  zerosum8_social_plot$group,
  levels = c("Democrat", "Independent", "Republican")
)

plot(zerosum8_social_plot) +
  scale_color_manual(values = party_colors) +
  scale_fill_manual(values = party_colors) +
  scale_x_continuous(breaks = 1:10,   limits = c(1, 10)) +
  scale_y_continuous(breaks = 1:7) +
  coord_cartesian(xlim = c(1, 10), ylim = c(1, 7)) +
  labs(
    title = "If there is equal pay for women, men will get lower wages.",
    x = "Subjective Social Status",
    y = "Level of Agreement Score",
    color = "Political Affiliation"
  ) +
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )
```

### ZEROSUM_9:

```{r}
zerosum9_social <- lm(ZEROSUM_9 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum9_social)
```

```{r}
#| fig-width: 7
#| fig-height: 5
#| dpi: 300

library(ggeffects)

zerosum9_social_plot <- ggpredict(zerosum9_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

zerosum9_social_plot$group <- factor(
  zerosum9_social_plot$group,
  levels = c("Democrat", "Independent", "Republican")
)

plot(zerosum9_social_plot) +
  scale_color_manual(values = party_colors) +
  scale_fill_manual(values = party_colors) +
  scale_x_continuous(breaks = 1:10, limits = c(1,10)) +
  scale_y_continuous(breaks = 1:7) +
  coord_cartesian(xlim = c(1, 10), ylim = c(1, 7)) +
  labs(
    title = "LGBTQ+ rights mean less freedom for religious groups.",
    x = "Subjective Social Status",
    y = "Level of Agreement Score",
    color = "Political Affiliation"
  )+
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )
```

### ZEROSUM_10:

```{r}
zerosum10_social <- lm(ZEROSUM_10 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum10_social)
```

```{r}
#| fig-width: 7
#| fig-height: 5
#| dpi: 300

library(ggeffects)

zerosum10_social_plot <- ggpredict(zerosum10_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

zerosum10_social_plot$group <- factor(
  zerosum10_social_plot$group,
  levels = c("Democrat", "Independent", "Republican")
)

plot(zerosum10_social_plot) +
  scale_color_manual(values = party_colors) +
  scale_fill_manual(values = party_colors) +
  scale_x_continuous(breaks = 1:10,   limits = c(1, 10)) +
  scale_y_continuous(breaks = 1:7) +
  coord_cartesian(xlim = c(1, 10), ylim = c(1, 7)) +
  labs(
    title = "Accessible healthcare for people with disabilities \n means longer wait times for others.",
    x = "Subjective Social Status",
    y = "Level of Agreement Score",
    color = "Political Affiliation"
  ) +
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )
```

### ZEROSUM_11:

```{r}
zerosum11_social <- lm(ZEROSUM_11 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum11_social)
```

```{r}
#| fig-width: 7
#| fig-height: 5
#| dpi: 300

library(ggeffects)

zerosum11_social_plot <- ggpredict(zerosum11_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

zerosum11_social_plot$group <- factor(
  zerosum11_social_plot$group,
  levels = c("Democrat", "Independent", "Republican")
)

plot(zerosum11_social_plot) +
  scale_color_manual(values = party_colors) +
  scale_fill_manual(values = party_colors) +
  scale_x_continuous(breaks = 1:10,   limits = c(1, 10)) +
  scale_y_continuous(breaks = 1:7) +
  coord_cartesian(xlim = c(1, 10), ylim = c(1, 7)) +
  labs(
    title = "Universal healthcare means worse healthcare \n for those who can afford private insurance.",
    x = "Subjective Social Status",
    y = "Level of Agreement Score",
    color = "Political Affiliation"
  ) +
  theme(
    plot.title = element_text(face = "bold", hjust = 0.5),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )
```

## Cross-tab table for each SSS with zerosum to see the counts of each political party

```{r}
library(dplyr)
library(tidyr)
library(knitr)
library(kableExtra)

table_data <- select_data %>%
  mutate(
    POLITICALPARTY = factor(
      POLITICALPARTY,
      levels = c("Democrat", "Republican", "Independent")
    )
  ) %>%
  count(SOCIALSTATUS, POLITICALPARTY) %>%
  pivot_wider(
    names_from = POLITICALPARTY,
    values_from = n,
    values_fill = 0
  ) %>%
  mutate(SOCIALSTATUS = as.character(SOCIALSTATUS))

# Add totals
table_data_total <- table_data %>%
  mutate(Total = rowSums(across(where(is.numeric)), na.rm = TRUE)) %>%
  bind_rows(
    table_data %>%
      summarise(across(where(is.numeric), ~ sum(.x, na.rm = TRUE))) %>%
      mutate(
        SOCIALSTATUS = "Total",
        Total = sum(across(where(is.numeric)), na.rm = TRUE)
      )
  )


table_data_total %>%
  kable(
    caption = "Counts of Political Party within Each Subjective Social Status",
    align = "c"
  ) %>%
  kable_styling(full_width = FALSE, position = "center") %>%
  row_spec(nrow(table_data_total), bold = TRUE)

```

```{r}
table(select_data$POLITICALPARTY, select_data$SOCIALSTATUS, useNA = "ifany")
```

## Appendix A: Detailed Statistical Output {.appendix}

### Distribution Check (Predictors)

```{r}
library(ggplot2)
library(dplyr)

# Continuous / Ordinal Variables (optional normality check if DV)
ordinal_vars <- c("SOCIALSTATUS")

for (var in ordinal_vars) {
  print(
    ggplot(select_data, aes(x = as.numeric(.data[[var]]))) +
      geom_histogram(aes(y = ..density..), bins = 10, fill="skyblue", color="black") +
      geom_density(alpha=0.3, fill="orange") +
      labs(title = paste("Distribution of", var), x=var, y="Density") +
      theme_minimal()
  )
}


# Categorical Variables (bar plots)
categorical_vars <- c("INCOME_3", "GENDER_cat", "RACIALIDENTITY.4", "SEXUAL_IDENTITY", "RELIGIOUS_Identity", "EDUCATION_3")

for (var in categorical_vars) {
  print(
    ggplot(select_data, aes(x = .data[[var]])) +
      geom_bar(fill="lightgreen", color="black") +
      labs(title = paste("Distribution of", var), x=var, y="Count") +
      theme_minimal() +
      theme(axis.text.x = element_text(angle=45, hjust=1))
  )
}


```

### Distribution Check (Outcomes ZEROSUM_1:11)

```{r}
#| fig-width: 14
#| fig-height: 14

library(ggplot2)

zero_vars <- c(
  paste0("ZEROSUM_", 1:11)
)


wrap_plots(
  lapply(zero_vars, function(var) {
    ggplot(select_data, aes(x = .data[[var]])) +
      geom_histogram(aes(y = after_stat(density)),
                     bins = 7,
                     fill = "gray80",
                     color = "black") +
      geom_density(fill = "lightblue", alpha = .3) +
      labs(title = paste("Distribution of", var),
           x = var,
           y = "Density") +
      theme_minimal()
  }),
  ncol = 3
) +
plot_annotation(
  title = "Distribution of Zero-Sum Belief Items",
  theme = theme(
    plot.title = element_text(size = 18, face = "bold", hjust = 0.5)
  )
)


```

```{r}
#| fig-width: 14
#| fig-height: 14

qq_plot <- function(var_name) {
  ggplot(select_data, aes(sample = .data[[var_name]])) +
    stat_qq(color = "lightblue") +
    stat_qq_line(color = "black") +
    labs(title = paste(var_name),
         x = "Theoretical Quantiles",
         y = "Sample Quantiles") +
    theme_minimal()
}

qq_list <- lapply(zero_vars, qq_plot)

wrap_plots(qq_list, ncol = 3) +
  plot_annotation(
    title = "Q-Q Plots of Zero-Sum Belief Items",
    theme = theme(
      plot.title = element_text(size = 18, face = "bold", hjust = 0.5)
    )
  )

## Most of the points are roughly following the diagonal, but many are stepped, this makes sense because ZEROSUM items are Likert-type scores (discrete integers).
## the distribution is not perfectly normal, but this is expected for Likert data.
```

## Appendix B: Exploratory Analyses Output {.appendix}

## Two-way ANOVA (categorical variables) & ANCOVA (continuous variable - socialstatus)

To examine the joint and interactive effects of social identity variables and political party affiliation on zero-sum beliefs, a series of two-way analyses were conducted. For continuous predictors (i.e., subjective social status (SSS)), two-way ANCOVA were used. For categorical predictors (i.e., income, gender, racial identity, and sexual identity), two-way ANOVAs were used. All models included political party affiliation (Democrat, Republican, Independent) as a second factor.

### ZEROSUM_1: Social Status x Political Party

```{r}
zerosum1_social <- lm(ZEROSUM_1 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum1_social)
```

The ANCOVA for ZEROSUM_1 model was not significant, F(5,116) = 1.07, p = 0.3806, R-squared = 0.044. The model explains only \~4.4% of the variance. The relationship between social status and zero-sum beliefs might differ slightly for Independents vs Democrats.

```{r}
library(ggeffects)

pred <- ggpredict(zerosum1_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

plot(pred) +
  scale_color_manual(values = party_colors)


```

The interaction term (SSS x Political Party) approached but did not achieve significance (p = .066). It suggests that the relationship between social status and zero-sum beliefs differs by political affiliation. Specifically, zero-sum beliefs increased with social status among Democrats, decreased among Independents, and remained relatively flat among Republicans. However, confidence intervals overlapped substantially, indicating limited statistical support for this interaction.

### ZEROSUM_2: Economic Zero-Sum Beliefs (Income x Political Party)

```{r}
zerosum2_income <- aov(ZEROSUM_2 ~ INCOME_3 * POLITICALPARTY, data = select_data)
summary(zerosum2_income)

```

The ANOVA for ZEROSUM_2 indicated no statistically significant main effects of income or political party, and no significant (Income x Political Party) interaction.

### ZEROSUM_3: Economic Zero-Sum Beliefs (Income x Political Party)

```{r}
zerosum3_income <- aov(ZEROSUM_3 ~ INCOME_3 * POLITICALPARTY, data = select_data)
summary(zerosum3_income)
```

The ANOVA for ZEROSUM_3 indicated no statistically significant main effects of income or political party, and no significant (Income x Political Party) interaction.

### ZEROSUM_4: Gender-Based Zero-Sum Beliefs (Gender x Political Party)

```{r}
zerosum4_gender <- aov(ZEROSUM_4 ~ GENDER_cat * POLITICALPARTY, data = select_data)
summary(zerosum4_gender)
```

The ANOVA for ZEROSUM_4 indicated a statistically significant main effect of political party, F(2, 109) = 5.04, p = .008. In contrast, the main effect of gender and (Gender x Political Party) interaction was not significant.

### ZEROSUM_5: Racial Zero-Sum Beliefs (Racial Identity x Political Party)

```{r}
zerosum5_racial <- aov(ZEROSUM_5 ~ RACIALIDENTITY.4 * POLITICALPARTY, data = select_data)
summary(zerosum5_racial)
```

The ANOVA for ZEROSUM_5 indicated a statistically significant main effect of political party, F(2, 104) = 7.98, p \< .001. In contrast, the main effect of racial identity and (Racial Identity x Political Party) interaction was not significant.

```{r}
ggplot(select_data,
       aes(x = POLITICALPARTY,
           y = ZEROSUM_5,
           fill = RACIALIDENTITY.4)) +
  stat_summary(fun = mean,
               geom = "bar",
               position = position_dodge(0.8),
               width = 0.6) +
  stat_summary(fun.data = mean_se,
               geom = "errorbar",
               position = position_dodge(0.8),
               width = 0.2) +
  geom_jitter(aes(color = RACIALIDENTITY.4),
              position = position_jitterdodge(
                jitter.width = 0.1,
                dodge.width = 0.8
              ),
              alpha = 0.3,
              size = 1.5) +
  scale_fill_manual(values = race_colors) +
  scale_color_manual(values = race_colors) +
  theme_classic()


```

```{r}
ggplot(select_data,
       aes(x = POLITICALPARTY,
           y = ZEROSUM_5,
           group = RACIALIDENTITY.4,
           color = RACIALIDENTITY.4)) +
  stat_summary(fun = mean, geom = "point", size = 3) +
  stat_summary(fun = mean, geom = "line", size = 1) +
  stat_summary(fun.data = mean_se, geom = "errorbar", width = 0.1) +
  scale_color_manual(values = race_colors) +
  theme_classic()

```

The interaction plot indicated all four racial groups showed a consistent increase in ZEROSUM_5 means moving from Democrat to Independent to Republican. The near significant interaction (p = .052) indicates that these divergent racial group trajectories across party may represent a potential meaningful pattern that warrants replication with a larger sample.

### ZEROSUM_6: Gender Based Zero-Sum Beliefs (Gender x Political Party)

```{r}
zerosum6_gender <- aov(ZEROSUM_6 ~ GENDER_cat * POLITICALPARTY, data = select_data)
summary(zerosum6_gender)
```

The ANOVA for ZEROSUM_6 indicated a statistically significant main effect of political party, F(2, 109) = 12.14, p \< .001. In contrast, the main effect of gender and (Gender x Political Party) interaction was not significant.

### ZEROSUM_7: More Healthcare for Undocumented Immigrants Means Less for U.S. Citizens (Racial Identity x Political Party)

```{r}
zerosum7_racial <- aov(ZEROSUM_7 ~ RACIALIDENTITY.4 * POLITICALPARTY, data = select_data)
summary(zerosum7_racial)
```

The ANOVA for ZEROSUM_7 indicated a statistically significant main effect of political party, F(2, 102) = 9.84, p \< .001. In contrast, the main effect of racial identity and (Racial Identity x Political Party) interaction was not significant.

### ZEROSUM_8: Gender Based Zero-Sum Beliefs (Gender x Political Party)

```{r}
zerosum8_gender <- aov(ZEROSUM_8 ~ GENDER_cat * POLITICALPARTY, data = select_data)
summary(zerosum8_gender)
```

The ANOVA for ZEROSUM_8 indicated a statistically significant main effect of political party, F(2, 109) = 8.04, p \< .001. In contrast, the main effect of gender and (Gender x Political Party) interaction was not significant.

### ZEROSUM_9: LGBTQ+ Rights and Religious Freedom (Sexual Identity x Political Party)

```{r}
zerosum9_sexual <- aov(ZEROSUM_9 ~ SEXUAL_IDENTITY_binary * POLITICALPARTY, data = select_data)
summary(zerosum9_sexual)
```

The ANOVA for ZEROSUM_9 indicated a statistically significant main effect of political party, F(2, 109) = 12.16, p \< .001. In contrast, the main effect of sexual identity and (Sexual Identity x Political Party) interaction was not significant.

```{r}
ggplot(select_data,
       aes(x = SEXUAL_IDENTITY_binary,
           y = ZEROSUM_9,
           fill = SEXUAL_IDENTITY_binary)) +
  stat_summary(fun = mean,
               geom = "bar",
               width = 0.6) +
  stat_summary(fun.data = mean_se,
               geom = "errorbar",
               width = 0.2) +
  geom_jitter(aes(color = SEXUAL_IDENTITY_binary),
              width = 0.15,
              alpha = 0.3,
              size = 1.5) +
  scale_fill_manual(values = sexual_colors) +
  scale_color_manual(values = sexual_colors) +
  theme_classic() +
  labs(title = "Zero-Sum Beliefs by Sexual Identity")

```

The bar chart for ZEROSUM_9 by sexual identity group revealed that straight identifying respondents endorsed ZEROSUM_9 at a higher mean level relative to LGBTQ+ identifying respondents, a pattern consistent with theoretical expectations.

```{r}
ggplot(select_data,
       aes(x = POLITICALPARTY,
           y = ZEROSUM_9,
           group = SEXUAL_IDENTITY_binary,
           color = SEXUAL_IDENTITY_binary)) +
  stat_summary(fun = mean, geom = "point", size = 3) +
  stat_summary(fun = mean, geom = "line", size = 1) +
  stat_summary(fun.data = mean_se, geom = "errorbar", width = 0.1) +
  scale_color_manual(values = sexual_colors) +
  theme_classic()
```

The interaction plot suggested that this difference between sexual identity groups may have been most pronounced among Republican respondents. However, formal inferential testing of the two-way ANOVA for ZEROSUM_9 did not yield a statistically significant main effect of sexual identity or a significant interaction. The observed visual patterns should therefore be interpreted as descriptive and directional.

### ZEROSUM_10: Healthcare Access Zero-Sum Beliefs (Social Status x Political Party)

```{r}
zerosum10_social <- lm(ZEROSUM_10 ~ SOCIALSTATUS * POLITICALPARTY, data = select_data)
summary(zerosum10_social)
```

The overall ANCOVA for ZEROSUM_10 model was statistically significant, F(5, 110) = 9.14, p \< .001, R-squared = .294, indicating that the model explained approximately 29.4% of the variance in ZEROSUM_10.

For individual predictors, SSS was a significant positive predictor of ZEROSUM_10 (b = 0.37, SE = 0.16, t(110) = 2.40, p = .018), indicating that higher subjective social status was associated with greater endorsement of this healthcare zero-sum belief among Democrats. Among political party, being Republican (vs. Democrat) was associated with significantly higher ZEROSUM_10 at the intercept (b = 3.23, SE = 1.20, t(110) = 2.70, p = .008).

```{r}
library(ggeffects)

pred <- ggpredict(zerosum10_social, terms = c("SOCIALSTATUS", "POLITICALPARTY"))

plot(pred) +
  scale_color_manual(values = party_colors)

```

The predicted marginal means plot suggested that Republicans displayed a uniformly elevated ZEROSUM_10 score across the full range of SSS, while Democrats and Independents showed lower and more overlapping patterns that increased modestly with SSS. Although the interaction terms were not significant, the visual divergence in intercepts reflects the significant main effect of Republican party identification.

```{r}
ggplot(select_data,
       aes(x = SOCIALSTATUS,
           y = ZEROSUM_10,
           group = POLITICALPARTY,
           color = POLITICALPARTY)) +
  stat_summary(fun = mean, geom = "point", size = 3) +
  stat_summary(fun = mean, geom = "line", size = 1) +
  stat_summary(fun.data = mean_se, geom = "errorbar", width = 0.1) +
  scale_color_manual(values = party_colors) +
  theme_classic()

```

The raw observed data plot similarly shows Republican respondents clustered at higher ZEROSUM_10 values across SSS levels, while Democrats showed a steeper increase from low to high SSS, despite considerable variability.

### ZEROSUM_11: Healthcare Access Zero-Sum Beliefs (Income x Political Party)

```{r}
zerosum11_income <- aov(ZEROSUM_11 ~ INCOME * POLITICALPARTY, data = select_data)
summary(zerosum11_income)
```

The ANOVA for ZEROSUM_11 indicated a statistically significant main effect of political party, F(2, 97) = 8.69, p \< .001. In contrast, the main effect of income and (Income x Political Party) interaction was not significant.
