1

n1 <- read_delim("https://whlevine.hosted.uark.edu/psyc5143/outgroup.da")

n1$condition <- factor(n1$condition, labels = c("ingroup", "outgroup"))

# a: comparing groups
n1a <- lm(heterog ~ condition, n1)
summary(n1a)
n1 %>% group_by(condition) %>% summarise(M = mean(heterog))
# they differ significantly, with the ingroup scoring higher

# b: mediation analysis

# Baron & Kenny style

# Step 1 was part a

# step 2: does the mediator differ across groups?
n1b.mediator <- lm(subgr ~ condition, n1)
summary(n1b.mediator)
n1 %>% group_by(condition) %>% summarise(M = mean(subgr))
# it does! the ingroup scores higher

# Step 3: is the direct effect reduced relative to the total effect?
n1b.full <- lm(heterog ~ condition + subgr, n1)
summary(n1b.full)
# it is! it's not even significant anymore, suggesting "full mediation"

library(mediation)
n1med <- mediate(model.m = n1b.mediator,
                                 model.y = n1b.full,            
                                 boot = TRUE,
                                 treat = "condition",
                                 mediator = "subgr")
summary(n1med)
# the ACME (i.e., the indirect effect) is significant, with a CI that does NOT
# contain 0, and about 69% of the total effect is mediated
  1. The ingroup was judged (M = 6.2) significantly more heterogeneous than the outgroup (M = 3.6), t(18) = 3.13, p = .006.

  2. Following Baron & Kenny’s steps, the answer to part a is the first step. The second step is establishing that the groups differ with respect to the mediator: they do, with the ingroup generating significantly more subgroups (M = 5.3) than the outgroup (M = 3.0), t(18) = 3.98, p < .001. The final step is assessing the direct effect of groups controlling for the mediator: this model results in a reduced, non-significant (p = .42) difference between groups, suggesting “full mediation”.

    The bootstrapping analysis agrees, providing an estimate of the indirect effect of -1.79 with a 95% CI of [-3.673, -0.35], suggesting that the effect of group on heterogeneity is mediated by the number of perceived/known subgroups, with about 69% of the total effect being mediated.

2

salary <- read.csv("http://whlevine.hosted.uark.edu/psyc5143/salary2.csv")

salary <- salary %>% 
    mutate(soc = ifelse(depart == "sociology", 1, 0),
                 hist = ifelse(depart == "history", 1, 0),
                 pub.c = pub - mean(pub),
                 soc.pub = soc*pub.c,
                 hist.pub = hist*pub.c)

n3a_model <- lm(salary ~ soc + hist + pub.c + soc.pub + hist.pub, salary)
modelSummary(n3a_model)

salary %>% filter(depart == "sociology") -> sociology
salary %>% filter(depart == "history") -> history
salary %>% filter(depart == "psychology") -> psychology

summary(lm(salary ~ pub.c, sociology))
summary(lm(salary ~ pub.c, history))
summary(lm(salary ~ pub.c, psychology))

salary <- salary %>% 
    mutate(psy = ifelse(depart == "psychology", 1, 0),
                 hist = ifelse(depart == "history", 1, 0),
                 pub.c = pub - mean(pub),
                 psy.pub = psy*pub.c,
                 hist.pub = hist*pub.c)

n3c_model <- lm(salary ~ psy + hist + pub.c + psy.pub + hist.pub, salary)
summary(n3c_model)
  1. The assocation between publications and salary differs significantly across departments. In psychology, the reference department, the slope of this relationship is 1372.9. The slope is sociology is 1115 lower than this (i.e., it is 257.9), a significant difference, \(t(144) = 2.25, p = .026\). The slope in history is also significantly lower than in psychology by 961, \(t(144) = 2.06, p = .04\).

  2. Only in psychology is the relationship between publications and salary significant, with the slope noted above (1373), \(t(58) = 6.19, p < .001\).

    (Notice that t and p are different here than in part a for psychology’s slope; this is because in doing the analyses separately for each department, some of the data are ignored, lowering power - 58 df rather than 144! and changing SE estimates. I am being lazy by doing this by splitting the data.)

  3. The last remaining comparison is between sociology and history, and these two department’s slopes do not differ significantly.