Download the internationally-comparative ESS 2014 data. Reconstruct our two outcome variables and all predictors that we have constructed so far. Finally, conjoin the ESS country data and survey data.
1. How much does xenophobia vary between countries, and how much does it vary within countries?
library(tidyverse) # Add the tidyverse package to my current library.
library(haven) # Handle labelled data.
library(essurvey) # Add ESS API package.
library(lme4) # For regression with robust SE
library(texreg) # For nicely-formatted regression tables
# Import the ESS round 7 data via the API
ESS <- import_rounds(
rounds = 7,
ess_email = YOUR_EMAIL) %>%
recode_missings() %>%
filter(brncntr == 1 & mocntr == 1 & facntr == 1) %>%
mutate(
# Make variables numeric
imtcjob = zap_labels(imtcjob),
imbleco = zap_labels(imbleco),
rlgueim = zap_labels(rlgueim),
imbgeco = zap_labels(imbgeco),
imueclt = zap_labels(imueclt),
imwbcnt = zap_labels(imwbcnt),
# Generate additive scale 0 to 10
xeno_ij = 10 - ((imtcjob + imbleco + rlgueim + imbgeco + imueclt + imwbcnt) / 6),
# Categorical variables
cntry = as_factor(cntry) %>% fct_drop()) %>%
inner_join(., read_dta("./../../assets/ESS7/ESSMD-2014-cntry_F1.dta") %>%
mutate(
cntry = as_factor(cntry) %>% fct_drop(),
), by = "cntry")
# Random effects ANOVA
RE_anova_xeno <- lmer(xeno_ij ~ (1 | cntry), data = ESS)
summary(RE_anova_xeno)
# Linear mixed model fit by REML ['lmerMod']
# Formula: xeno_ij ~ (1 | cntry)
# Data: ESS
#
# REML criterion at convergence: 1e+05
#
# Scaled residuals:
# Min 1Q Median 3Q Max
# -3.550 -0.665 -0.077 0.604 3.423
#
# Random effects:
# Groups Name Variance Std.Dev.
# cntry (Intercept) 0.338 0.582
# Residual 2.718 1.649
# Number of obs: 26820, groups: cntry, 21
#
# Fixed effects:
# Estimate Std. Error t value
# (Intercept) 5.139 0.127 40.4
# . use "./../../assets/ESS7/ESS7e02_2.dta", clear
#
# . quietly do "./../../assets/ESS7/ESS7e02_2_formats_unicode.do"
# . keep if brncntr == 1 & mocntr == 1 & facntr == 1
# (8,673 observations deleted)
#
# . gen xeno_ij = 10 - ((imtcjob + imbleco + rlgueim + imbgeco + imueclt + imwbcn
# > t) / 6)
# (4,692 missing values generated)
#
# .
# . mixed xeno_ij || cntry: , reml noheader
#
# Performing EM optimization:
#
# Performing gradient-based optimization:
#
# Iteration 0: log restricted-likelihood = -51516.558
# Iteration 1: log restricted-likelihood = -51516.558 (backed up)
#
# Computing standard errors:
#
# ------------------------------------------------------------------------------
# xeno_ij | Coef. Std. Err. z P>|z| [95% Conf. Interval]
# -------------+----------------------------------------------------------------
# _cons | 5.139413 .1273535 40.36 0.000 4.889805 5.389022
# ------------------------------------------------------------------------------
#
# ------------------------------------------------------------------------------
# Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
# -----------------------------+------------------------------------------------
# cntry: Identity |
# var(_cons) | .3382796 .1076742 .1812754 .6312667
# -----------------------------+------------------------------------------------
# var(Residual) | 2.7177 .0234778 2.672071 2.764107
# ------------------------------------------------------------------------------
# LR test vs. linear model: chibar2(01) = 3021.37 Prob >= chibar2 = 0.0000
#
# .
The ICC of Xenophobia is %, meaning there is substantial variation between European countries.
2. How much does superficial inter-racial/ethnic contact vary within and between countries?
# Random effects ANOVA
RE_anova_dfegcon <- lmer(dfegcon ~ (1 | cntry), data = ESS)
summary(RE_anova_dfegcon)
# Linear mixed model fit by REML ['lmerMod']
# Formula: dfegcon ~ (1 | cntry)
# Data: ESS
#
# REML criterion at convergence: 132515
#
# Scaled residuals:
# Min 1Q Median 3Q Max
# -2.3710 -0.8886 0.0948 0.8377 2.3814
#
# Random effects:
# Groups Name Variance Std.Dev.
# cntry (Intercept) 0.676 0.822
# Residual 4.065 2.016
# Number of obs: 31224, groups: cntry, 21
#
# Fixed effects:
# Estimate Std. Error t value
# (Intercept) 4.28 0.18 23.8
# . use "./../../assets/ESS7/ESS7e02_2.dta", clear
#
# . quietly do "./../../assets/ESS7/ESS7e02_2_formats_unicode.do"
# . keep if brncntr == 1 & mocntr == 1 & facntr == 1
# (8,673 observations deleted)
#
# .
# . mixed dfegcon || cntry: , reml noheader
#
# Performing EM optimization:
#
# Performing gradient-based optimization:
#
# Iteration 0: log restricted-likelihood = -66257.59
# Iteration 1: log restricted-likelihood = -66257.59
#
# Computing standard errors:
#
# ------------------------------------------------------------------------------
# dfegcon | Coef. Std. Err. z P>|z| [95% Conf. Interval]
# -------------+----------------------------------------------------------------
# _cons | 4.282379 .1797884 23.82 0.000 3.930001 4.634758
# ------------------------------------------------------------------------------
#
# ------------------------------------------------------------------------------
# Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
# -----------------------------+------------------------------------------------
# cntry: Identity |
# var(_cons) | .6758612 .2146165 .3627126 1.259368
# -----------------------------+------------------------------------------------
# var(Residual) | 4.06509 .0325452 4.0018 4.12938
# ------------------------------------------------------------------------------
# LR test vs. linear model: chibar2(01) = 4524.54 Prob >= chibar2 = 0.0000
#
# .
The ICC of of superficial inter-racial/ethnic contact is %, meaning there is substantial variation between European countries.
3. Taking the information from both tasks above into account, do you think statistical inference will be biased if we OLS-regress racism on superficial inter-racial/ethnic contact across the whole ESS sample?**