Branching items
A branching item in an ESM survey is a type of question that presents respondents with specific propositions (case 1) or a specific follow-up set of items (case 2) based on their initial response. However, it is important to ensure that participants’ subsequent responses align with the branching structure of the survey.
Case 1: Follow-up answer choices
In our data example, in the function of the answer at the branching variable (“branching_var”) only specific choices of the following item (“branching_item”) are proposed to the participant, as follows:
Branch_var | Branch_item |
---|---|
repA | choiceA ; choiceB |
repB | choiceC ; choiceD |
Coherence (i.e., repA -> choiceC) must be checked. To this end, we can count the number of occurrences between “branching_var” and “branching_item” values:
%>%
data group_by(branch_var, branch_item) %>%
summarise(n())
# A tibble: 7 × 3
# Groups: branch_var [2]
branch_var branch_item `n()`
<chr> <chr> <int>
1 repA choiceA 600
2 repA choiceB 584
3 repA choiceD 2
4 repB choiceA 3
5 repB choiceB 6
6 repB choiceC 1531
7 repB choiceD 1474
The function highlights that occurrences of incoherent combinations of values exists (e.g., repA -> choiceC, repB -> choiceA).
Solving this issue: if there is no way to get the correct values, you might consider to handle this issue by setting the incoherent values of the incoherent conditions as missing.
# Define the incoherent combinations.
= list(c("repA", "choiceC"), c("repA", "choiceD"),
incoherent c("repB", "choiceA"), c("repB", "choiceB"))
# Whenever incoherent, set as missing the values.
for (inc in incoherent){
= data$branch_var==inc[1] & data$branch_item==inc[2] & !is.na(data$branch_var) & !is.na(data$branch_item)
condition_ "branch_var"] = NA
data[condition_, "branch_item"] = NA
data[condition_, }
Don’t forget to check that the issues have been solved using the previous R code.
Case 2: Follow-up items
In our data example, in the function of the answer at the “branching_var” only specific variables are presented to the participants, as follows:
Branch_var | Items |
---|---|
repA | ‘PA1’ |
repB | ‘PA2’ |
Again coherence (i.e., repA -> ‘PA1’, repB -> ‘PA2’) must be checked. To this end, we count the number of occurrences between non-missing values in ‘PA1’ and ‘PA2’ and the ‘branch_var’ values:
%>%
data mutate(PA1_NA= !is.na(PA1),
PA2_NA= !is.na(PA2)) %>%
group_by(branch_var, PA1_NA, PA2_NA) %>%
summarise(n())
# A tibble: 6 × 4
# Groups: branch_var, PA1_NA [4]
branch_var PA1_NA PA2_NA `n()`
<chr> <lgl> <lgl> <int>
1 repA FALSE FALSE 351
2 repA TRUE FALSE 881
3 repA TRUE TRUE 9
4 repB FALSE FALSE 903
5 repB FALSE TRUE 2049
6 repB TRUE TRUE 7
Solving this issue: one solution is to assign missing values to the follow-up items (‘PA1’, ‘PA2’) whenever an observation have non-coherent values.
$branch_var=="repA" & !is.na(data$PA2), "PA2"] = NA
data[data$branch_var=="repB" & !is.na(data$PA1), "PA1"] = NA data[data