Why is anti-Muslim prejudice more pronounced in some countries than in others? Use your newly-acquired skills to replicate Schlueter, Masso, and Davidov (2019).

1. Replicate Model 1 from Table 1 reported in Schlueter, Masso, and Davidov (2019).

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

# ESS <- import_rounds(rounds = 7, ess_email = YOUR_EMAIL) %>%
ESS <- read_dta("./../../assets/ESS7/ESS7e02_2.dta") %>% ## <-
  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
library(lme4) # Multilevel modeling

# Model 1
Model_1 <- lmer(almuslv ~ gndr + agea + edu_attain + uempla + 
                  hincfel + dfegcf + rlgdnm + TV_not_news + 
                  (1 | cntry), data  = ESS)
summary(Model_1)
# Linear mixed model fit by REML ['lmerMod']
# Formula: almuslv ~ gndr + agea + edu_attain + uempla + hincfel + dfegcf +      rlgdnm + TV_not_news + (1 | cntry)
#    Data: ESS
# 
# REML criterion at convergence: 73799
# 
# Scaled residuals: 
#    Min     1Q Median     3Q    Max 
# -3.559 -0.695  0.008  0.742  3.017 
# 
# Random effects:
#  Groups   Name        Variance Std.Dev.
#  cntry    (Intercept) 0.108    0.329   
#  Residual             0.677    0.823   
# Number of obs: 30064, groups:  cntry, 20
# 
# Fixed effects:
#                                      Estimate Std. Error t value
# (Intercept)                          2.589197   0.077933   33.22
# gndrMale                            -0.001792   0.009619   -0.19
# agea                                 0.005499   0.000272   20.20
# edu_attain                          -0.090385   0.002825  -32.00
# uemplaMarked                        -0.026512   0.025023   -1.06
# hincfel                              0.101836   0.006686   15.23
# dfegcf                              -0.234529   0.007446  -31.50
# rlgdnmEastern Orthodox               0.002227   0.054328    0.04
# rlgdnmEastern religions             -0.092738   0.103340   -0.90
# rlgdnmJewish                        -0.021807   0.171996   -0.13
# rlgdnmOther Christian denomination  -0.077180   0.050118   -1.54
# rlgdnmOther non-Christian religions -0.220956   0.100889   -2.19
# rlgdnmProtestant                     0.032350   0.015284    2.12
# rlgdnmRoman Catholic                 0.059260   0.013188    4.49
# TV_not_news                          0.028921   0.002832   10.21

. 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"

. 
. * Estimation

. ** Model 1

. mixed almuslv i.gndr agea edu_attain uempla hincfel dfegcf i.rlgdnm TV_not_ne
> ws || cntry: , reml

Performing EM optimization: 

Performing gradient-based optimization: 

Iteration 0:   log restricted-likelihood = -36899.551  
Iteration 1:   log restricted-likelihood = -36899.551  (backed up)

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(14)     =    4535.83
Log restricted-likelihood = -36899.551          Prob > chi2       =     0.0000

------------------------------------------------------------------------------
     almuslv |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        gndr |
     Female  |   .0017915   .0096185     0.19   0.852    -.0170605    .0206435
        agea |   .0054991   .0002722    20.20   0.000     .0049656    .0060326
  edu_attain |  -.0903847   .0028248   -32.00   0.000    -.0959213   -.0848481
      uempla |  -.0265116   .0250229    -1.06   0.289    -.0755556    .0225324
     hincfel |   .1018364    .006686    15.23   0.000     .0887322    .1149407
      dfegcf |  -.2345295   .0074462   -31.50   0.000    -.2491238   -.2199351
             |
      rlgdnm |
Roman Cat..  |   .0592596   .0131884     4.49   0.000     .0334109    .0851083
 Protestant  |   .0323498   .0152844     2.12   0.034     .0023929    .0623066
Eastern O..  |   .0022269   .0543284     0.04   0.967    -.1042549    .1087086
Other Chr..  |  -.0771796   .0501177    -1.54   0.124    -.1754086    .0210493
     Jewish  |  -.0218065   .1719959    -0.13   0.899    -.3589124    .3152993
Eastern r..  |  -.0927377   .1033405    -0.90   0.370    -.2952813     .109806
Other non..  |  -.2209562   .1008891    -2.19   0.029    -.4186952   -.0232172
             |
 TV_not_news |   .0289212   .0028325    10.21   0.000     .0233696    .0344727
       _cons |   2.587405   .0777368    33.28   0.000     2.435044    2.739767
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
cntry: Identity              |
                  var(_cons) |   .1079246   .0351921      .0569587    .2044942
-----------------------------+------------------------------------------------
               var(Residual) |   .6774207   .0055284      .6666715    .6883432
------------------------------------------------------------------------------
LR test vs. linear model: chibar2(01) = 3734.30       Prob >= chibar2 = 0.0000

. 

2. Conjoin context data to the ESS On Absalon you find the original macro-level data used by Schlueter, Masso, and Davidov (2019).

