The NextGen Harmonised Data Gateway
  • Home
  • Variable Database
    • Variable Database
    • Make it Green!
    • Make it Digital!
    • Make it Equal!
    • Make it Healthy!
    • Make it Strong!
  • Harmonisation
    • Harmonisation Toolbox
    • Make it Green!
    • Make it Digital!
    • Make it Equal!
    • Make it Healthy!
    • Make it Strong!
  • Data
  • Training
  • Contact
    • User Support
    • Team

On this page

  • Set-up
  • 1. Prepare Data: ESS 2006
  • 2. Prepare Data: EQLS
  • 3. Harmonisation
  • Summary

Job Loss Concerns

This page guides you through the harmonisation process of the Job Loss Concerns item.

The item was administered in ESS 2006 and EQLS 2003, 2007, 2012 and 2016. 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 Strong! data documentation page, in the section devoted to Job Loss Concerns. 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.

install.packages()
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])

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

How-to

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 “s_ew_loss”. The name is a combination of “s” representing the main topic “strong”, the concept “Employment, Income and Work Conditions” and the variable label “Job Loss Concerns”.

target_var_hrms <- "s_ew_loss"

Before we can harmonise any data, we need to prepare the source data sets:

1. Prepare Data: ESS 2006

Six steps must be carried out in the following coding section:

1.1 Import data

ess <- haven::read_sav("data/ESS3e03_7.sav", user_na=TRUE)
Check the source item

Use this output to compare it with your output. Check especially if the labels match.

ess %>% count(uempnyr)
# A tibble: 8 × 2
  uempnyr                     n
  <dbl+lbl>               <int>
1 1 [Very likely]           933
2 2 [Likely]               2155
3 3 [Not very likely]      8613
4 4 [Not at all likely]   10445
5 6 (NA) [Not applicable] 19676
6 7 (NA) [Refusal]           25
7 8 (NA) [Don't know]      1035
8 9 (NA) [No answer]        118

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_ess <- create_codebook_short(ess) %>%
  mutate(survey = "ESS",
         target_var = ifelse(var_source == "cntry", "country_source", NA),
         target_var = ifelse(grepl("Design weight", var_label_source), "w1_design", target_var),
         target_var = ifelse(grepl("Post-stratification weight", var_label_source), "w2_poststr", target_var),
         target_var = ifelse(grepl("unified respondent number|Respondent's identification number|ID SERIAL NUMBER|RESPONDENT ID", var_label_source, perl = TRUE), "caseID_source", target_var),
         target_var = ifelse(grepl("Become unemployed in the next 12 months", var_label_source), 
                             target_var_hrms, # Find NAME FOR THE TARGET VARIABLE to be harmonised
                             target_var),
         target_var = gsub(" ", "_", target_var),
         target_var = tolower(target_var))

codebook_ess 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
idno Respondent's identification number ESS caseid_source
cntry Country ESS country_source
uempnyr Become unemployed in the next 12 months, how likely ESS s_ew_loss
dweight Design weight ESS w1_design
pspwght Post-stratification weight including design weight ESS w2_poststr

 

1.3. Retrieve names of the chosen source variables

variables <- codebook_ess %>% drop_na(target_var) %>% pull(var_source)

The retrieved variables are: idno, cntry, uempnyr, dweight, pspwght.

 

1.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 2006 with the chosen variables for the harmonised data. The first six rows of the dataset are as follows:

idno cntry uempnyr dweight pspwght caseid
3 AT 4 1.2429 0.9495779 1
6 AT 4 0.8286 1.4121802 2
8 AT 4 0.8286 0.7232761 3
9 AT 3 1.2429 0.6257437 4
11 AT 4 0.8286 0.4171625 5
12 AT 6 1.6572 3.7887211 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. Lastly, NAs are assigned to missing values.

ess_cwt <- create_cwt(ess_small %>% 
                         select(cntry, uempnyr)) %>%
  left_join(codebook_ess, by = join_by(var_source, var_label_source)) %>%
  mutate(target_value = case_when(grepl("know|efusal|answer|NA|Can't choose|]DK|] DK|Na", value_label_source) ~ NA,
                                  var_source == "uempnyr" & value_code == "6" ~ "-999",
                                  TRUE ~ value_code
                                  ),
         value_code = as.character(value_code)
  )
Important

There are decisions about the substantive variable made by taking into account both ESS and EQLS 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.

In particular, definitions of missing values differ across ESS and EQLS. Missing values are not harmonised but recoded into the single missing value “NA” except cases classified as “Not applicable”. They are assigned the value −999. The code −999 represents a distinct missing category, which is denoted as “Inap. from source data sets”. Please see ‘Further notes’ section on the documentation page of the Make it Strong! Data.

Let’s look at the correspondence between s_ew_loss and uempnyr:

ess_cwt %>% filter(var_source == "uempnyr") %>% 
  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
uempnyr Become unemployed in the next 12 months, how likely 1 [1] Very likely: 933 [1] Very likely 1 ESS s_ew_loss 1
uempnyr Become unemployed in the next 12 months, how likely 2 [2] Likely: 2155 [2] Likely 2 ESS s_ew_loss 2
uempnyr Become unemployed in the next 12 months, how likely 3 [3] Not very likely: 8613 [3] Not very likely 3 ESS s_ew_loss 3
uempnyr Become unemployed in the next 12 months, how likely 4 [4] Not at all likely: 10445 [4] Not at all likely 4 ESS s_ew_loss 4
uempnyr Become unemployed in the next 12 months, how likely 5 [6] Not applicable: 19676 [6] Not applicable 6 ESS s_ew_loss -999
uempnyr Become unemployed in the next 12 months, how likely 6 [7] Refusal: 25 [7] Refusal 7 ESS s_ew_loss NA
uempnyr Become unemployed in the next 12 months, how likely 7 [8] Don't know: 1035 [8] Don't know 8 ESS s_ew_loss NA
uempnyr Become unemployed in the next 12 months, how likely 8 [9] No answer: 118 [9] No answer 9 ESS s_ew_loss NA
Optional

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 = ''))

 

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.

