Skip to main content

FV Kinesis Support

All the topics, resources needed for FV Kinesis.

 
FocusVision Knowledge Base

MaxDiff Example

This section provides information on how to program a Maxdiff choice model in Kinesis Survey. Scroll down for a Custom HTML example that can assist with the formatting.

NOTE: This example will not fit all MaxDiff exercises, but can typically be modified for other variations.

MaxDiff requires the programmer to pool several attributes or items, and randomly display a subset of these items multiple times, so that all available items are randomly shown over all iterations. The respondents are asked to select the Most and Least Favorable for each subset. Typically, these attributes or items are assigned a maximum number of displays before they are removed from later iterations.

In this example, we have 15 attributes/items, and will randomly display 5 rotated rows of attributes. We may only ever show each attribute/item TWICE. Before each table, we will use a hidden checkbox with 15 conditional rows - one for each possible item. The checkbox questions are where the bulk of the MaxDiff programming is done. To begin, we randomly select five items to display in the first table. We'll call this datapoint QMDIFF1.

# first, we create an array for our 15 items and shuffle them
$USER_rand = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
shuffle($USER_rand);
# next, we take the first five items in this array, since we need 5 at a time
$USER_five = array_slice($USER_rand,0,5);
# return the 5 random selections
return $USER_five;

For QMDIFF1, this is all you'll need - you will now show five conditional rows in a table based on the answers generated. Now it will be a bit more complicated in the next iteration, QMDIFF2, because we need to determine what we've already shown in QMDIFF1.

# create the initial list of items
$USER_rand = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
# We have no selected items, yet
$USER_selection = array();
# We need 5 items to be selected
$USER_needed = 5;

# create a list of all the previously selected items
$USER_selected = array_keys($QMDIFF1,1);

# count how many times each item was previously selected
$USER_array_count = array_count_values($USER_selected);

# create a list of all the items that have been selected twice (there won't be any yet, this is only the second iteration)
$USER_invalid_items = array_keys($USER_array_count,2);

# remove the items that have been selected twice from the initial list of all the items
$USER_new_items = array_diff($USER_rand,$USER_invalid_items);

# rotate remaining items
shuffle($USER_new_items);

# select 5 (needed items) of the remaining items for return
$USER_selection = array_slice($USER_new_items,0,$USER_needed);

# return the selection
return $USER_selection;

Now we are at a point where it's possible we've exhausted our two display maximum for one or more items. In QMDIFF3, we need to check both previous QMDIFFs and exclude any that were shown twice, we may begin removing items from our list.

# create the initial list of items
$USER_rand = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
# We have no selected items, yet
$USER_selection = array();
# We need 5 items to be selected
$USER_needed = 5;

# create a list of all the previously selected items, including QMDIFF1 AND QMDIFF2
$USER_selected = array_merge(array_keys($QMDIFF1,1),array_keys($QMDIFF2,1));

# count how many times each item was previously selected
$USER_array_count = array_count_values($USER_selected);

# create a list of all the items that have been selected twice - we can NOT use these anymore!
$USER_invalid_items = array_keys($USER_array_count,2);

# remove the items that have been selected twice from the initial list of all the items
$USER_new_items = array_diff($USER_rand,$USER_invalid_items);

# rotate remaining items
shuffle($USER_new_items);

# select 5 (needed items) of the remaining items for return
$USER_selection = array_slice($USER_new_items,0,$USER_needed);

# return the selection
return $USER_selection;

.. and repeat this process for as many iterations as you have, adding the prior selections (QMDIFF1, QMDIFF2, etc.) to your array in the process. Each table will only show 5 rows, and those 5 rows will be dictated by IF conditions created with the above. Note that you MUST have enough available items to display across the iterations provided by your client - typically the number of iterations requested by your client will be the number of possible items multipled by the maximum number of displays divided by visible rows, e.g. in the above example, respondents will see 6 iterations of 5 rows each before exhausting their combinations.

Using Custom HTML

Custom HTML ranges are frequently used to design MaxDiff questions, as they provide significantly more control over the table formatting.

VIEW DEMO

  1. Start by creating two radio questions for each assignment (for this demo "most important" and "least important" are the question text used for each radio with your attributes for a single max diff exercise as your answer options on both questions).
  2. From the survey editor, select the two questions and click the custom HTML range icon from the side toolbar.
  3. Use the demo HTML template below to build your custom table.
  • The table cells that contain text such as <input name="Qmost" type="radio" value="1"> are the radio buttons for each question. Make sure the "name" reflects the qlabel being used and that the "value" corresponds to that choices punch value (or choice id).
  • Notice that CSS classes are used to style the table, do not change or remove these. These will automatically format the table to match the style used by regular matrix tables according to the applied survey theme.
  • Also notice that the table rows comprised of the radio buttons and choice text alternate classes "tablecellodd" and "tablecelleven". If additional options are included make sure the cell classes alternate to stripe the rows accordingly.
  • Validation is piped in from the first question using syntax "%Qmost_ERROR%" at the beginning of the HTML. The validation used to restrict the same choice being answered in both columns is simply $Qmost==$Qleast.

Demo HTML template:

<style type="text/css">
.questiontable td {
	text-align: center;
}
</style>

%Qmost_ERROR%
<table class="questiontexttable">
<tbody>
<tr>
<td class="questiontext">Which of the following attributes was most important to you on your recent visit? <br> <br> Which of the following attributes was least important to you on your recent visit?</td>
</tr>
</tbody>
</table>
<br>
<table class="questiontable" border="0" cellspacing="1" cellpadding="2">
<thead>
<tr>
<td class="tableheading">Most Important</td>
<td class="tableheading"> </td>
<td class="tableheading">Least Important</td>
</tr>
</thead>
<tbody>
<tr>
<td class="tablecellodd"><input type="radio" name="Qmost" value="1"></td>
<td class="tablecellodd">The items I bought were on sale</td>
<td class="tablecellodd"><input type="radio" name="Qleast" value="1"></td>
</tr>
<tr>
<td class="tablecelleven"><input type="radio" name="Qmost" value="2"></td>
<td class="tablecelleven">The items I bought came with a mail-in rebate</td>
<td class="tablecelleven"><input type="radio" name="Qleast" value="2"></td>
</tr>
<tr>
<td class="tablecellodd"><input type="radio" name="Qmost" value="3"></td>
<td class="tablecellodd">The service staff was very knowledgeable</td>
<td class="tablecellodd"><input type="radio" name="Qleast" value="3"></td>
</tr>
<tr>
<td class="tablecelleven"><input type="radio" name="Qmost" value="4"></td>
<td class="tablecelleven">The service staff was very friendly</td>
<td class="tablecelleven"><input type="radio" name="Qleast" value="4"></td>
</tr>
<tr>
<td class="tablecellodd"><input type="radio" name="Qmost" value="5"></td>
<td class="tablecellodd">I found everything I was looking for</td>
<td class="tablecellodd"><input type="radio" name="Qleast" value="5"></td>
</tr>
</tbody>
</table>
<br> <br> <!-- THESE FIELDS ARE REQUIRED --> <input type="hidden" name="sessionstr" value="%SESSIONSTR%"> <input type="hidden" name="pagenum" value="%PAGENUM%"> 
<!-- CONTROL BUTTONS --> %BACK% %CONTINUE%

  • Was this article helpful?