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: 8 × 3
# Groups: branch_var [2]
branch_var branch_item `n()`
<chr> <chr> <int>
1 repA choiceA 610
2 repA choiceB 643
3 repA choiceC 1
4 repA choiceD 4
5 repB choiceA 5
6 repB choiceB 4
7 repB choiceC 1493
8 repB choiceD 1440
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.
incoherent = list(c("repA", "choiceC"), c("repA", "choiceD"),
c("repB", "choiceA"), c("repB", "choiceB"))
# Whenever incoherent, set as missing the values.
for (inc in incoherent){
condition_ = data$branch_var==inc[1] & data$branch_item==inc[2] & !is.na(data$branch_var) & !is.na(data$branch_item)
data[condition_, "branch_var"] = NA
data[condition_, "branch_item"] = NA
}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 360
2 repA TRUE FALSE 863
3 repA TRUE TRUE 4
4 repB FALSE FALSE 894
5 repB FALSE TRUE 2071
6 repB TRUE TRUE 8
Solving this issue: one solution is to assign missing values to the follow-up items (‘PA1’, ‘PA2’) whenever an observation have non-coherent values.
data[data$branch_var=="repA" & !is.na(data$PA2), "PA2"] = NA
data[data$branch_var=="repB" & !is.na(data$PA1), "PA1"] = NA