Displayr can analyze MaxDiff variables from Qualtrics, but depending on how they have been set up, you will likely have to reformat them first.
For example, let us suppose you have respondents choose which company they like the most (best) and which the least (worst) from several alternative lists of companies.
- Displayr's version of MaxDiff analysis requires separate Best and Worst variables for each question or task, and that the alternative labels (company names) are the category options.
- Typically this is programmed in Qualtrics (and similar platforms) as a series of matrix questions with piped alternatives, whereby the variables are by company name for each question or task, and the category labels represent the Best or Worst selections.
Requirements
A data set with MaxDiff variable sets where the alternatives are the variables and the Best and Worst selections are the category labels, as per the above example.
Method
Part 1 – Tidy the data
This just makes things easier later on. Let's say you have 6 MaxDiff variable sets, Q14 to Q19, which represent each question or iteration of the MaxDiff survey question.
- In the Data Sets tree, select Q14
- In the Object Inspector, select Properties > GENERAL > Label and change the label to MD1
- Repeat steps 1 and 2 for each of Q15 to Q19.
The result should end up looking like this:
Part 2 – Add the Design
If you have an external design, you can paste this into your document using Table > Paste or Enter Table. Otherwise you can use R code to create a design based on your data. In this example, we will do the latter.
- Select Anything > Calculation > Custom Code and click anywhere on the page.
-
Click on your page where you wish to have this Calculation inserted, and drag to create a box for the output.
-
Enter a name under GENERAL > Name. In this example, we will change the name to design.
-
Enter your R code in the object inspector under Properties > R CODE. For example:
n.questions = 6
questions = list(MD1, MD2, MD3, MD4, MD5, MD6)
question.attributes = lapply(questions, colnames)
alts.per.question = length(question.attributes[[1]])
attributes = unique(unlist(question.attributes))
design = matrix(NA, nrow = n.questions, ncol = alts.per.question + 2)
colnames(design) = c("Version", "Question", paste0("Option.", 1:alts.per.question))
design[, "Version"] = rep(1, nrow(design))
design[, "Question"] = 1:n.questions
for (q in 1:n.questions) {
for (a in 1:alts.per.question) {
design[q, a+2] = which(attributes == question.attributes[[q]][a])
}
}
design
Note, the first line should be updated to reflect the number of MaxDiff questions, and the second line should refer to all your MaxDiff variable sets by name.
Part 3 – Create the best/worst variables
- Click the plus sign
when you hover over any variable in the Data Sets tree
- From the Insert Variable(s) menu, select Custom Code > Multiple R Variables > Numeric to create a Numeric - Multi variable set.
- Type the number of variables you want to create in the How Many Variables Do You Want to Create? box. In this example, we will create 12 new variables (6 best variables and 6 worst variables)
- Click OK
Each of the variables in this variable set shares the same R template code, that is used to create empty variables. - The next step is to update the template code with the following R code
- In the Data Set tree, click on Variable 1 in the New R Variable Set. The current code will be in the object inspector > Properties >R CODE box.
- Insert the following code on line 17, just before line of code that says new.data
Note, you will need to make the following edits to the code:
- Update the first line to reflect the number of MaxDiff questions in the design
- On the fourth line, list out the names of all of your MaxDiff variable sets.
- Update the sixth and seventh lines with the labels of the best and worst categories in your MaxDiff variable sets.
#Update with the number of MaxDiff questions
n.questions = 6
#Update with the names of the MaxDiff variable sets
questions = list(MD1, MD2, MD3, MD4, MD5, MD6)
#Update with the labels of the best and worst categories in the MaxDiff variable sets
best.label = "Most important"
worst.label = "Least important"
question.attributes = lapply(questions, colnames)
alts.per.question = length(question.attributes[[1]])
attributes = unique(unlist(question.attributes))
get.best.worst = function (question, attributes, best.label = best.label, worst.label = worst.label) {
option.selected.in.row = function (v) {
option = v[v != "FALSE"]
if (length(option) == 0) {
return(NA)
} else {
return(option)
}
}
q = question
q.labels = matrix(colnames(q), nrow = nrow(q), ncol = ncol(q), byrow = TRUE)
q.best = q == best.label & !is.na(q)
q.best[q.best] = q.labels[q.best]
q.best = apply(q.best, 1, option.selected.in.row)
q.worst = q == worst.label & !is.na(q)
q.worst[q.worst] = q.labels[q.worst]
q.worst = apply(q.worst, 1, option.selected.in.row)
q.best = factor(q.best, levels = attributes)
q.worst = factor(q.worst, levels = attributes)
best.worst = data.frame(q.best, q.worst)
}
get.best.worst(MD1, attributes = attributes)
x = lapply(questions, FUN = get.best.worst, attributes = attributes)
x = do.call(cbind, x)
colnames(x) = paste0(colnames(x), rep(1:n.questions, each = 2))
new.data = x - The Data Sets tree should now look like this:
- Click on New R Variable Set in the Data Sets tree
- In the Object Inspector, change the structure to Nominal - Multi Grid with unordered categories
The results are as follows: - Drag the new variable set onto the page
The questions are now ready to be analyzed in Displayr.
Next
How to Create a MaxDiff Experimental Design
How to Do MaxDiff Latent Class Analysis
How to Use Hierarchical Bayes for MaxDiff
How to Import Data from Qualtrics
Comments
0 comments
Article is closed for comments.