1. Add the “Geopolitical Threat” variable of Hiers, Soehl, and Wimmer (2017) (see Table 1 below) to the ESS ’14 data that we had prepared to replicate Schlueter, Masso, and Davidov (2019). Make a plot that visualizes the variation across countries.

Source: Hiers, Soehl, and Wimmer (2017)

library(tidyverse) # Data manipulation
library(haven) # Read Stata dta files
library(essurvey) # API to ESS
library(ggplot2) # Nice visualizations

ESS <- import_rounds(rounds = 7, ess_email = YOUR_EMAIL) %>%
  recode_missings() %>%
  # redefine some variables as factors
  mutate(
    # Educational attainment
    edu_attain = case_when(
      edulvlb < 200 ~ 1,
      edulvlb > 199 & edulvlb < 300 ~ 2,
      edulvlb > 299 & edulvlb < 400 ~ 3,
      edulvlb > 399 & edulvlb < 500 ~ 4,
      edulvlb > 499 & edulvlb < 600 ~ 5,
      edulvlb > 599 & edulvlb < 700 ~ 6,
      edulvlb > 699 & edulvlb < 801 ~ 7,
      TRUE ~ as.numeric(NA)
    ),
    # Watching TV, but not news on TV
    TV_not_news = tvtot - tvpol,
    # Immigrant friends
    dfegcf = max(dfegcf, na.rm = TRUE) - dfegcf,
    brncntr = as_factor(brncntr), 
    ctzcntr = as_factor(ctzcntr),
    rlgblg = as_factor(rlgblg),
    rlgdnm = as_factor(rlgdnm),
    uempla = as_factor(uempla),
    rlgdnm = case_when( # Add atheists to the religion variable
      rlgblg == "No" ~ "Atheist",
      rlgdnm=="Not applicable"|rlgdnm=="Refusal"|rlgdnm=="No answer" ~ as.character(NA),
      TRUE ~ as.character(rlgdnm)
    ) %>% factor(),
    gndr = as_factor(gndr),
    gndr = case_when(
      gndr == "No answer" ~ as.character(NA),
      TRUE ~ as.character(gndr)
    ) %>% factor()
  ) %>% zap_labels() %>%
  # keep only those born and with citizenship in country of interview,
  # non-Muslim and drop Israel
  filter(brncntr == "Yes" & ctzcntr == "Yes" & rlgdnm != "Islamic" & cntry != "IL") %>%
  # Keep only the following variables
  select(cntry, almuslv, agea, gndr, edu_attain, TV_not_news,
         uempla, hincfel, rlgdnm, dfegcf, tvtot, tvpol) %>%
  drop_na() %>% # Casewise deletion
  # Conjoin Schlueter et al. macro data
  inner_join(., 
             read_dta("./../../assets/ESS7/Schlueter.dta") %>%
               mutate( # Add geopolitical threat to macro data
                 geothreat_j = case_when(
                   cntry == "AT" ~ 3, cntry == "BE" ~ 2,
                   cntry == "CH" ~ 0, cntry == "CZ" ~ 3,
                   cntry == "DE" ~ 3, cntry == "DK" ~ 1,
                   cntry == "EE" ~ 3, cntry == "ES" ~ 2,
                   cntry == "FI" ~ 1, cntry == "FR" ~ 0,
                   cntry == "GB" ~ 3, cntry == "HU" ~ 4,
                   cntry == "IE" ~ 1, cntry == "LT" ~ 2,
                   cntry == "NL" ~ 0, cntry == "NO" ~ 0,
                   cntry == "PL" ~ 2, cntry == "PT" ~ 0,
                   cntry == "SE" ~ 1, cntry == "SI" ~ 0)), 
             by = "cntry")
ggplot(data = ESS, aes(y = geothreat_j, x = reorder(cntry, geothreat_j))) + 
  geom_point() +
  labs(y = "Geopolitical threat", x = "") + 
  theme_minimal()


. use "./../../assets/ESS7/ESS7e02_2.dta", cl. quietly do "./../../assets/ESS7/ESS7e02_2_formats_unicode.do"
. 
. * Data preparation

. ** Keep only those born in and with citizenship of country of interview, 

. ** Non-Muslims, and drop Israel

. keep if brncntr == 1 & ctzcntr == 1 & rlgdnm != 6 & cntry != "IL"
(6,789 observations deleted)