ess_small_long <- ess_small %>% 
  mutate(across(everything(), as.character)) %>% 
  pivot_longer(cols = c(uempnyr, 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
3 1.24290001392365 0.949577867984772 1 uempnyr 4
3 1.24290001392365 0.949577867984772 1 cntry AT
6 0.828599989414215 1.41218018531799 2 uempnyr 4
6 0.828599989414215 1.41218018531799 2 cntry AT
8 0.828599989414215 0.723276138305664 3 uempnyr 4
8 0.828599989414215 0.723276138305664 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(dweight, pspwght, idno, 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) 

Now, ESS 2006 data is ready for harmonisation. This is how the first six rows of the ess_hrmsd should look like:

dweight pspwght caseID_source caseid survey country_source target_var target_value
1.24290001392365 0.949577867984772 3 1 ESS AT s_ew_loss 4
0.828599989414215 1.41218018531799 6 2 ESS AT s_ew_loss 4
0.828599989414215 0.723276138305664 8 3 ESS AT s_ew_loss 4
1.24290001392365 0.625743746757507 9 4 ESS AT s_ew_loss 3
0.828599989414215 0.417162477970123 11 5 ESS AT s_ew_loss 4
1.65719997882843 3.78872108459473 12 6 ESS AT s_ew_loss -999
Optional

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 = ''))

 

2. Prepare Data: EQLS

We follow the same steps used for the ESS 2006 item. The EQLS dataset contains all four waves, and the source variable is consistent across them. Therefore, the data preparation is carried out in a single step rather than in separate sections for each year. As expected, there are differences between ESS and EQLS data, which are taken into account during the implementation of these steps.

 

2.1. Import data

eqls <- haven::read_sav("data/eqls_integrated_trend_2003-2016.sav", user_na=TRUE) 

The items are asked only of respondents who reported having a job at a previous filtering question. Those not working are coded as -999 (Inap. from source data sets).

eqls <- eqls %>%
  mutate(jobloss = case_when(
    Y16_Q21 %in% 1:5 ~ Y16_Q21,
    Y16_Q21 %in% c(98, 99) ~ Y16_Q21,
    TRUE ~ -999
  ))

jobloss_label <- c(
  attr(eqls$Y16_Q21, "labels"),
  "Inap. from source data sets" = -999)


eqls$jobloss <- labelled_spss(
  eqls$jobloss,
  labels    = jobloss_label,
  na_values = c(98, 99, -999),
  label     = "Likelihood of losing job in next 6 months"
)
Check the source item

Use this output to compare it with your output. Check especially if the labels match.

eqls %>% count(jobloss)
# A tibble: 8 × 2
  jobloss                                     n
  <dbl+lbl>                               <int>
