Shin - MPA

Author

Heather Perkins

Load Libraries

Code
library(sjPlot)
library(ggplot2)

Load Data

Code
df <- read.csv(file="data.csv", header=T)

Hypothesis 1

Expectation of Rejection > Anomie, M = Everyday Discrimination

Code
df$anomie <- (df$anomie_break + df$anomie_dis)/2
df$eds_di <- 1
df$eds_di[df$eds < mean(df$eds, na.rm = TRUE)] <- 0

reg1 <- lm(anomie ~ ers*eds_di, data=df)
summary(reg1)

Call:
lm(formula = anomie ~ ers * eds_di, data = df)

Residuals:
    Min      1Q  Median      3Q     Max 
-2.0729 -0.3780  0.0560  0.4218  1.4065 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  2.42279    0.17945  13.502   <2e-16 ***
ers          0.17068    0.11956   1.428    0.155    
eds_di       0.41068    0.25428   1.615    0.108    
ers:eds_di  -0.09088    0.14507  -0.626    0.532    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.6411 on 180 degrees of freedom
Multiple R-squared:  0.07884,   Adjusted R-squared:  0.06349 
F-statistic: 5.136 on 3 and 180 DF,  p-value: 0.001974
Code
p <- plot_model(reg1, type="int")

library(ggplot2)

p +
  # Labels — update these to match your variables
  labs(
    title = "Expectation of Rejection, Everyday Discrimination, and Anomie",
    subtitle = "Adj. R² = .06, F(3,180) = 5.14, p = .002",
    x = "Expectation of Rejection",
    y = "Anomie",
    color = "Everyday Discrimination"
  ) +
  scale_color_manual(
    values = c("#2E86AB", "#E84855"),
    labels = c("Low", "High")   # <-- change these
  ) +
  
  # Clean theme
  theme_minimal(base_size = 13) +
  theme(
    plot.title      = element_text(face = "bold", size = 15, margin = margin(b = 4)),
    plot.subtitle   = element_text(color = "grey50", size = 11, margin = margin(b = 12)),
    axis.title      = element_text(face = "bold", color = "grey30"),
    axis.text       = element_text(color = "grey20"),
    legend.title    = element_text(face = "bold", size = 11),
    legend.position = "bottom",
    panel.grid.minor  = element_blank(),
    panel.grid.major  = element_line(color = "grey92"),
    plot.background   = element_rect(fill = "white", color = NA),
    plot.margin       = margin(20, 20, 20, 20)
  ) +
  
  # Color palette for the interacting groups
  scale_fill_manual(values  = c("#2E86AB", "#E84855"))
Scale for colour is already present.
Adding another scale for colour, which will replace the existing scale.