packages <- c( "tidyverse", "readxl", "xlsx", "haven", "labelled", "tidyr", "knitr", "kableExtra", "dplyr", "openxlsx")
installed <- packages %in% rownames(installed.packages())
if (any(!installed)) install.packages(packages[!installed])Climate Change Worries
This page guides you through the harmonisation process of the Climate Change Worries item.
The item was administered in ESS 2016 and EB 2002. Before we start harmonising, please download these data sets from the respective repositories. You can find links to the survey repositories on the Make It Green! data documentation page, in the section devoted to Climate Change Worries. If you click on the single year, the link takes you to the specific data set. We are working with the .sav format. So please make sure to download the datasets in this format.
Set-up
Please download the statistical software R (R Core Team, 2024) and RStudio (RStudio Team, 2023). Then start a project in RStudio by clicking File > New Project and set up a new directory or assign your project to an existing directory (i.e., folder). Within the project directory, create a folder called “data”. Now save the downloaded ESS and EB survey data into this “data” folder. Lastly, please download the following packages using the install.packages() function if they have not been before.
Every package installed in R must also be loaded. This is what the library-function is for.
library(tidyverse)
library(readxl)
library(openxlsx) # If you have problems installing or loading the xlsx-package, use the openxlsx.
library(haven)
library(labelled)
library(tidyr)
library(knitr)
library(kableExtra)
library(dplyr)An important step during the harmonisation process is to prepare the source data sets in a consistent and systematic way. For that, the functions “codebook” (create_codebook_short()) and ”crosswalk table” (create_cwt()) by Kołczyńska (2022) are used. They show the correspondence between source data sets and harmonised data regarding variable names and values. These functions are adopted into our needs, and the R file containing them can be downloaded here . Please save this file in the R project folder and import it into the R project via source("kolczynska2022_i4ng.R").
If you can not download the R-file and if it is opened in a new tab, please open a new file in your R-Studio project under File -> New File -> R Script and copy the text from the kolczynska2022-file into this new file. Make sure that you save this new file in your project folder under the name “kolczynska2022_i4ng.R”.
source("kolczynska2022_i4ng.R")Now we can name our target variable as “g_cc_worr”. The name is a combination of “g” representing the main topic “green”, the concept “Climate Change” and the variable label “Climate Change Worries”.
target_var_hrms <- "g_cc_worr"Before we can harmonise any data, we need to prepare the source data sets:
1. Prepare Data: EB 2002
Six steps must be carried out in the following coding section:
1.1 Import data
eb <- haven::read_sav("data/ZA3692_v1-0-1.sav", user_na=TRUE)Use this output to compare it with your output. Check especially if the labels match.
attr(eb$v568, "label")[1] "Q39 ENVIRONM PROBL: CLIMATE CHANGE"
eb %>% count(v568)# A tibble: 5 × 2
v568 n
<dbl+lbl> <int>
1 1 [Very worried] 6115
2 2 [Fairly worried] 7534
3 3 [Not very worried] 2705
4 4 [Not at all worried] 461
5 5 (NA) [DK] 226
1.2. Create codebook
Not just the substantive variables but also protocol variables need to be selected from this data set. Protocol variables selected for this harmonisation are the source data’s country, weight, and ID variables. In this step, we create a codebook that provides an overview of the selected variables and their naming in the harmonised data.
codebook_eb <- create_codebook_short(eb) %>%
mutate(survey = "EB",
target_var = ifelse(var_source == "isocntry", "country_source", NA),
target_var = ifelse(var_source == "v11", "w2_poststr", target_var),
target_var = ifelse(grepl("RESPONDENT ID|identi", var_label_source), "caseID_source", target_var),
target_var = ifelse(grepl("Q39 ENVIRONM PROBL: CLIMATE CHANGE", var_label_source),
target_var_hrms,
target_var),
target_var = gsub(" ", "_", target_var),
target_var = tolower(target_var))codebook_eb includes the columns called: var_source, var_label_source, survey, target_var. The variable names which will be used in the harmonised data are listed under target_var.
| var_source | var_label_source | survey | target_var |
|---|---|---|---|
| isocntry | NATION - ALL SAMPLES ISO 3166 (CROSSTABULATION VARIABLE) | EB | country_source |
| v11 | WEIGHT SPECIAL GERMANY | EB | w2_poststr |
| v568 | Q39 ENVIRONM PROBL: CLIMATE CHANGE | EB | g_cc_worr |
| v788 | ORIGINAL RESPONDENT ID | EB | caseid_source |
1.3. Retrieve names of the chosen source variables
variables <- codebook_eb %>% drop_na(target_var) %>% pull(var_source)The retrieved variables are: isocntry, v11, v568, v788.
1.4. Select a subset of the survey data containing only the chosen variables
eb_small <- eb %>% select(all_of(variables)) %>% mutate(caseid = row_number())You will see that the following data set is a subset of the EB 2002 with the chosen variables for the harmonised data. The first six rows of the dataset are as follows:
| isocntry | v11 | v568 | v788 | caseid |
|---|---|---|---|---|
| BE | 0.9370 | 2 | 1000001 | 1 |
| BE | 1.0399 | 2 | 1001003 | 2 |
| BE | 1.0399 | 2 | 1001003 | 3 |
| BE | 1.0071 | 2 | 1001004 | 4 |
| BE | 1.1645 | 1 | 1001005 | 5 |
| BE | 1.1133 | 3 | 1001006 | 6 |
1.5. Create a crosswalk table for the chosen variables
A crosswalk table provides a connection between the source variable values and the target variable values. First, it provides the variables, their labels, and the possible values. Then, the information is linked with the codebook information of the newly specified target variables. Lastly, target values are defined in a variable called target_value.
Here, weight and ID variables are excluded from the crosswalk table. Original codes for the country variable are preserved. For the substantive variable, the response scales of the EB and ESS items are reversed. Considering the big picture of Make it Green! items, we decided to adjust the EB response scale. Lastly, NAs are assigned to missing values.
eb_cwt <- create_cwt(eb_small %>% select(all_of(variables))) %>% filter(!grepl("WEIGHT|ID", var_label_source)) %>%
left_join(codebook_eb, by=join_by(var_source, var_label_source)) %>%
mutate(value_code = as.character(value_code),
target_value = case_when(target_var == target_var_hrms & !grepl("know|efusal|answer|NA|applicable| DK|Can't choose|Na", value_label_source)
~ plyr::mapvalues(value_code, c("1", "2", "3", "4"), # original one
c("4", "3", "2", "1")), # reversed one
target_var == target_var_hrms & grepl("know|efusal|answer|NA|applicable| DK|Can't choose|Na", value_label_source) ~ NA,
TRUE ~ as.character(value_code))
)There are decisions about the substantive variable made by taking into account both EB and ESS data. The utility of creating a crosswalk table is that the results of these decisions can be seen explicitly by comparing the value_code and target_value columns:
Definitions of missing values differ across EB and ESS. Missing values are not harmonised but recoded into the single missing value “NA”.
Response scales of the EB and the ESS items point in different directions. The EB response scale is adjusted at this step.
Let’s look at the correspondence between g_cc_worr and v568:
eb_cwt %>% filter(var_source == "v568") %>%
kable(row.names = FALSE) %>%
kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))| var_source | var_label_source | npos | value_n | value_label_source | value_code | survey | target_var | target_value |
|---|---|---|---|---|---|---|---|---|
| v568 | Q39 ENVIRONM PROBL: CLIMATE CHANGE | 1 | [1] Very worried: 6115 | [1] Very worried | 1 | EB | g_cc_worr | 4 |
| v568 | Q39 ENVIRONM PROBL: CLIMATE CHANGE | 2 | [2] Fairly worried: 7534 | [2] Fairly worried | 2 | EB | g_cc_worr | 3 |
| v568 | Q39 ENVIRONM PROBL: CLIMATE CHANGE | 3 | [3] Not very worried: 2705 | [3] Not very worried | 3 | EB | g_cc_worr | 2 |
| v568 | Q39 ENVIRONM PROBL: CLIMATE CHANGE | 4 | [4] Not at all worried: 461 | [4] Not at all worried | 4 | EB | g_cc_worr | 1 |
| v568 | Q39 ENVIRONM PROBL: CLIMATE CHANGE | 5 | [5] DK: 226 | [5] DK | 5 | EB | g_cc_worr | NA |
It might be useful to export the crosswalk table as a spreadsheet since it serves as a reference document that visualises the connection between the source and harmonised data set.
write.xlsx(eb_cwt, paste("data/", target_var_hrms, "_cwt_eb.xlsx", sep = ''))
1.6. Recode survey data using the crosswalk table
To be able to merge survey data with the crosswalk table information, we first need to convert the wide data format to a long data format.
eb_small_long <- eb_small %>%
mutate(across(everything(), as.character)) %>%
pivot_longer(cols = c(v568, isocntry),
names_to = "var_source", values_to = "value_source")This is how the first six rows of the eb_small_long should look like:
| v11 | v788 | caseid | var_source | value_source |
|---|---|---|---|---|
| 0.937 | 1000001 | 1 | v568 | 2 |
| 0.937 | 1000001 | 1 | isocntry | BE |
| 1.0399 | 1001003 | 2 | v568 | 2 |
| 1.0399 | 1001003 | 2 | isocntry | BE |
| 1.0399 | 1001003 | 3 | v568 | 2 |
| 1.0399 | 1001003 | 3 | isocntry | BE |
Now we use left_join() to recode source values according to the crosswalk table, eb_cwt.
eb_hrmsd <- eb_small_long %>%
mutate(value_source = as.character(value_source)) %>%
left_join(eb_cwt, by = c("value_source" = "value_code", "var_source")) %>%
select(-c(npos, value_n)) %>%
mutate(target_value = as.character(target_value)) %>%
pivot_wider(
id_cols =c( v11, v788, caseid, survey), # Columns to keep as unique identifiers*
names_from = target_var, # Column that will become the new column names
values_from = target_value # Column containing the values for those new columns
) %>% pivot_longer(
cols = all_of(target_var_hrms),
names_to = "target_var", values_to = "target_value") %>%
rename(caseID_source = v788)Now, EB data is ready for harmonisation. This is how the first six rows of the eb_hrmsd should look like:
| v11 | caseID_source | caseid | survey | country_source | target_var | target_value |
|---|---|---|---|---|---|---|
| 0.937 | 1000001 | 1 | EB | BE | g_cc_worr | 3 |
| 1.0399 | 1001003 | 2 | EB | BE | g_cc_worr | 3 |
| 1.0399 | 1001003 | 3 | EB | BE | g_cc_worr | 3 |
| 1.0071 | 1001004 | 4 | EB | BE | g_cc_worr | 3 |
| 1.1645 | 1001005 | 5 | EB | BE | g_cc_worr | 4 |
| 1.1133 | 1001006 | 6 | EB | BE | g_cc_worr | 2 |
At this step, the prepared data can be exported as an Rdata file and saved for later re-use.
saveRDS(eb_hrmsd, paste("data/", target_var_hrms, "_eb.rds", sep = ''))
2. Prepare Data: ESS2016
We will follow the same steps used for the EB 2002 item. As expected, ESS and EB data have differences, and they are taken into account in implementing these steps.
2.1. Import data
ess <- haven::read_sav("data/ESS8e02_3.sav", user_na=TRUE)Use this output to compare it with your output. Check especially if the labels match.
attr(ess$wrclmch, "label")[1] "How worried about climate change"
ess %>% count(wrclmch)# A tibble: 9 × 2
wrclmch n
<dbl+lbl> <int>
1 1 [Not at all worried] 2590
2 2 [Not very worried] 8493
3 3 [Somewhat worried] 19729
4 4 [Very worried] 9649
5 5 [Extremely worried] 2193
6 6 (NA) [Not applicable] 1317
7 7 (NA) [Refusal] 29
8 8 (NA) [Don't know] 364
9 9 (NA) [No answer] 23
2.2. Create codebook
Protocol variables selected for this harmonisation are the source data’s country, weight, and ID variables. Note that there are two weight variables: design and post-stratification weights. Both of them are included.
codebook_ess <- create_codebook_short(ess) %>%
mutate(survey = "ESS",
target_var = ifelse(var_source == "cntry", "country_source", NA),
target_var = ifelse(var_source == "dweight", "w1_design", target_var),
target_var = ifelse(var_source == "pspwght", "w2_poststr", target_var),
target_var = ifelse(grepl("RESPONDENT ID|identi", var_label_source), "caseID_source", target_var),
target_var = ifelse(grepl("worried about climate change", var_label_source),
target_var_hrms,
target_var),
target_var = gsub(" ", "_", target_var),
target_var = tolower(target_var))The variable names which will be used in the harmonised data are listed under target_var. The same names are used except for the weight variables because there are two weight variables.
| var_source | var_label_source | survey | target_var |
|---|---|---|---|
| idno | Respondent's identification number | ESS | caseid_source |
| cntry | Country | ESS | country_source |
| dweight | Design weight | ESS | w1_design |
| pspwght | Post-stratification weight including design weight | ESS | w2_poststr |
| wrclmch | How worried about climate change | ESS | g_cc_worr |
2.3. Retrieve names of the chosen source variables
variables <- codebook_ess %>% drop_na(target_var) %>% pull(var_source)The retrieved variables are: idno, cntry, dweight, pspwght, wrclmch.
2.4. Select a subset of the survey data containing only the chosen variables
ess_small <- ess %>% select(all_of(variables)) %>% mutate(caseid = row_number())You will see that the following data set is a subset of the ESS 2016 with the chosen variables for the harmonised data. The first six rows of the dataset are as follows:
| idno | cntry | dweight | pspwght | wrclmch | caseid |
|---|---|---|---|---|---|
| 1 | AT | 0.6116771 | 1.1784955 | 4 | 1 |
| 2 | AT | 1.2233541 | 0.8994715 | 4 | 2 |
| 4 | AT | 0.3890577 | 0.3157533 | 4 | 3 |
| 6 | AT | 0.6425940 | 0.4724674 | 3 | 4 |
| 10 | AT | 3.4324021 | 2.2467055 | 4 | 5 |
| 11 | AT | 1.1805793 | 1.0113790 | 3 | 6 |
2.5. Create a crosswalk table for the chosen variables
Similar to what was implemented in step 1.5, weight and ID variables are excluded from the crosswalk table. Only country and the substantive variable are used for creating the crosswalk table. Original codes for the country variable are preserved. For the substantive variable, “NA” is assigned to missing values; the other values are kept identical.
ess_cwt <- create_cwt(ess_small %>% select(cntry, wrclmch)) %>%
left_join(codebook_ess, by = join_by(var_source, var_label_source)) %>%
mutate(target_value = NA,
target_value = ifelse(!grepl("know|efusal|answer|NA|applicable|Can't choose|]DK|Na", value_label_source),
value_code,
target_value),
value_code = as.character(value_code)
)The ESS item has multiple definitions for missing values, and the EB item has only one. Because of this difference in missing values, they are recoded into the single missing value “NA”.
Let’s look at the correspondence between g_cc_worr and wrclmch:
ess_cwt %>% filter(var_source == "wrclmch") %>%
kable(row.names = FALSE) %>%
kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))| var_source | var_label_source | npos | value_n | value_label_source | value_code | survey | target_var | target_value |
|---|---|---|---|---|---|---|---|---|
| wrclmch | How worried about climate change | 1 | [1] Not at all worried: 2590 | [1] Not at all worried | 1 | ESS | g_cc_worr | 1 |
| wrclmch | How worried about climate change | 2 | [2] Not very worried: 8493 | [2] Not very worried | 2 | ESS | g_cc_worr | 2 |
| wrclmch | How worried about climate change | 3 | [3] Somewhat worried: 19729 | [3] Somewhat worried | 3 | ESS | g_cc_worr | 3 |
| wrclmch | How worried about climate change | 4 | [4] Very worried: 9649 | [4] Very worried | 4 | ESS | g_cc_worr | 4 |
| wrclmch | How worried about climate change | 5 | [5] Extremely worried: 2193 | [5] Extremely worried | 5 | ESS | g_cc_worr | 5 |
| wrclmch | How worried about climate change | 6 | [6] Not applicable: 1317 | [6] Not applicable | 6 | ESS | g_cc_worr | NA |
| wrclmch | How worried about climate change | 7 | [7] Refusal: 29 | [7] Refusal | 7 | ESS | g_cc_worr | NA |
| wrclmch | How worried about climate change | 8 | [8] Don't know: 364 | [8] Don't know | 8 | ESS | g_cc_worr | NA |
| wrclmch | How worried about climate change | 9 | [9] No answer: 23 | [9] No answer | 9 | ESS | g_cc_worr | NA |
It might be useful to export the crosswalk table as a spreadsheet since it serves as a reference document that visualises the connection between the source and harmonised data set.
write.xlsx(ess_cwt, paste("data/", target_var_hrms, "_cwt_ess.xlsx", sep = ''))
2.6. Recode survey data using the crosswalk table
We first convert the wide data format to a long data format, and then merge survey data with the crosswalk table information.
ess_small_long <- ess_small %>%
mutate(across(everything(), as.character)) %>%
pivot_longer(cols = c(wrclmch, cntry),
names_to = "var_source", values_to = "value_source")This is how the first six rows of the ess_small_long should look like:
| idno | dweight | pspwght | caseid | var_source | value_source |
|---|---|---|---|---|---|
| 1 | 0.611677050590515 | 1.17849552631378 | 1 | wrclmch | 4 |
| 1 | 0.611677050590515 | 1.17849552631378 | 1 | cntry | AT |
| 2 | 1.22335410118103 | 0.899471521377563 | 2 | wrclmch | 4 |
| 2 | 1.22335410118103 | 0.899471521377563 | 2 | cntry | AT |
| 4 | 0.389057725667953 | 0.31575334072113 | 3 | wrclmch | 4 |
| 4 | 0.389057725667953 | 0.31575334072113 | 3 | cntry | AT |
Now we use left_join() to recode source values according to the crosswalk table, ess_cwt.
ess_hrmsd <- ess_small_long %>%
left_join(ess_cwt, by = c("value_source" = "value_code", "var_source")) %>%
select(-c(npos, value_n)) %>%
mutate(target_value = as.character(target_value)) %>%
pivot_wider(
id_cols = c(idno, dweight, pspwght, caseid, survey), # Columns to keep as unique identifiers
names_from = target_var, # Column that will become the new column names
values_from = target_value # Column containing the values for those new columns
) %>% pivot_longer(
cols = all_of(target_var_hrms),
names_to = "target_var", values_to = "target_value") %>%
rename(caseID_source = idno)ESS data is ready for harmonisation. This is how the first six rows of the ess_hrmsd should look like:
head(ess_hrmsd) %>%
kable(row.names = FALSE) %>%
kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))| caseID_source | dweight | pspwght | caseid | survey | country_source | target_var | target_value |
|---|---|---|---|---|---|---|---|
| 1 | 0.611677050590515 | 1.17849552631378 | 1 | ESS | AT | g_cc_worr | 4 |
| 2 | 1.22335410118103 | 0.899471521377563 | 2 | ESS | AT | g_cc_worr | 4 |
| 4 | 0.389057725667953 | 0.31575334072113 | 3 | ESS | AT | g_cc_worr | 4 |
| 6 | 0.64259397983551 | 0.472467392683029 | 4 | ESS | AT | g_cc_worr | 3 |
| 10 | 3.43240213394165 | 2.24670553207397 | 5 | ESS | AT | g_cc_worr | 4 |
| 11 | 1.18057930469513 | 1.01137900352478 | 6 | ESS | AT | g_cc_worr | 3 |
At this step, the prepared data can be exported as an Rdata file and saved for later re-use.
saveRDS(ess_hrmsd, paste("data/", target_var_hrms, "_ess.rds", sep = ''))
3. Harmonisation
Linear stretch (de Jonge et al., 2014) or identity linking is used to harmonise items. Kolen & Brennan (2014) and Albano (2016) provide extensive information about identity linking as well as other methodological approaches. Interested users are encouraged to consult these sources for further details.
With the following steps, we will create the harmonised Climate Change Worries data.
3.1. Standardise country names & apply labels
There are functions specifically written to standardise country names and apply labels. Please download the R file containing these functions here . Then save this file in the R project folder and import it into the R project via source("func_recoded_country.R").
If you cannot download the R-file, please open a new file in your R-Studio project under File -> New File -> R Script and copy the text from the func_recoded_country-file into this new file. Make sure that you save this new file in your project folder under the name “func_recoded_country.R”.
source("func_recoded_country.R")
eb_1 <- eb_hrmsd %>%
mutate(year = "2002") %>%
recoded_country("country_source") %>%
country_new_labels("country_new") %>%
func_country_sample("country_source") %>%
country_source_recoded_labels("country_source_recoded")
ess_1 <- ess_hrmsd %>%
mutate(year = "2016") %>%
recoded_country("country_source") %>%
country_new_labels("country_new") %>%
func_country_sample("country_source") %>%
country_source_recoded_labels("country_source_recoded")
# in ESS GB refers to UK: in all ESS waves GB_GBN needs to be recoded to GB_UK for country_new and country_recoded
ess_1$country_new[ess_1$country_new == "GB_GBN"] <- "GB_UK"
ess_1$country_source_recoded[ess_1$country_source_recoded == "GB_GBN"] <- "GB_UK"You can run the following code to check the country variable:
table(eb_hrmsd$country_source, eb_1$country_new)
table(ess_hrmsd$country_source, ess_1$country_new)
3.2. Weights
For details on decisions and procedures for including weight variables, please see the Make It Green! data documentation page, section Weight Variables.
eb_fnl <- eb_1 %>% mutate(w1_design = v11,
w2_poststr = v11,
w3_combined = as.numeric(w2_poststr))
ess_fnl <- ess_1 %>% mutate(w1_design =dweight,
w2_poststr = pspwght,
w3_combined = as.numeric(w2_poststr))3.3. Import additional information about the source data sets
This file, including additional information, can be downloaded here . Please save it into the “data” folder you generated previously.
add_data <- read_excel("data/from_doi_links_green.xlsx") %>% select(-studyno_source)
3.4. Combine all data
commons <- c("caseID_source", "caseid", "survey",
"target_var","target_value","year", "country_new", "country_source_recoded",
"w1_design", "w2_poststr", "w3_combined")
all_comb <- bind_rows(ess_fnl[, commons],
eb_fnl[, commons]) %>%
left_join(add_data, by = c("target_var", "survey","year")) %>%
mutate(
caseID_I4NG = paste(survey, year, country_new, caseid, sep = ''),
#country_year
country_year = paste(country_new, year, sep = '_'),
# caseID = NA,
caseID = row_number(),
# code the lengths of response scales in each project
npoints = case_when( survey == "ESS" ~ 5, survey == "EB" ~ 4, TRUE ~ NA_real_)
) %>%
rename(caseid_sw = caseid, country_I4NG = country_new) Let’s check the data set:
head(all_comb) %>%
kable(row.names = FALSE) %>%
kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))| caseID_source | caseid_sw | survey | target_var | target_value | year | country_I4NG | country_source_recoded | w1_design | w2_poststr | w3_combined | title_source | wave | doi_source | caseID_I4NG | country_year | caseID | npoints |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | ESS | g_cc_worr | 4 | 2016 | AT | AT | 0.611677050590515 | 1.17849552631378 | 1.1784955 | Welfare & climate change attitudes | 8 | https://doi.org/10.21338/ess8e02_3 | ESS2016AT1 | AT_2016 | 1 | 5 |
| 2 | 2 | ESS | g_cc_worr | 4 | 2016 | AT | AT | 1.22335410118103 | 0.899471521377563 | 0.8994715 | Welfare & climate change attitudes | 8 | https://doi.org/10.21338/ess8e02_3 | ESS2016AT2 | AT_2016 | 2 | 5 |
| 4 | 3 | ESS | g_cc_worr | 4 | 2016 | AT | AT | 0.389057725667953 | 0.31575334072113 | 0.3157533 | Welfare & climate change attitudes | 8 | https://doi.org/10.21338/ess8e02_3 | ESS2016AT3 | AT_2016 | 3 | 5 |
| 6 | 4 | ESS | g_cc_worr | 3 | 2016 | AT | AT | 0.64259397983551 | 0.472467392683029 | 0.4724674 | Welfare & climate change attitudes | 8 | https://doi.org/10.21338/ess8e02_3 | ESS2016AT4 | AT_2016 | 4 | 5 |
| 10 | 5 | ESS | g_cc_worr | 4 | 2016 | AT | AT | 3.43240213394165 | 2.24670553207397 | 2.2467055 | Welfare & climate change attitudes | 8 | https://doi.org/10.21338/ess8e02_3 | ESS2016AT5 | AT_2016 | 5 | 5 |
| 11 | 6 | ESS | g_cc_worr | 3 | 2016 | AT | AT | 1.18057930469513 | 1.01137900352478 | 1.0113790 | Welfare & climate change attitudes | 8 | https://doi.org/10.21338/ess8e02_3 | ESS2016AT6 | AT_2016 | 6 | 5 |
distinct(all_comb, target_var, survey, year)# A tibble: 2 × 3
target_var survey year
<chr> <chr> <chr>
1 g_cc_worr ESS 2016
2 g_cc_worr EB 2002
3.5. Find equivalents of the response categories
transformation <- function(x, x_min, x_max, y_min, y_max){
# x: source scale
# y: target scale
y = ((x - x_min)/(x_max - x_min))*(y_max-y_min) + y_min
return(y)
}
# source scale
scale_source <- c(1:4)
# Transform the 4-point source scale to the 5-point target scale
scale_target <- transformation(x = scale_source, x_min = 1, x_max = 4, y_min = 1, y_max = 5)Equivalents of 1, 2, 3, 4 on the target scale are 1, 2.33, 3.67, 5. In the following step, EB item scores are recoded according to the correspondence between the source scale and the target scale.
3.6. Apply transformation
all_hrmsd <- all_comb %>%
# apply transformation
mutate(value_hrmsd = case_when(!(npoints == 5) ~ plyr::mapvalues(target_value,
scale_source,
scale_target),
TRUE ~ target_value)) %>%
# style and format
rename(var_hrmsd = target_var) %>%
select(-var_hrmsd, -value_hrmsd, var_hrmsd, value_hrmsd, -caseID, caseID,
-ends_with("_source"), ends_with("_source"), -target_value, -npoints) %>%
pivot_wider(
id_cols = c(doi_source, title_source, caseID_source, caseid_sw, survey, country_I4NG, country_source_recoded, year, country_year,
w1_design, w2_poststr, caseID_I4NG),
names_from = var_hrmsd, # Column that will become the new column names
values_from = value_hrmsd # Column containing the values for those new columns
) Now the harmonised Climate Change Worries data are ready. This is how the first six rows of the all_hrmsd should look like:
| doi_source | title_source | caseID_source | caseid_sw | survey | country_I4NG | country_source_recoded | year | country_year | w1_design | w2_poststr | caseID_I4NG | g_cc_worr |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| https://doi.org/10.21338/ess8e02_3 | Welfare & climate change attitudes | 1 | 1 | ESS | AT | AT | 2016 | AT_2016 | 0.611677050590515 | 1.17849552631378 | ESS2016AT1 | 4 |
| https://doi.org/10.21338/ess8e02_3 | Welfare & climate change attitudes | 2 | 2 | ESS | AT | AT | 2016 | AT_2016 | 1.22335410118103 | 0.899471521377563 | ESS2016AT2 | 4 |
| https://doi.org/10.21338/ess8e02_3 | Welfare & climate change attitudes | 4 | 3 | ESS | AT | AT | 2016 | AT_2016 | 0.389057725667953 | 0.31575334072113 | ESS2016AT3 | 4 |
| https://doi.org/10.21338/ess8e02_3 | Welfare & climate change attitudes | 6 | 4 | ESS | AT | AT | 2016 | AT_2016 | 0.64259397983551 | 0.472467392683029 | ESS2016AT4 | 3 |
| https://doi.org/10.21338/ess8e02_3 | Welfare & climate change attitudes | 10 | 5 | ESS | AT | AT | 2016 | AT_2016 | 3.43240213394165 | 2.24670553207397 | ESS2016AT5 | 4 |
| https://doi.org/10.21338/ess8e02_3 | Welfare & climate change attitudes | 11 | 6 | ESS | AT | AT | 2016 | AT_2016 | 1.18057930469513 | 1.01137900352478 | ESS2016AT6 | 3 |
3.7. Export data
# Rdata
saveRDS(all_hrmsd, paste("data/", target_var_hrms, "_hrmsd.rds", sep = ''))
# SPSS file
write_sav(all_hrmsd, paste("data/", target_var_hrms, "_hrmsd.sav", sep = ''))
# STATA file
write_dta(all_hrmsd, paste("data/", target_var_hrms, "_hrmsd.dta", sep = ''))
# CSV file
write.csv(all_hrmsd, paste("data/", target_var_hrms, "_hrmsd.csv", sep = ''), row.names = F, quote = T)
Summary
Climate Change Worries was administered in ESS 2016 and EB 2002. Our script, first, prepares these two data sets for harmonisation so that they are consistent in format via codebooks and crosswalk tables. Then, the response categories are harmonised using the identity linking/linear stretch approach. After this step, the item is ready for subsequent analysis!
To go back to the Make it Green! Toolbox page, please click here!