1 -999 (NA) [Inap. from source data sets] 75677
2    1 [Very likely]                       2799
3    2 [Rather likely]                     5025
4    3 [Neither likely nor unlikely]      10436
5    4 [Rather unlikely]                  16185
6    5 [Very unlikely]                    29551
7   98 (NA) [Don't know]                   2507
8   99 (NA) [Refusal]                       255

 

2.2. Create codebook

Protocol variables selected for this harmonisation are the source data’s country, weight, and ID variables.

codebook_eqls <- create_codebook_short(eqls) %>%
  mutate(survey = "EQLS",
         target_var = ifelse(var_source == "Y16_Country", "country_source", NA),
         target_var = ifelse(var_source == "WCalib", "w2_poststr", target_var),
         target_var = ifelse(grepl("unified respondent number|Respondent's identification number|respondent ID", var_label_source, perl = TRUE), "caseID_source", target_var),
         target_var = ifelse(var_source == "Wave", "year", target_var),
         target_var = ifelse(grepl("Likelihood of losing job in next 6 months", var_label_source), 
                             target_var_hrms, # Find NAME FOR THE TARGET VARIABLE to be harmonised
                             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
Y16_uniqueid Unique respondent ID EQLS caseid_source
Wave EQLS Wave EQLS year
Y16_Country Country EQLS country_source
WCalib Standardised Final Calibration weight for within country metrics and comparsions between any individual countries EQLS w2_poststr
Y16_Q21 Likelihood of losing job in next 6 months EQLS s_ew_loss
jobloss Likelihood of losing job in next 6 months EQLS s_ew_loss

 

2.3. Retrieve names of the chosen source variables

variables <- codebook_eqls %>% drop_na(target_var) %>% pull(var_source)

The retrieved variables are: Y16_uniqueid, Wave, Y16_Country, WCalib, Y16_Q21, jobloss.

 

2.4. Select a subset of the survey data containing only the chosen variables

eqls_small <- eqls %>% select(all_of(variables)) %>% 
  # filter(Wave == 1) %>% 
  mutate(caseid = row_number()) 

You will see that the following data set is a subset of the EQLS with the chosen variables for the harmonised data. The first six rows of the dataset are as follows:

Y16_uniqueid Wave Y16_Country WCalib Y16_Q21 jobloss caseid
AT8000101 1 1 0.424712 NA -999 1
AT8000105 1 1 0.534066 5 5 2
AT8000109 1 1 1.043511 NA -999 3
AT8000111 1 1 0.221848 5 5 4
AT8000115 1 1 0.443695 5 5 5
AT8000117 1 1 0.409498 5 5 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.

eqls_cwt <- create_cwt(eqls_small %>%
                          select(Y16_Country, jobloss)) %>%
  left_join(codebook_eqls, 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|] DK|Na", value_label_source), #* CHECK
                               value_code, 
                               target_value),
         value_code = as.character(value_code)
  )
Important

The survey-specific missing values are recoded into the single missing value “NA”.

Let’s look at the correspondence between s_ew_loss and jobloss:

eqls_cwt %>% filter(var_source == "jobloss") %>%
  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
jobloss Likelihood of losing job in next 6 months 1 [1] Very likely: 2799 [1] Very likely 1 EQLS s_ew_loss 1
jobloss Likelihood of losing job in next 6 months 2 [2] Rather likely: 5025 [2] Rather likely 2 EQLS s_ew_loss 2
jobloss Likelihood of losing job in next 6 months 3 [3] Neither likely nor unlikely: 10436 [3] Neither likely nor unlikely 3 EQLS s_ew_loss 3
jobloss Likelihood of losing job in next 6 months 4 [4] Rather unlikely: 16185 [4] Rather unlikely 4 EQLS s_ew_loss 4
jobloss Likelihood of losing job in next 6 months 5 [5] Very unlikely: 29551 [5] Very unlikely 5 EQLS s_ew_loss 5
jobloss Likelihood of losing job in next 6 months 6 [98] Don't know: 2507 [98] Don't know 98 EQLS s_ew_loss NA
jobloss Likelihood of losing job in next 6 months 7 [99] Refusal: 255 [99] Refusal 99 EQLS s_ew_loss NA
jobloss Likelihood of losing job in next 6 months 8 [-999] Inap. from source data sets: 75677 [-999] Inap. from source data sets -999 EQLS s_ew_loss -999
Optional

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(eqls_cwt, paste("data/",  target_var_hrms, "_cwt_eqls.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.

eqls_small_long <- eqls_small %>%
  mutate(across(everything(), as.character)) %>%
  pivot_longer(cols = c(jobloss, Y16_Country),
               names_to = "var_source", values_to = "value_source")

This is how the first six rows of the eqls_small_long should look like:

Y16_uniqueid Wave WCalib Y16_Q21 caseid var_source value_source
AT8000101 1 0.424712 NA 1 jobloss -999
AT8000101 1 0.424712 NA 1 Y16_Country 1
AT8000105 1 0.534066 5 2 jobloss 5
AT8000105 1 0.534066 5 2 Y16_Country 1
AT8000109 1 1.043511 NA 3 jobloss -999
AT8000109 1 1.043511 NA 3 Y16_Country 1

Now we use left_join() to recode source values according to the crosswalk table, eqls_cwt.

eqls_hrmsd <- eqls_small_long %>%
  left_join(eqls_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(Y16_uniqueid, WCalib, ends_with("wt"), caseid, survey, Wave),    # 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 = Y16_uniqueid)

EQLS 2003 data is ready for harmonisation. This is how the first six rows of the eqls_hrmsd should look like:

head(eqls_hrmsd) %>%
  kable(row.names = FALSE) %>%
  kable_styling(full_width = FALSE, bootstrap_options = c("striped", "hover"))
caseID_source WCalib caseid survey Wave country_source target_var target_value
AT8000101 0.424712 1 EQLS 1 1 s_ew_loss -999
AT8000105 0.534066 2 EQLS 1 1 s_ew_loss 5
AT8000109 1.043511 3 EQLS 1 1 s_ew_loss -999
AT8000111 0.221848 4 EQLS 1 1 s_ew_loss 5
AT8000115 0.443695 5 EQLS 1 1 s_ew_loss 5
AT8000117 0.409498 6 EQLS 1 1 s_ew_loss 5
Optional

At this step, the prepared data can be exported as an Rdata file and saved for later re-use.

saveRDS(eqls_hrmsd, paste("data/",  target_var_hrms, "_eqls.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 Job Loss Concerns 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").

How-to

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")
ess_1 <- ess_hrmsd %>% 
  recoded_country("country_source") %>%
  country_new_labels("country_new") %>%
  func_country_sample("country_source") %>%
  country_source_recoded_labels("country_source_recoded")

eqls_1 <- eqls_hrmsd %>% 
  recoded_country("country_source") %>%
  country_new_labels("country_new") %>%
  func_country_sample("country_source") %>%
  country_source_recoded_labels("country_source_recoded")
Check

You can run the following code to check the country variable:

table(eqls_hrmsd$country_source, eqls_1$country_new)

 

3.2. Weights

For details on decisions and procedures for including weight variables, please see the Make It Strong! data documentation page, section Weight Variables.

ess_fnl <- ess_1 %>% mutate(w1_design = dweight,
                            w2_poststr = pspwght, 
                            w3_combined = as.numeric(w2_poststr))

eqls_fnl <- eqls_1 %>% mutate(w1_design = WCalib,
                              w2_poststr = WCalib,
                              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_strong.xlsx") %>%  
  select(-studyno_source, -wave)

 

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

ess_fnl$year <- "2006"
eqls_fnl <- eqls_fnl %>% mutate(year = case_when(Wave == 1 ~ "2003", Wave == 2 ~ "2007", Wave == 3 ~ "2012", Wave == 4 ~ "2016")
                                    )

all_comb <- bind_rows(eqls_fnl[, commons], 
                      ess_fnl[, commons]
                      
) %>%
   left_join(add_data, by = c("target_var", "survey", "year")) %>%
  mutate(
    ## variables To Be Added
    studyno_I4NG = NA,
    version_I4NG = NA,
    doi_I4NG = NA,
    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 = NA 
  ) %>%
  # Rename to avoid SPSS duplicate name error
  rename(caseid_sw = caseid) 
Check

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_new country_source_recoded w1_design w2_poststr w3_combined title_source doi_source studyno_I4NG version_I4NG doi_I4NG caseID_I4NG country_year caseID npoints
AT8000101 1 EQLS s_ew_loss -999 2003 AT AT 0.424712 0.424712 0.424712 Integrated file https://doi.org/10.5255/UKDA-SN-5260-1 NA NA NA EQLS2003AT1 AT_2003 1 NA
AT8000105 2 EQLS s_ew_loss 5 2003 AT AT 0.534066 0.534066 0.534066 Integrated file https://doi.org/10.5255/UKDA-SN-5260-1 NA NA NA EQLS2003AT2 AT_2003 2 NA
AT8000109 3 EQLS s_ew_loss -999 2003 AT AT 1.043511 1.043511 1.043511 Integrated file https://doi.org/10.5255/UKDA-SN-5260-1 NA NA NA EQLS2003AT3 AT_2003 3 NA
AT8000111 4 EQLS s_ew_loss 5 2003 AT AT 0.221848 0.221848 0.221848 Integrated file https://doi.org/10.5255/UKDA-SN-5260-1 NA NA NA EQLS2003AT4 AT_2003 4 NA
AT8000115 5 EQLS s_ew_loss 5 2003 AT AT 0.443695 0.443695 0.443695 Integrated file https://doi.org/10.5255/UKDA-SN-5260-1 NA NA NA EQLS2003AT5 AT_2003 5 NA
AT8000117 6 EQLS s_ew_loss 5 2003 AT AT 0.409498 0.409498 0.409498 Integrated file https://doi.org/10.5255/UKDA-SN-5260-1 NA NA NA EQLS2003AT6 AT_2003 6 NA
distinct(all_comb, target_var, survey, year)
# A tibble: 5 × 3
  target_var survey year 
  <chr>      <chr>  <chr>
1 s_ew_loss  EQLS   2003 
2 s_ew_loss  EQLS   2007 
3 s_ew_loss  EQLS   2012 
4 s_ew_loss  EQLS   2016 
5 s_ew_loss  ESS    2006 

 

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))
[1] 1 2 3 4
# Transform the source scale to the target scale
scale_target <- transformation(x = scale_source, x_min = 1, x_max = 4, y_min = 1, y_max = 5)
scale_target
[1] 1.000000 2.333333 3.666667 5.000000

Equivalents of 1, 2, 3, 4 on the target scale are 1, 2.33, 3.67, 5. In the following step, ESS item scores are recoded according to this correspondence between the source scale and the target scale.

 

3.6. Apply transformation

all_hrmsd <- all_comb %>%
  mutate(
    value_hrmsd = case_when(
      survey == "ESS" & year == "2006" ~ plyr::mapvalues(target_value, scale_source, scale_target),
      TRUE ~ target_value)) %>%
  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) %>% rename(country_I4NG = country_new)%>% 
  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, w3_combined, 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 Job Loss Concerns 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 w3_combined caseID_I4NG s_ew_loss
https://doi.org/10.5255/UKDA-SN-5260-1 Integrated file AT8000101 1 EQLS AT AT 2003 AT_2003 0.424712 0.424712 0.424712 EQLS2003AT1 -999
https://doi.org/10.5255/UKDA-SN-5260-1 Integrated file AT8000105 2 EQLS AT AT 2003 AT_2003 0.534066 0.534066 0.534066 EQLS2003AT2 5
https://doi.org/10.5255/UKDA-SN-5260-1 Integrated file AT8000109 3 EQLS AT AT 2003 AT_2003 1.043511 1.043511 1.043511 EQLS2003AT3 -999
https://doi.org/10.5255/UKDA-SN-5260-1 Integrated file AT8000111 4 EQLS AT AT 2003 AT_2003 0.221848 0.221848 0.221848 EQLS2003AT4 5
https://doi.org/10.5255/UKDA-SN-5260-1 Integrated file AT8000115 5 EQLS AT AT 2003 AT_2003 0.443695 0.443695 0.443695 EQLS2003AT5 5
https://doi.org/10.5255/UKDA-SN-5260-1 Integrated file AT8000117 6 EQLS AT AT 2003 AT_2003 0.409498 0.409498 0.409498 EQLS2003AT6 5

 

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

Job Loss Concerns was administered in ESS 2006 and EQLS 2003, 2007, 2012 and 2016. Our script, first, prepares these five 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 Strong! Toolbox page, please click here!

Back to top

References

Albano, A. D. (2016). equate: An R package for observed-score linking and equating. Journal of Statistical Software, 74(8), 1–36. https://doi.org/10.18637/jss.v074.i08
de Jonge, T., Veenhoven, R., & Arends, L. (2014). Homogenizing responses to different survey questions on the same topic: Proposal of a scale homogenization method using a reference distribution. Social Indicators Research, 117, 375–300. https://doi.org/10.1007/s11205-013-0335-6
Kołczyńska, M. (2022). Combining multiple survey sources: A reproducible workflow and toolbox for survey data harmonization. Methodological Innovations, 15(1), 62–72. https://doi.org/10.1177/20597991221077923
Kolen, M. J., & Brennan, R. L. (2014). Test equating, scaling, and linking. Springer. https://doi.org/10.1007/978-1-4939-0317-7
R Core Team. (2024). R: A language and environment for statistical computing. R Foundation for Statistical Computing. https://www.R-project.org/
RStudio Team. (2023). RStudio: Integrated development environment for R. https://www.rstudio.com/

© EU Funded Project 101131118 — Infra4NextGen

 

Subject to Terms of Use | Privacy notice | Cookie policy | Built with R and Quarto