# Conjoin Schlueter et al. macro data
ESS <- ESS %>%
  inner_join(., read_dta("./../../assets/ESS7/Schlueter.dta"), by = "cntry")
* Conjoin Schlueter et al. macro data
merge m:1 cntry using "./../../assets/ESS7/Schlueter.dta", keep(match) nogen

3. Replicate Model 2 from Table 1 reported in Schlueter, Masso, and Davidov (2019).

# Model 2
Model_2 <- lmer(
  almuslv ~ 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_2)
# Linear mixed model fit by REML ['lmerMod']
# Formula: almuslv ~ 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: 73799
# 
# Scaled residuals: 
#    Min     1Q Median     3Q    Max 
# -3.557 -0.694  0.009  0.743  3.020 
# 
# Random effects:
#  Groups   Name        Variance Std.Dev.
#  cntry    (Intercept) 0.0344   0.186   
#  Residual             0.6774   0.823   
# Number of obs: 30064, groups:  cntry, 20
# 
# Fixed effects:
#                                      Estimate Std. Error t value
# (Intercept)                          3.529811   0.250494   14.09
# gndrMale                            -0.001773   0.009618   -0.18
# agea                                 0.005507   0.000272   20.23
# edu_attain                          -0.090369   0.002825  -31.99
# uemplaMarked                        -0.026586   0.025022   -1.06
# hincfel                              0.101535   0.006686   15.19
# dfegcf                              -0.234470   0.007446  -31.49
# rlgdnmEastern Orthodox               0.000852   0.054319    0.02
# rlgdnmEastern religions             -0.092259   0.103340   -0.89
# rlgdnmJewish                        -0.022459   0.171995   -0.13
# rlgdnmOther Christian denomination  -0.077413   0.050117   -1.54
# rlgdnmOther non-Christian religions -0.221022   0.100889   -2.19
# rlgdnmProtestant                     0.032939   0.015282    2.16
# rlgdnmRoman Catholic                 0.057076   0.013169    4.33
# TV_not_news                          0.028947   0.002832   10.22
# muslim_j                            -0.088233   0.018832   -4.69
# mipex_j                             -0.010364   0.003905   -2.65
# relstate_j                          -0.017433   0.014196   -1.23
# claims_j                             0.122111   0.096072    1.27

. quietly do "./../../assets/ESS7/7-exercise.. 
. ** Model 2

. mixed almuslv i.gndr agea edu_attain i.uempla hincfel dfegcf i.rlgdnm TV_not_
> news muslim_j mipex_j relstate_j claims_j || cntry: , reml

Performing EM optimization: 

Performing gradient-based optimization: 

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

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(18)     =    4600.41
Log restricted-likelihood =  -36899.45          Prob > chi2       =     0.0000

------------------------------------------------------------------------------
     almuslv |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        gndr |
     Female  |   .0017727   .0096184     0.18   0.854     -.017079    .0206244
        agea |   .0055072   .0002722    20.23   0.000     .0049737    .0060406
  edu_attain |  -.0903693   .0028245   -31.99   0.000    -.0959053   -.0848333
             |
      uempla |
 Unemployed  |   -.026586   .0250219    -1.06   0.288    -.0756281    .0224561
     hincfel |   .1015351   .0066859    15.19   0.000      .088431    .1146391
      dfegcf |  -.2344702   .0074458   -31.49   0.000    -.2490638   -.2198767
             |
      rlgdnm |
Roman Cat..  |   .0570756   .0131686     4.33   0.000     .0312655    .0828856
 Protestant  |    .032939   .0152821     2.16   0.031     .0029866    .0628914
Eastern O..  |   .0008523   .0543188     0.02   0.987    -.1056106    .1073151
Other Chr..  |  -.0774134    .050117    -1.54   0.122    -.1756409    .0208141
     Jewish  |  -.0224594   .1719952    -0.13   0.896    -.3595639     .314645
Eastern r..  |  -.0922595   .1033398    -0.89   0.372    -.2948018    .1102828
Other non..  |  -.2210224   .1008889    -2.19   0.028    -.4187609   -.0232839
             |
 TV_not_news |    .028947   .0028321    10.22   0.000     .0233962    .0344979
    muslim_j |  -.0882334   .0188324    -4.69   0.000    -.1251441   -.0513226
     mipex_j |  -.0103644   .0039052    -2.65   0.008    -.0180185   -.0027104
  relstate_j |  -.0174327   .0141957    -1.23   0.219    -.0452557    .0103903
    claims_j |   .1221106   .0960718     1.27   0.204    -.0661867    .3104079
       _cons |   3.528038   .2504508    14.09   0.000     3.037164    4.018913
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
cntry: Identity              |
                  var(_cons) |   .0344445   .0127685      .0166564    .0712291
-----------------------------+------------------------------------------------
               var(Residual) |   .6774208   .0055284      .6666716    .6883433
------------------------------------------------------------------------------
LR test vs. linear model: chibar2(01) = 935.93        Prob >= chibar2 = 0.0000

. 

References

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.