. 
. ** Use the following variables for the analysis

. keep cntry almuslv agea gndr edulvlb uempla hincfel rlgblg rlgdnm dfegcf tvto
> t tvpol

. 
. ** Add atheists to the religion variable

. replace rlgdnm = 0 if rlgblg == 2
(15,411 real changes made)

. 
. ** Listwise deletion of missing values

. foreach var in cntry almuslv agea gndr edulvlb uempla hincfel rlgdnm dfegcf t
> vtot tvpol {
  2. drop if missing(`var')
  3. }
(0 observations deleted)
(1,217 observations deleted)
(54 observations deleted)
(20 observations deleted)
(76 observations deleted)
(0 observations deleted)
(243 observations deleted)
(179 observations deleted)
(75 observations deleted)
(51 observations deleted)
(1,337 observations deleted)

. 
. ** Educational attainment

. gen edu_attain = edulvlb

. recode edu_attain (0 113 129 = 1) (212 213 221 222 223 229 = 2) (311 312 313 
> 321 322 323 = 3) (412 413 421 422 423 = 4) (510 520 = 5) (610 620 = 6) (710 7
> 20 800 = 7) (else = .)
(edu_attain: 30144 changes made)

. label var edu_attain "Education"

. 
. ** Watching TV, but not news on TV

. gen TV_not_news = tvtot - tvpol

. label var TV_not_news "TV exposure"

. 
. ** Immigrant friends

. sum dfegcf

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
      dfegcf |     30,144    2.432657    .6823662          1          3

. replace dfegcf = `r(max)' - dfegcf
(30,144 real changes made)

. lab var dfegcf "Friendships with immigrants"

. 
. ** Some more labels

. label define uempla 0 "Not unemployed" 1 "Unemployed", replace

. label variable hincfel "Economic deprivation"

. 
. * Conjoin Schlueter et al. macro data

. preserve

. ** Use country data

. use "./../../assets/ESS7/Schlueter.dta", clear

. ** Add Geopolitical threat

. gen geothreat_j = .
(40 missing values generated)

. replace geothreat_j = 3 if cntry == "AT"
(1 real change made)

. replace geothreat_j = 2 if cntry == "BE"
(1 real change made)

. replace geothreat_j = 0 if cntry == "CH"
(1 real change made)

. replace geothreat_j = 3 if cntry == "CZ"
(1 real change made)

. replace geothreat_j = 3 if cntry == "DE"
(1 real change made)

. replace geothreat_j = 1 if cntry == "DK"
(1 real change made)

. replace geothreat_j = 3 if cntry == "EE"
(1 real change made)

. replace geothreat_j = 2 if cntry == "ES"
(1 real change made)

. replace geothreat_j = 1 if cntry == "FI"
(1 real change made)

. replace geothreat_j = 0 if cntry == "FR"
(1 real change made)

. replace geothreat_j = 3 if cntry == "GB"
(1 real change made)

. replace geothreat_j = 4 if cntry == "HU"
(1 real change made)

. replace geothreat_j = 1 if cntry == "IE"
(1 real change made)

. replace geothreat_j = 2 if cntry == "LT"
(1 real change made)

. replace geothreat_j = 0 if cntry == "NL"
(1 real change made)

. replace geothreat_j = 0 if cntry == "NO"
(1 real change made)

. replace geothreat_j = 2 if cntry == "PL"
(1 real change made)

. replace geothreat_j = 0 if cntry == "PT"
(1 real change made)

. replace geothreat_j = 1 if cntry == "SE"
(1 real change made)

. replace geothreat_j = 0 if cntry == "SI"
(1 real change made)

. lab var geothreat_j "Geopolitical threat"

. ** Create a temporary file

. tempfile temp1

. ** Save memory into the temporary file

. save "`temp1'"
file /var/folders/2_/0vc2cx65781cm0qm9tw72fg80000gn/T//St04537.000002 saved

. ** Restore back to ESS survey data

. restore

. ** Conjoin ESS survey and country-level data

. merge m:1 cntry using "`temp1'", keep(match) nogen

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                            30,144  
    -----------------------------------------

. 
. * Make a dot plot

. graph dot (mean)  geothreat_j, over(cntry, sort(geothreat_j)) yline(0) vertic
> al scheme(plotplain)
(note: scheme plotplain not found, using s2color)

. 

2. Does geopolitical threat predict anti-Muslim prejudice? Estimate a bivariate random intercept model with only “Geopolitical Threat” as predictor of anti-Muslim prejudice.

library(lme4) # Multilevel modeling

# Model 1
Model_1 <- lmer(almuslv ~ geothreat_j + (1 | cntry), data  = ESS)
summary(Model_1)
# Linear mixed model fit by REML ['lmerMod']
# Formula: almuslv ~ geothreat_j + (1 | cntry)
#    Data: ESS
# 
# REML criterion at convergence: 77931
# 
# Scaled residuals: 
#     Min      1Q  Median      3Q     Max 
# -2.7928 -0.6986  0.0458  0.6333  2.4530 
# 
# Random effects:
#  Groups   Name        Variance Std.Dev.
#  cntry    (Intercept) 0.130    0.361   
#  Residual             0.779    0.883   
# Number of obs: 30064, groups:  cntry, 20
# 
# Fixed effects:
#             Estimate Std. Error t value
# (Intercept)    2.454      0.127   19.34
# geothreat_j    0.152      0.063    2.41
# 
# Correlation of Fixed Effects:
#             (Intr)
# geothreat_j -0.770
. quietly do "./../../assets/ESS7/8-RI-Replication-2.do"
. mixed almuslv geothreat_j || cntry: , reml

Performing EM optimization: 

Performing gradient-based optimization: 

Iteration 0:   log restricted-likelihood = -39072.151  
Iteration 1:   log restricted-likelihood = -39072.151  

Computing standard errors:

Mixed-effects REML regression                   Number of obs     =     30,144
Group variable: cntry                           Number of groups  =         20

                                                Obs per group:
                                                              min =        953
                                                              avg =    1,507.2
                                                              max =      2,478

                                                Wald chi2(1)      =       5.85
Log restricted-likelihood = -39072.151          Prob > chi2       =     0.0156

------------------------------------------------------------------------------
     almuslv |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 geothreat_j |   .1523375   .0629685     2.42   0.016     .0289214    .2757536
       _cons |   2.453463   .1267474    19.36   0.000     2.205043    2.701884
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
cntry: Identity              |
                  var(_cons) |   .1300798   .0435215      .0675178    .2506115
-----------------------------+------------------------------------------------
               var(Residual) |   .7793262   .0063501      .7669792    .7918721
------------------------------------------------------------------------------
LR test vs. linear model: chibar2(01) = 4656.66       Prob >= chibar2 = 0.0000

. 

3. Control for composition effects Add the “Geopolitical Threat” variable to Model 1 of Table 1 reported in Schlueter, Masso, and Davidov (2019). Do composition effects account for the earlier result?

Model_2 <- lmer(almuslv ~ geothreat_j + gndr + agea + edu_attain + 
                  uempla + hincfel + dfegcf + rlgdnm + TV_not_news + 
                  (1 | cntry), data  = ESS)
summary(Model_2)
# Linear mixed model fit by REML ['lmerMod']
# Formula: almuslv ~ geothreat_j + gndr + agea + edu_attain + uempla + hincfel +  
#     dfegcf + rlgdnm + TV_not_news + (1 | cntry)
#    Data: ESS
# 
# REML criterion at convergence: 73798
# 
# Scaled residuals: 
#    Min     1Q Median     3Q    Max 
# -3.560 -0.694  0.008  0.743  3.016 
# 
# Random effects:
#  Groups   Name        Variance Std.Dev.
#  cntry    (Intercept) 0.0863   0.294   
#  Residual             0.6774   0.823   
# Number of obs: 30064, groups:  cntry, 20
# 
# Fixed effects:
#                                      Estimate Std. Error t value
# (Intercept)                          2.398724   0.106283   22.57
# geothreat_j                          0.123004   0.051342    2.40
# gndrMale                            -0.001792   0.009619   -0.19
# agea                                 0.005499   0.000272   20.20
# edu_attain                          -0.090419   0.002825  -32.01
# uemplaMarked                        -0.026342   0.025023   -1.05
# hincfel                              0.101760   0.006686   15.22
# dfegcf                              -0.234459   0.007446  -31.49
# rlgdnmEastern Orthodox               0.001973   0.054327    0.04
# rlgdnmEastern religions             -0.092736   0.103340   -0.90
# rlgdnmJewish                        -0.021526   0.171996   -0.13
# rlgdnmOther Christian denomination  -0.077225   0.050118   -1.54
# rlgdnmOther non-Christian religions -0.220750   0.100889   -2.19
# rlgdnmProtestant                     0.032381   0.015283    2.12
# rlgdnmRoman Catholic                 0.059437   0.013185    4.51
# TV_not_news                          0.028863   0.002833   10.19
. quietly do "./../../assets/ESS7/8-RI-Replication-2.do"
. mixed almuslv geothreat_j gndr agea edu_attain uempla hincfel dfegcf rlgdnm T
> V_not_news || cntry: , reml

Performing EM optimization: 

Performing gradient-based optimization: 

Iteration 0:   log restricted-likelihood = -36905.411  
Iteration 1:   log restricted-likelihood = -36905.411  

Computing standard errors:

Mixed-effects REML regression                   Number of obs     =     30,064
Group variable: cntry                           Number of groups  =         20

                                                Obs per group:
                                                              min =        953
                                                              avg =    1,503.2
                                                              max =      2,478

                                                Wald chi2(9)      =    4506.81
Log restricted-likelihood = -36905.411          Prob > chi2       =     0.0000

------------------------------------------------------------------------------
     almuslv |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 geothreat_j |    .122275   .0518617     2.36   0.018     .0206279     .223922
        gndr |   .0046644   .0096073     0.49   0.627    -.0141655    .0234943
        agea |    .005691     .00027    21.08   0.000     .0051618    .0062201
  edu_attain |   -.091012   .0028229   -32.24   0.000    -.0965448   -.0854792
      uempla |  -.0306483   .0250204    -1.22   0.221    -.0796874    .0183907
     hincfel |   .1006458   .0066807    15.07   0.000     .0875519    .1137397
      dfegcf |  -.2372989   .0074294   -31.94   0.000    -.2518603   -.2227376
      rlgdnm |   .0030032   .0052659     0.57   0.568    -.0073178    .0133242
 TV_not_news |   .0285813    .002833    10.09   0.000     .0230287     .034134
       _cons |   2.411732   .1078274    22.37   0.000     2.200394     2.62307
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
cntry: Identity              |
                  var(_cons) |   .0880858   .0295139      .0456777    .1698667
-----------------------------+------------------------------------------------
               var(Residual) |   .6780185   .0055327      .6672609    .6889495
------------------------------------------------------------------------------
LR test vs. linear model: chibar2(01) = 3410.88       Prob >= chibar2 = 0.0000

. 

4. Control for alternative context effects. Add the “Geopolitical Threat” variable to Model 2 of Table 1 reported in Schlueter, Masso, and Davidov (2019). What happens to the “effect” of geopolitical threat?

Model_3 <- lmer(almuslv ~ geothreat_j + gndr + agea + edu_attain + 
                  uempla + hincfel + dfegcf + rlgdnm + TV_not_news + 
                  muslim_j + mipex_j + relstate_j + claims_j + (1 | cntry), data  = ESS)
summary(Model_3)
# Linear mixed model fit by REML ['lmerMod']
# Formula: almuslv ~ geothreat_j + gndr + agea + edu_attain + uempla + hincfel +  
#     dfegcf + rlgdnm + TV_not_news + muslim_j + mipex_j + relstate_j +      claims_j + (1 | cntry)
#    Data: ESS
# 
# REML criterion at convergence: 73802
# 
# Scaled residuals: 
#    Min     1Q Median     3Q    Max 
# -3.558 -0.694  0.009  0.743  3.019 
# 
# Random effects:
#  Groups   Name        Variance Std.Dev.
#  cntry    (Intercept) 0.0326   0.181   
#  Residual             0.6774   0.823   
# Number of obs: 30064, groups:  cntry, 20
# 
# Fixed effects:
#                                      Estimate Std. Error t value
# (Intercept)                          3.394999   0.263247   12.90
# geothreat_j                          0.049163   0.036135    1.36
# gndrMale                            -0.001766   0.009618   -0.18
# agea                                 0.005507   0.000272   20.23
# edu_attain                          -0.090400   0.002825  -32.00
# uemplaMarked                        -0.026420   0.025022   -1.06
# hincfel                              0.101446   0.006686   15.17
# dfegcf                              -0.234391   0.007446  -31.48
# rlgdnmEastern Orthodox               0.000347   0.054319    0.01
# rlgdnmEastern religions             -0.092211   0.103340   -0.89
# rlgdnmJewish                        -0.022076   0.171995   -0.13
# rlgdnmOther Christian denomination  -0.077482   0.050117   -1.55
# rlgdnmOther non-Christian religions -0.220865   0.100889   -2.19
# rlgdnmProtestant                     0.033007   0.015282    2.16
# rlgdnmRoman Catholic                 0.057295   0.013169    4.35
# TV_not_news                          0.028898   0.002832   10.20
# muslim_j                            -0.081741   0.018939   -4.32
# mipex_j                             -0.009029   0.003925   -2.30
# relstate_j                          -0.020104   0.013955   -1.44
# claims_j                             0.097237   0.095271    1.02
. quietly do "./../../assets/ESS7/8-RI-Replication-2.do"
. mixed almuslv geothreat_j gndr agea edu_attain uempla hincfel dfegcf rlgdnm T
> V_not_news muslim_j mipex_j relstate_j claims_j || cntry: , reml

Performing EM optimization: 

Performing gradient-based optimization: 

Iteration 0:   log restricted-likelihood = -36906.738  
Iteration 1:   log restricted-likelihood = -36906.738  

Computing standard errors:

Mixed-effects REML regression                   Number of obs     =     30,064
Group variable: cntry                           Number of groups  =         20

                                                Obs per group:
                                                              min =        953
                                                              avg =    1,503.2
                                                              max =      2,478

                                                Wald chi2(13)     =    4576.10
Log restricted-likelihood = -36906.738          Prob > chi2       =     0.0000

------------------------------------------------------------------------------
     almuslv |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
 geothreat_j |   .0462634    .035007     1.32   0.186    -.0223492    .1148759
        gndr |   .0045812   .0096072     0.48   0.633    -.0142485     .023411
        agea |   .0056949     .00027    21.10   0.000     .0051658    .0062241
  edu_attain |  -.0909764   .0028226   -32.23   0.000    -.0965086   -.0854443
      uempla |  -.0305992   .0250197    -1.22   0.221     -.079637    .0184385
     hincfel |   .1003558   .0066806    15.02   0.000      .087262    .1134496
      dfegcf |  -.2372076   .0074291   -31.93   0.000    -.2517684   -.2226468
      rlgdnm |   .0029008   .0052653     0.55   0.582     -.007419    .0132206
 TV_not_news |    .028624   .0028328    10.10   0.000     .0230718    .0341761
    muslim_j |  -.0832599   .0183428    -4.54   0.000    -.1192111   -.0473087
     mipex_j |  -.0094109   .0038023    -2.48   0.013    -.0168633   -.0019585
  relstate_j |  -.0208161    .013508    -1.54   0.123    -.0472912     .005659
    claims_j |   .1011748    .092269     1.10   0.273    -.0796692    .2820188
       _cons |   3.441236   .2550542    13.49   0.000     2.941339    3.941133
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
cntry: Identity              |
                  var(_cons) |   .0305724   .0117325      .0144103    .0648615
-----------------------------+------------------------------------------------
               var(Residual) |   .6780185   .0055327      .6672609    .6889495
------------------------------------------------------------------------------
LR test vs. linear model: chibar2(01) = 861.94        Prob >= chibar2 = 0.0000

. 

5. Consider which of these macro-level control variables are potential confounders, and which ones are maybe some also potential mediators that we should not control for.

References

Hiers, Wesley, Thomas Soehl, and Andreas Wimmer. 2017. “National Trauma and the Fear of Foreigners: How Past Geopolitical Threat Heightens Anti-Immigration Sentiment Today.” Social Forces 96(1):361–88. doi: 10.1093/sf/sox045.
Schlueter, Elmar, Anu Masso, and Eldad Davidov. 2019. “What Factors Explain Anti-Muslim Prejudice? An Assessment of the Effects of Muslim Population Size, Institutional Characteristics and Immigration-Related Media Claims.” Journal of Ethnic and Migration Studies 0(0):1–16. doi: 10.1080/1369183X.2018.1550160.