The following scripts can be used to replicate the data-set for the preregistered Experiments 1 and 2 of Dederichs et al. (2025). It may also be obtained by downloading: Download conjoint_liss.Rda
To copy the code, click the button in the upper right corner of the code-chunks.
rm(list = ls())
gc()
fpackage.check: Check if packages are installed (and
install if not) in Rfsave: Function to save data with time stamp in correct
directoryfload: Function to load R-objects under new namesfshowdf: Print objects (tibble /
data.frame) nicely on screen in .Rmdfpackage.check <- function(packages) {
lapply(packages, FUN = function(x) {
if (!require(x, character.only = TRUE)) {
install.packages(x, dependencies = TRUE)
library(x, character.only = TRUE)
}
})
}
fsave <- function(x, file, location = "./data/processed/", ...) {
if (!dir.exists(location))
dir.create(location)
datename <- substr(gsub("[:-]", "", Sys.time()), 1, 8)
totalname <- paste(location, datename, file, sep = "")
print(paste("SAVED: ", totalname, sep = ""))
save(x, file = totalname)
}
fload <- function(fileName) {
load(fileName)
get(ls()[ls() != "fileName"])
}
fshowdf <- function(x, ...) {
knitr::kable(x, digits = 2, "html", ...) %>%
kableExtra::kable_styling(bootstrap_options = c("striped", "hover")) %>%
kableExtra::scroll_box(width = "100%", height = "300px")
}
tidyverse: data wranglinghaven: read and write various data formatssjlabelled: work with labelled (SPSS) datapackages = c("tidyverse", "haven", "sjlabelled")
fpackage.check(packages)
rm(packages)
Download the data files from the LISS data archive. Note that you must join the LISS community and create an account to access the downloads.
The primary data of the survey module “The Bridging Power of Civic Organizations and Neighborhoods”.
Background data of the LISS Core Study:
We used objective data about the composition of neighborhoods, retrieved from CBS. Although these data are not publicly available, our constructed data-set (indicating the levels of neighborhood exposure to high/low-income households, young/old individuals, and residents with Turkish/Moroccan backgrounds; for specific subgroups) can be retrieved by downloading: Download public_composition_data.Rda.
Download the data-files, unzip them if needed, and put them in the
./data/ folder. But first, make a ./data/
folder:
ifelse(!dir.exists("data"), dir.create("data"), FALSE)
Now import the downloaded data:
# Main data survey module
liss <- read_sav("./data/xs23a_EN_1.0p.sav")
# Background data september 2023
bckgrnd <- read_sav("./data/avars_202309_EN_1.0p.sav")
# Latest religion and ethnicity module (information about people's identification with different
# minority groups)
releth <- read_sav("./data/cr23p_EN_1.0p.sav")
releth_previousyear <- read_sav("./data/cr22o_EN_1.0p.sav")
# public data about composition of 'buurten'
comp <- fload("./data/public_composition_data.Rda")
bckgrnd <- bckgrnd %>% select(c('nomem_encr', 'herkomstgroep', 'geslacht', 'leeftijd', 'gebjaar', 'oplmet', 'sted'))
releth <- releth %>%
mutate(orig_tur = if_else(cr23p166==1 | cr23p167==1, 1, 0), #Turks and Kurds
orig_mor = if_else(cr23p168==1 | cr23p169==1, 1, 0), #Moroccans and Berbers
lang_tur = if_else(cr23p085==1 | cr23p090==6, 1, 0), #person spoke turkish growing up or speaks it now
lang_mor = if_else(cr23p080==1 | cr23p081==1 | cr23p090 %in% c(1, 2), 1, 0), #person spoke berber or arab growing up or speaks it now
rel_isl = if_else(cr23p135==12 | cr23p144==10, 1, 0)) #person grew up with Islam or is currently feels they belong to Islam
releth <- releth %>% select(c('nomem_encr'), starts_with('orig_'), starts_with('lang_'), starts_with('rel_isl'))
#Year previous to our survey (2022)
releth_previousyear <- releth_previousyear %>%
mutate(orig_tur_prev = if_else(cr22o166==1 | cr22o167==1, 1, 0), #Turks and Kurds
orig_mor_prev = if_else(cr22o168==1 | cr22o169==1, 1, 0), #Moroccans and Berbers
lang_tur_prev = if_else(cr22o085==1 | cr22o090==6, 1, 0), #person spoke turkish growing up or speaks it now
lang_mor_prev = if_else(cr22o080==1 | cr22o081==1 | cr22o090 %in% c(1, 2), 1, 0), #person spoke berber or arab growing up or speaks it now
rel_isl_prev = if_else(cr22o143==10 | cr22o135==12, 1, 0)) #person grew up with Islam or is currently feels they belong to Islam
releth_previousyear <- releth_previousyear %>% select(c('nomem_encr'), starts_with('orig_'), starts_with('lang_'), starts_with('rel_isl'))
liss <- merge(liss, bckgrnd, by='nomem_encr', all.x = TRUE, all.y = FALSE)
liss <- merge(liss, releth, by='nomem_encr', all.x = TRUE, all.y = FALSE)
liss <- merge(liss, releth_previousyear, by='nomem_encr', all.x = TRUE, all.y = FALSE)
liss <- liss %>%
mutate(eth_dtm = case_when(herkomstgroep==0 & (lang_tur!=1 | is.na(lang_tur)) & (lang_mor!=1 | is.na(lang_mor)) & (orig_tur!=1 | is.na(orig_tur)) & (orig_mor!=1 | is.na(orig_mor)) & (rel_isl!=1 | is.na(rel_isl)) &
(lang_tur_prev!=1 | is.na(lang_tur_prev)) & (lang_mor_prev!=1 | is.na(lang_mor_prev)) & (orig_tur_prev!=1 | is.na(orig_tur_prev)) & (orig_mor_prev!=1 | is.na(orig_mor_prev)) & (rel_isl_prev!=1 | is.na(rel_isl_prev))~ 'Dutch',
(lang_tur==1 | lang_mor==1 | orig_tur==1 | orig_mor==1 |
lang_tur_prev==1 | lang_mor_prev==1 | orig_tur_prev==1 | orig_mor_prev==1) ~ 'Turkish/Moroccan'))
liss <- liss %>%
mutate(eth_dwnw = case_when(herkomstgroep==0 ~ 'Dutch',
herkomstgroep %in% c(101, 201) ~ 'Western',
herkomstgroep %in% c(102, 202) ~ 'Non-Western'),
eth_dnw = case_when(herkomstgroep==0 ~ 'Dutch',
herkomstgroep %in% c(102, 202) ~ 'Non-Western'),
eth_tm = if_else(orig_tur==1 | orig_mor==1, 1, 0),
eth_dtmwnw = case_when(eth_tm==1 ~ 'Turkish/Moroccan',
herkomstgroep==0 ~ 'Dutch',
herkomstgroep %in% c(102, 202) ~ 'Other Non-Western',
herkomstgroep %in% c(101, 201) ~ 'Western'),
eth_dtmo = case_when(eth_tm==1 ~ 'Turkish/Moroccan',
herkomstgroep==0 ~ 'Dutch',
herkomstgroep %in% c(101, 102, 201, 202) ~ 'Other'))
#here, add the simplified "buurten" composition data
names(comp)[2] <- "ethnbh_obj_TM"
names(comp)[3] <- "hinbh_obj_Educ"
names(comp)[4] <- "agenbh_obj_Age"
liss <- merge(liss,comp, by="nomem_encr")
#create variables with intuitive names from raw data (in same order as codebook)
#prefix explanation: o = observational data, e = experimental data, civ = civic organization, nbh = neighborhood
liss <- liss %>%
mutate(#CIVIC ORGANIZATIONS#
#Variables indicating whether respondent WAS involved in each type of org during SIL model 2023:
ociv_inv_was_sport = xs23a003,
ociv_inv_was_culture = xs23a004,
ociv_inv_was_union = xs23a005,
ociv_inv_was_prof = xs23a006,
ociv_inv_was_consum = xs23a007,
ociv_inv_was_humanit = xs23a008,
ociv_inv_was_migrant = xs23a009,
ociv_inv_was_envmnt = xs23a010,
ociv_inv_was_relig = xs23a011,
ociv_inv_was_polit = xs23a012,
ociv_inv_was_educ = xs23a013,
ociv_inv_was_social = xs23a014,
ociv_inv_was_other = xs23a015,
#Variables indicating whether respondent IS currently involved in each type of org:
ociv_inv_is_sport = xs23a148,
ociv_inv_is_culture = xs23a149,
ociv_inv_is_union = xs23a150,
ociv_inv_is_prof = xs23a151,
ociv_inv_is_consum = xs23a152,
ociv_inv_is_humanit = xs23a153,
ociv_inv_is_migrant = xs23a154,
ociv_inv_is_envmnt = xs23a155,
ociv_inv_is_relig = xs23a156,
ociv_inv_is_polit = xs23a157,
ociv_inv_is_educ = xs23a158,
ociv_inv_is_social = xs23a159,
ociv_inv_is_other = xs23a160,
ociv_inv_is_none = xs23a161,
#Information on most important organization:
ociv_mostimp_type = case_when(xs23a035==1 ~ 'Sports',
xs23a035==2 ~ 'Cultural',
xs23a035==3 ~ 'Union',
xs23a035==4 ~ 'Professional',
xs23a035==5 ~ 'Consumer',
xs23a035==6 ~ 'Humanitarian',
xs23a035==7 ~ 'Migrants',
xs23a035==8 ~ 'Environmental',
xs23a035==9 ~ 'Religious',
xs23a035==10 ~ 'Political',
xs23a035==11 ~ 'Educational',
xs23a035==12 ~ 'Social',
xs23a035==13 ~ 'Other'),
ociv_mostimp_type = factor(ociv_mostimp_type, levels = c('Sports', 'Cultural', 'Union', 'Professional', 'Consumer', 'Humanitarian', 'Migrants', 'Environmental', 'Religious', 'Political', 'Educational', 'Social', 'Other')),
ociv_fincontr = xs23a164,
ociv_freqpart = case_when(xs23a170==1 ~ 'Less than once per month', xs23a170==2 ~ '1-3 times per month', xs23a170==3 ~ 'Once per week', xs23a170==4 ~ 'More than once per week'),
ociv_freqpart = factor(ociv_freqpart, levels = c('Less than once per month', '1-3 times per month', 'Once per week', 'More than once per week')),
ociv_freqpart_num = case_when(xs23a170==1 ~ 0.5, xs23a170==2 ~ 2, xs23a170==3 ~ 4, xs23a170==4 ~ 8),
ociv_size = case_when(xs23a171==1 ~ 'Less than 20', xs23a171==2 ~ '20-49', xs23a171==3 ~ '50-99', xs23a171==4 ~ '100-199', xs23a171==5 ~ '200-499', xs23a171==6 ~ '500+'),
ociv_size = factor(ociv_size, levels = c('Less than 20', '20-49', '50-99', '100-199', '200-499', '500+')),
ociv_size_num = case_when(xs23a171==1 ~ 10, xs23a171==2 ~ 34.5, xs23a171==3 ~ 74.5, xs23a171==4 ~ 149.5, xs23a171==5 ~ 349.5, xs23a171==6 ~ 500),
ociv_nrcontact = case_when(xs23a172==1 ~ 'None', xs23a172==2 ~ '1-4', xs23a172==3 ~ '5-9', xs23a172==4 ~ '10-19', xs23a172==5 ~ '20-49', xs23a172==6 ~ '50+'),
ociv_nrcontact = factor(ociv_nrcontact, levels = c('None', '1-4', '5-9', '10-19', '20-49', '50+')),
ociv_nrcontact_num = case_when(xs23a172==1 ~ 0, xs23a172==2 ~ 2.5, xs23a172==3 ~ 7, xs23a172==4 ~ 14.5, xs23a172==5 ~ 34, xs23a172==6 ~ 50),
ociv_satisf = xs23a173,
#Composition of civic orgs and respondents' contact within them:
ociv_comp_gnd = xs23a174, ociv_comp_age = xs23a175,
ociv_comp_eth = xs23a176, ociv_comp_edu = xs23a177,
ociv_cont_gnd = xs23a182, ociv_cont_age = xs23a183,
ociv_cont_eth = xs23a184, ociv_cont_edu = xs23a185,
ociv_comp_gnd_dk = xs23a178, ociv_comp_age_dk = xs23a179,
ociv_comp_eth_dk = xs23a180, ociv_comp_edu_dk = xs23a181,
ociv_cont_gnd_dk = xs23a186, ociv_cont_age_dk = xs23a187,
ociv_cont_eth_dk = xs23a188, ociv_cont_edu_dk = xs23a189,
#Number of contacts with certain socio-demographic characteristics:
ociv_cont_nrfemales = ociv_nrcontact_num * ociv_cont_gnd * 0.01,
ociv_cont_nrmales = ociv_nrcontact_num * (100-ociv_cont_gnd) * 0.01,
ociv_cont_nrold = ociv_nrcontact_num * ociv_cont_age * 0.01,
ociv_cont_nryoung = ociv_nrcontact_num * (100-ociv_cont_age) * 0.01,
ociv_cont_nrturmor = ociv_nrcontact_num * ociv_cont_eth * 0.01,
ociv_cont_nrdutch = ociv_nrcontact_num * (100-ociv_cont_eth) * 0.01,
ociv_cont_nrcollege = ociv_nrcontact_num * ociv_cont_edu * 0.01,
ociv_cont_nrnocollege = ociv_nrcontact_num * (100-ociv_cont_edu) * 0.01,
#NEIGHBORHOODS#
onbh_rent = xs23a190,
onbh_satisf = xs23a197,
#Composition of neighborhoods and respondents' contact within them:
onbh_comp_gnd = xs23a198, onbh_comp_age = xs23a199,
onbh_comp_eth = xs23a200, onbh_comp_edu = xs23a201,
onbh_cont_gnd = xs23a206, onbh_cont_age = xs23a207,
onbh_cont_eth = xs23a208, onbh_cont_edu = xs23a209,
onbh_comp_gnd_dk = xs23a202, onbh_comp_age_dk = xs23a203,
onbh_comp_eth_dk = xs23a204, onbh_comp_edu_dk = xs23a205,
onbh_cont_gnd_dk = xs23a210, onbh_cont_age_dk = xs23a211,
onbh_cont_eth_dk = xs23a212, onbh_cont_edu_dk = xs23a213,
#Number of contacts with certain socio-demographic characteristics:
onbh_nrcontact = case_when(xs23a196==1 ~ 'None', xs23a196==2 ~ '1-4', xs23a196==3 ~ '5-9', xs23a196==4 ~ '10-19', xs23a196==5 ~ '20-49', xs23a196==6 ~ '50+'),
onbh_nrcontact = factor(onbh_nrcontact, levels = c('None', '1-4', '5-9', '10-19', '20-49', '50+')),
onbh_nrcontact_num = case_when(xs23a196==1 ~ 0, xs23a196==2 ~ 2.5, xs23a196==3 ~ 7, xs23a196==4 ~ 14.5, xs23a196==5 ~ 34, xs23a196==6 ~ 50),
onbh_cont_nrfemales = onbh_nrcontact_num * onbh_cont_gnd * 0.01,
onbh_cont_nrmales = onbh_nrcontact_num * (100-onbh_cont_gnd) * 0.01,
onbh_cont_nrold = onbh_nrcontact_num * onbh_cont_age * 0.01,
onbh_cont_nryoung = onbh_nrcontact_num * (100-onbh_cont_age) * 0.01,
onbh_cont_nrturmor = onbh_nrcontact_num * onbh_cont_eth * 0.01,
onbh_cont_nrdutch = onbh_nrcontact_num * (100-onbh_cont_eth) * 0.01,
onbh_cont_nrcollege = onbh_nrcontact_num * onbh_cont_edu * 0.01,
onbh_cont_nrnocollege = onbh_nrcontact_num * (100-onbh_cont_edu) * 0.01,
#Evaluation questions:
ev_difficult = xs23a214,
ev_clear = xs23a215,
ev_thinking = xs23a216,
ev_interestingtopic = xs23a217,
ev_fun = xs23a218,
#other information
surv_start_date = xs23a219,
surv_start_time = xs23a220,
surv_end_date = xs23a221,
surv_end_time = xs23a222,
surv_duration = xs23a223,
#Socio-demographic variables:
sex3 = case_when(geslacht==1 ~ 'male', geslacht==2 ~ 'female', geslacht==3 ~ 'diverse'),
sex = case_when(geslacht==1 ~ 'male', geslacht==2 ~ 'female'),
age = case_when(leeftijd<50 ~ 'under 50', leeftijd>=50 ~ '50 or older'),
age_continuous = leeftijd,
birthyear = gebjaar,
edu = case_when(oplmet %in% c(5, 6) ~ 'college degree', oplmet %in% c(1, 2, 3, 4, 8, 9) ~ 'no college degree'), #level 7 is NA (label 'other'),
edu_unihbo = case_when(oplmet == 6 ~ 'research university', oplmet == 5 ~ 'university of applied sciences')
)
liss <- liss %>%
select(-starts_with(c('surv', 'ev', 'oplmet', 'geslacht', 'leeftijd', 'gebjaar', 'herkomstgroep')))
#Additional preparation: composition and contact across different dimensions and settings:
liss <- liss %>%
mutate(ociv_comp_same_gnd = case_when(sex=='female' ~ ociv_comp_gnd, sex=='male' ~ 100-ociv_comp_gnd),
ociv_comp_same_edu = case_when(edu=='college degree' ~ ociv_comp_edu, edu=='no college degree' ~ 100-ociv_comp_edu),
ociv_comp_same_age = case_when(age=='50 or older' ~ ociv_comp_age, age=='under 50' ~ 100-ociv_comp_age),
ociv_comp_same_eth = case_when(eth_dtm=='Turkish/Moroccan' ~ ociv_comp_eth, eth_dtm=='Dutch' ~ 100-ociv_comp_eth),
ociv_comp_same_gnd_50 = case_when(ociv_comp_same_gnd>=50 ~ 1, ociv_comp_same_gnd<50 ~ 0),
ociv_comp_same_edu_50 = case_when(ociv_comp_same_edu>=50 ~ 1, ociv_comp_same_edu<50 ~ 0),
ociv_comp_same_age_50 = case_when(ociv_comp_same_age>=50 ~ 1, ociv_comp_same_age<50 ~ 0),
ociv_comp_same_eth_50 = case_when(ociv_comp_same_eth>=50 ~ 1, ociv_comp_same_eth<50 ~ 0),
ociv_comp_same_dimensions4_50 = ociv_comp_same_gnd_50 + ociv_comp_same_edu_50 + ociv_comp_same_age_50 + ociv_comp_same_eth_50,
ociv_comp_same_dimensions3_50 = ociv_comp_same_gnd_50 + ociv_comp_same_edu_50 + ociv_comp_same_age_50,
ociv_cont_same_gnd = case_when(sex=='female' ~ ociv_cont_gnd, sex=='male' ~ 100-ociv_cont_gnd),
ociv_cont_same_edu = case_when(edu=='college degree' ~ ociv_cont_edu, edu=='no college degree' ~ 100-ociv_cont_edu),
ociv_cont_same_age = case_when(age=='50 or older' ~ ociv_cont_age, age=='under 50' ~ 100-ociv_cont_age),
ociv_cont_same_eth = case_when(eth_dtm=='Turkish/Moroccan' ~ ociv_cont_eth, eth_dtm=='Dutch' ~ 100-ociv_cont_eth),
ociv_cont_same_gnd_50 = case_when(ociv_cont_same_gnd>=50 ~ 1, ociv_cont_same_gnd<50 ~ 0),
ociv_cont_same_edu_50 = case_when(ociv_cont_same_edu>=50 ~ 1, ociv_cont_same_edu<50 ~ 0),
ociv_cont_same_age_50 = case_when(ociv_cont_same_age>=50 ~ 1, ociv_cont_same_age<50 ~ 0),
ociv_cont_same_eth_50 = case_when(ociv_cont_same_eth>=50 ~ 1, ociv_cont_same_eth<50 ~ 0),
ociv_cont_same_dimensions4_50 = ociv_cont_same_gnd_50 + ociv_cont_same_edu_50 + ociv_cont_same_age_50 + ociv_cont_same_eth_50,
ociv_cont_same_dimensions3_50 = ociv_cont_same_gnd_50 + ociv_cont_same_edu_50 + ociv_cont_same_age_50)
liss <- liss %>%
mutate(onbh_comp_same_gnd = case_when(sex=='female' ~ onbh_comp_gnd, sex=='male' ~ 100-onbh_comp_gnd),
onbh_comp_same_edu = case_when(edu=='college degree' ~ onbh_comp_edu, edu=='no college degree' ~ 100-onbh_comp_edu),
onbh_comp_same_age = case_when(age=='50 or older' ~ onbh_comp_age, age=='under 50' ~ 100-onbh_comp_age),
onbh_comp_same_eth = case_when(eth_dtm=='Turkish/Moroccan' ~ onbh_comp_eth, eth_dtm=='Dutch' ~ 100-onbh_comp_eth),
onbh_comp_same_gnd_50 = case_when(onbh_comp_same_gnd>=50 ~ 1, onbh_comp_same_gnd<50 ~ 0),
onbh_comp_same_edu_50 = case_when(onbh_comp_same_edu>=50 ~ 1, onbh_comp_same_edu<50 ~ 0),
onbh_comp_same_age_50 = case_when(onbh_comp_same_age>=50 ~ 1, onbh_comp_same_age<50 ~ 0),
onbh_comp_same_eth_50 = case_when(onbh_comp_same_eth>=50 ~ 1, onbh_comp_same_eth<50 ~ 0),
onbh_comp_same_dimensions4_50 = onbh_comp_same_gnd_50 + onbh_comp_same_edu_50 + onbh_comp_same_age_50 + onbh_comp_same_eth_50,
onbh_comp_same_dimensions3_50 = onbh_comp_same_gnd_50 + onbh_comp_same_edu_50 + onbh_comp_same_age_50,
onbh_cont_same_gnd = case_when(sex=='female' ~ onbh_cont_gnd, sex=='male' ~ 100-onbh_cont_gnd),
onbh_cont_same_edu = case_when(edu=='college degree' ~ onbh_cont_edu, edu=='no college degree' ~ 100-onbh_cont_edu),
onbh_cont_same_age = case_when(age=='50 or older' ~ onbh_cont_age, age=='under 50' ~ 100-onbh_cont_age),
onbh_cont_same_eth = case_when(eth_dtm=='Turkish/Moroccan' ~ onbh_cont_eth, eth_dtm=='Dutch' ~ 100-onbh_cont_eth),
onbh_cont_same_gnd_50 = case_when(onbh_cont_same_gnd>=50 ~ 1, onbh_cont_same_gnd<50 ~ 0),
onbh_cont_same_edu_50 = case_when(onbh_cont_same_edu>=50 ~ 1, onbh_cont_same_edu<50 ~ 0),
onbh_cont_same_age_50 = case_when(onbh_cont_same_age>=50 ~ 1, onbh_cont_same_age<50 ~ 0),
onbh_cont_same_eth_50 = case_when(onbh_cont_same_eth>=50 ~ 1, onbh_cont_same_eth<50 ~ 0),
onbh_cont_same_dimensions4_50 = onbh_cont_same_gnd_50 + onbh_cont_same_edu_50 + onbh_cont_same_age_50 + onbh_cont_same_eth_50,
onbh_cont_same_dimensions3_50 = onbh_cont_same_gnd_50 + onbh_cont_same_edu_50 + onbh_cont_same_age_50)
#store dataframe in df
df <- liss
#1. organization choice experiment
#2. neighborhood choice experiment
#to long format
#make respondent id
df$id <- 1:nrow(df)
#each list element contains the choices for each set:
#thus, reistijd.list1[[3]][2] is the level of the travel time attribute of option 2 in choice-set 3 of the civ org experiment.
{
reistijd.list1 <- list(
c("xs23a036", "xs23a037"),
c("xs23a050", "xs23a051"),
c("xs23a064", "xs23a065"),
c("xs23a078", "xs23a079")
)
kosten.list1 <- list(
c("xs23a038", "xs23a039"),
c("xs23a052", "xs23a053"),
c("xs23a066", "xs23a067"),
c("xs23a080", "xs23a081")
)
cohesie.list1 <- list(
c("xs23a040", "xs23a041"),
c("xs23a054", "xs23a055"),
c("xs23a068", "xs23a069"),
c("xs23a082", "xs23a083")
)
bekenden.list1 <- list(
c("xs23a042", "xs23a043"),
c("xs23a056", "xs23a057"),
c("xs23a070", "xs23a071"),
c("xs23a084", "xs23a085")
)
opleiding.list1 <- list(
c("xs23a044", "xs23a045"),
c("xs23a058", "xs23a059"),
c("xs23a072", "xs23a073"),
c("xs23a086", "xs23a087")
)
leeftijd.list1 <- list(
c("xs23a046", "xs23a047"),
c("xs23a060", "xs23a061"),
c("xs23a074", "xs23a075"),
c("xs23a088", "xs23a089")
)
migratie.list1 <- list(
c("xs23a048", "xs23a049"),
c("xs23a062", "xs23a063"),
c("xs23a076", "xs23a077"),
c("xs23a090", "xs23a091")
)
chosen1 <- c("xs23a165","xs23a166","xs23a167","xs23a168")
reistijd.list2 <- list(
c("xs23a092", "xs23a093"),
c("xs23a106", "xs23a107"),
c("xs23a120", "xs23a121"),
c("xs23a134", "xs23a135")
)
kosten.list2 <- list(
c("xs23a094", "xs23a095"),
c("xs23a108", "xs23a109"),
c("xs23a122", "xs23a123"),
c("xs23a136", "xs23a137")
)
cohesie.list2 <- list(
c("xs23a096", "xs23a097"),
c("xs23a110", "xs23a111"),
c("xs23a124", "xs23a125"),
c("xs23a138", "xs23a139")
)
bekenden.list2 <- list(
c("xs23a098", "xs23a099"),
c("xs23a112", "xs23a113"),
c("xs23a126", "xs23a127"),
c("xs23a140", "xs23a141")
)
opleiding.list2 <- list(
c("xs23a100", "xs23a101"),
c("xs23a114", "xs23a115"),
c("xs23a128", "xs23a129"),
c("xs23a142", "xs23a143")
)
leeftijd.list2 <- list(
c("xs23a102", "xs23a103"),
c("xs23a116", "xs23a117"),
c("xs23a130", "xs23a131"),
c("xs23a144", "xs23a145")
)
migratie.list2 <- list(
c("xs23a104", "xs23a105"),
c("xs23a118", "xs23a119"),
c("xs23a132", "xs23a133"),
c("xs23a146", "xs23a147")
)
chosen2 <- c("xs23a191","xs23a192","xs23a193","xs23a194")
}
for (set in 1:4) {
for (choice in 1:2) {
data <- as.data.frame(df)
#civ
data$eciv_set <- set
data$eciv_options <- choice
data$eciv_time <- data[, names(data) == reistijd.list1[[set]][choice]]
data$eciv_cost <- data[, names(data) == kosten.list1[[set]][choice]]
data$eciv_cohesion <- data[, names(data) == cohesie.list1[[set]][choice]]
data$eciv_acquaintances <- data[, names(data) == bekenden.list1[[set]][choice]]
data$eciv_comp_educ <- data[, names(data) == opleiding.list1[[set]][choice]]
data$eciv_comp_age <- data[, names(data) == leeftijd.list1[[set]][choice]]
data$eciv_comp_eth <- data[, names(data) == migratie.list1[[set]][choice]]
data$eciv_chosen <- data[, names(data) == chosen1[set]]
#nbh
data$enbh_set <- set
data$enbh_options <- choice
data$enbh_time <- data[, names(data) == reistijd.list2[[set]][choice]]
data$enbh_cost <- data[, names(data) == kosten.list2[[set]][choice]]
data$enbh_cohesion <- data[, names(data) == cohesie.list2[[set]][choice]]
data$enbh_acquaintances <- data[, names(data) == bekenden.list2[[set]][choice]]
data$enbh_comp_educ <- data[, names(data) == opleiding.list2[[set]][choice]]
data$enbh_comp_age <- data[, names(data) == leeftijd.list2[[set]][choice]]
data$enbh_comp_eth <- data[, names(data) == migratie.list2[[set]][choice]]
data$enbh_chosen <- data[, names(data) == chosen2[set]]
if(set == 1 & choice == 1) {
df_long <- data
} else {
df_long <- rbind(df_long, data)
}
}
}
# reorder
df_long <- df_long[order(df_long$id, df_long$eciv_set, df_long$eciv_options, df_long$enbh_set, df_long$enbh_options), ]
row.names(df_long) <- 1:nrow(df_long)
# define the choices
df_long$eciv_choice <- (df_long$eciv_chosen == c(1, 2)[df_long$eciv_options])
df_long$enbh_choice <- (df_long$enbh_chosen == c(1, 2)[df_long$enbh_options])
# recode levels
df_long <- df_long %>% mutate(
eciv_time = case_when(
eciv_time == 1 ~ "travel time: 10 minutes",
eciv_time == 2 ~ "travel time: 15 minutes",
eciv_time == 3 ~ "travel time: 20 minutes"),
enbh_time = case_when(
enbh_time == 1 ~ "travel time to facilities: 10 minutes",
enbh_time == 2 ~ "travel time to facilities: 15 minutes",
enbh_time == 3 ~ "travel time to facilities: 20 minutes"),
eciv_cost = case_when(
eciv_cost == 1 ~ "costs: 70% of current contribution",
eciv_cost == 2 ~ "costs: 90% of current contribution",
eciv_cost == 3 ~ "costs: 100% of current contribution",
eciv_cost == 4 ~ "costs: 110% of current contribution",
eciv_cost == 5 ~ "costs: 130% of current contribution"),
enbh_cost = case_when(
enbh_cost == 1 ~ "costs: 90% of current housing expenses",
enbh_cost == 2 ~ "costs: 95% of current housing expenses",
enbh_cost == 3 ~ "costs: 100% of current housing expenses",
enbh_cost == 4 ~ "costs: 105% of current housing expenses",
enbh_cost == 5 ~ "costs: 110% of current housing expenses"),
eciv_cohesion = case_when(
eciv_cohesion == 1 ~ "cohesion: people know each other well",
eciv_cohesion == 2 ~ "cohesion: some know each other well, others only by sight",
eciv_cohesion == 3 ~ "cohesion: people know each other only by sight"),
enbh_cohesion = case_when(
enbh_cohesion == 1 ~ "cohesion: neighbors know each other well",
enbh_cohesion == 2 ~ "cohesion: neighbors know each other only by sight",
enbh_cohesion == 3 ~ "cohesion: some know each other well, others only by sight"),
eciv_acquaintances = case_when(
eciv_acquaintances == 1 ~ "acquaintances: no one",
eciv_acquaintances == 2 ~ "acquaintances: one person",
eciv_acquaintances == 3 ~ "acquaintances: multiple"),
enbh_acquaintances = case_when(
enbh_acquaintances == 1 ~ "acquaintances: multiple",
enbh_acquaintances == 2 ~ "acquaintances: one person",
enbh_acquaintances == 3 ~ "acquaintances: no one"),
eciv_comp_educ = case_when(
eciv_comp_educ == 1 ~ "education: a quarter (25%)",
eciv_comp_educ == 2 ~ "education: half (50%)",
eciv_comp_educ == 3 ~ "education: three quarters (75%)"),
enbh_comp_educ = case_when(
enbh_comp_educ == 1 ~ "education: a quarter (25%)",
enbh_comp_educ == 2 ~ "education: half (50%)",
enbh_comp_educ == 3 ~ "education: three quarters (75%)"),
eciv_comp_age = case_when(
eciv_comp_age == 1 ~ "age: a quarter (25%)",
eciv_comp_age == 2 ~ "age: just under half (40%)",
eciv_comp_age == 3 ~ "age: half (50%)"),
enbh_comp_age = case_when(
enbh_comp_age == 1 ~ "age: a quarter (25%)",
enbh_comp_age == 2 ~ "age: just under half (40%)",
enbh_comp_age == 3 ~ "age: half (50%)"),
eciv_comp_eth = case_when(
eciv_comp_eth == 1 ~ "migration: none (0%)",
eciv_comp_eth == 2 ~ "migration: minority (10%)",
eciv_comp_eth == 3 ~ "migration: a quarter (25%)"),
enbh_comp_eth = case_when(
enbh_comp_eth == 1 ~ "migration: none (0%)",
enbh_comp_eth == 2 ~ "migration: minority (10%)",
enbh_comp_eth == 3 ~ "migration: a quarter (25%)")
)
#last, reorder attribute levels
{
#civ
df_long$eciv_time <- factor(df_long$eciv_time, levels = rev(c("travel time: 10 minutes", "travel time: 15 minutes", "travel time: 20 minutes")))
df_long$eciv_cost <- factor(df_long$eciv_cost, levels = rev(c("costs: 70% of current contribution","costs: 90% of current contribution","costs: 100% of current contribution", "costs: 110% of current contribution","costs: 130% of current contribution")))
df_long$eciv_cohesion <- factor(df_long$eciv_cohesion, levels = rev(c( "cohesion: people know each other well", "cohesion: some know each other well, others only by sight","cohesion: people know each other only by sight" )))
df_long$eciv_acquaintances <- factor(df_long$eciv_acquaintances, levels = rev(c("acquaintances: no one", "acquaintances: one person", "acquaintances: multiple")))
df_long$eciv_comp_educ <- factor(df_long$eciv_comp_educ, levels = rev(c("education: a quarter (25%)", "education: half (50%)","education: three quarters (75%)")))
df_long$eciv_comp_age <- factor(df_long$eciv_comp_age, levels = rev(c("age: a quarter (25%)","age: just under half (40%)","age: half (50%)")))
df_long$eciv_comp_eth <- factor(df_long$eciv_comp_eth, levels = rev(c("migration: none (0%)", "migration: minority (10%)", "migration: a quarter (25%)")))
#nbh
df_long$enbh_time <- factor(df_long$enbh_time, levels = rev(c("travel time to facilities: 10 minutes", "travel time to facilities: 15 minutes", "travel time to facilities: 20 minutes")))
df_long$enbh_cost <- factor(df_long$enbh_cost, levels = rev(c("costs: 90% of current housing expenses","costs: 95% of current housing expenses","costs: 100% of current housing expenses", "costs: 105% of current housing expenses","costs: 110% of current housing expenses")))
df_long$enbh_cohesion <- factor(df_long$enbh_cohesion, levels = rev(c( "cohesion: neighbors know each other well", "cohesion: some know each other well, others only by sight","cohesion: neighbors know each other only by sight" )))
df_long$enbh_acquaintances <- factor(df_long$enbh_acquaintances, levels = rev(c("acquaintances: no one", "acquaintances: one person", "acquaintances: multiple")))
df_long$enbh_comp_educ <- factor(df_long$enbh_comp_educ, levels = rev(c("education: a quarter (25%)", "education: half (50%)","education: three quarters (75%)")))
df_long$enbh_comp_age <- factor(df_long$enbh_comp_age, levels = rev(c("age: a quarter (25%)","age: just under half (40%)","age: half (50%)")))
df_long$enbh_comp_eth <- factor(df_long$enbh_comp_eth, levels = rev(c("migration: none (0%)", "migration: minority (10%)", "migration: a quarter (25%)")))
}
df_long <- df_long %>%
select(
everything(),
# remove redundant columns,
# retain only the repeated choice tasks needed for bias correction
# and the block_order
-which(startsWith(names(.), "xs") & !(names(.) %in% c("xs23a165", "xs23a169", "xs23a191", "xs23a195", "xs23a026")))
) %>%
rename(
first_org_choice = xs23a165,
rep_org_choice = xs23a169,
first_nbh_choice = xs23a191,
rep_nbh_choice = xs23a195,
block_order = xs23a026
)
fsave(df_long, "conjoint_liss.Rda")
Copyright © Rob Franken / Kasimir Dederichs / Dingeman Wiertz / Jochem Tolsma