<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/how-to-create-a-max-diff-experimental-design-in-r/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.displayr.com/create-max-diff-experimental-design-r/"> R – Displayr</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img sizes="(max-width: 300px) 100vw, 300px" alt="Max Diff design output" class="webfeedsFeaturedVisual wp-post-image" src="https://i1.wp.com/www.displayr.com/wp-content/uploads/2017/05/max_diff_large-300x185.png?resize=300%2C185&ssl=1" data-recalc-dims="1">
<p><img sizes="(max-width: 780px) 100vw, 780px" alt="Max diff design table" class="wp-image-1631" src="https://i0.wp.com/www.displayr.com/wp-content/uploads/2017/05/max.diff-1.png?w=450&ssl=1" data-recalc-dims="1"></p>
<p>Creating the experimental design for a max-diff experiment is easy in R. This post describes how to create and check a max-diff experimental design. If you are not sure what this is, it would be best to read <a target="_blank" rel="nofollow" href="https://www.displayr.com/a-beginners-guide-to-max-diff/">A beginner’s guide to max-diff</a> first.</p>
<p> </p>
<hr>
<p> </p>
<h1><span>Step 1: Installing the packages</span></h1>
<p>The first step is to install the <span>flipMaxDiff </span>package and a series of dependent packages. Depending on how your R has been setup, you may need to install none of these (e.g., if using Displayr), or even more packages than are shown below.</p>
<pre> 
install.packages(&quot;devtools&quot;)
library(devtools)
install.packages(&quot;AlgDesign&quot;) 
install_github(&quot;Displayr/flipData&quot;)
install_github(&quot;Displayr/flipTransformations&quot;)
install.packages(&quot;Rcpp&quot;)
install_github(&quot;Displayr/flipMaxDiff&quot;)
</pre>
<hr>
<pre>
</pre>
<h1><span>Step 2: Creating the design</span></h1>
<p>The <span>MaxDiffDesign</span> function is a wrapper for the <span>optBlock</span> function in the wonderful <span>AlgDesign</span> package. The following snippet can be used to create a design. The arguments used in the code snippet here are described immediately below.</p>
<pre> 
library(flipMaxDiff)
MaxDiffDesign(number.alternatives = 10, 
              alternatives.per.question = 5, 
              number.questions = 6, 
              n.repeats = 1)
</pre>
<ul>
<li><span>number.alternatives:</span> The total number of alternatives considered in the study. In <a target="_blank" rel="nofollow" href="https://www.displayr.com/a-beginners-guide-to-max-diff/">my technology study</a>, for example, I had 10 brands, so I enter the number of alternatives as 10.</li>
<li><span>alternatives.per.question</span>: The number of alternatives shown to the respondents in each individual task. I tend to set this at 5. Where I have studies where the alternatives are wordy, I like to reduce this to 4. Where the alternatives are really easy to understand, I have used 6.  The key trade-off here is cognitive difficulty for the respondent. The harder the questions, the more likely people are to not consider them very carefully.</li>
<li><span>number.questions</span>: The number of questions (i.e., tasks or sets) to present to respondents. A rule of thumb provided by the good folks at Sawtooth Software states the ideal number of questions:<span> 3 * number.alternatives/</span><span>alternatives.per.question</span>. This would suggest that in the technology study, I should have used 3 * 10 / 5 = 6 questions, which is indeed the number that I used in the study. There are two conflicting factors to trade off when setting the number of questions. The more questions, the more respondent fatigue, and the worse your data becomes. The fewer questions, the less data, and the harder it is to work out the relative appeal of alternatives that have a similar level of overall appeal. I return to this topic in the discussion of checking designs, below.</li>
<li><span>n.repeats</span>: The algorithm includes a randomization component. Occasionally, this can lead to poor designs being found (how to check for this is described below). Sometimes this problem can be remedied by increasing <span>n.repeats</span>.</li>
</ul>
<hr>
<p> </p>
<h1><span>Step 3: Interpreting the design</span></h1>
<p>The design is called the <span>binary.design</span>. Each row represents a question. Each column shows which alternatives are to be shown. Thus, in the first question, the respondent evaluates alternatives 1, 3, 5, 6, and 10. More complicated designs can have additional information (this is discussed below)</p>
<p><img sizes="(max-width: 563px) 100vw, 563px" alt="" class="wp-image-1702" src="https://i1.wp.com/www.displayr.com/wp-content/uploads/2017/05/binarydesign.png?w=450&ssl=1" data-recalc-dims="1"></p>
<p>I tend to add one additional complication to my max-diff studies. I get the data collection to involve randomization of the order of the alternatives between respondents. One and only one respondent had brands shown in this order: Apple, Google Samsung, Sony, Microsoft, Intel, Dell, Nokia, IBM, and Yahoo. So, whenever Apple appeared it was at the top, whenever Google appeared, it was below Apple if Apple appeared, but at the top otherwise, etc. The next respondent had the brands in a different order, and so on.</p>
<p>If doing randomization like this, I strongly advise having this randomization done in the data collection software.  You can then undo it when creating the data file, enabling you to conduct the analysis as if no randomization ever occurred.</p>
<p>There are many other ways of complicating designs, such as to deal with large numbers of alternatives, and to prevent certain pairs of alternatives appearing together. <a target="_blank" rel="nofollow" href="http://docs.displayr.com/wiki/Creating_Max-Diff_Experimental_Designs">Click here</a> for more information about this.</p>
<p> </p>
<hr>
<p> </p>
<h1><span>Step 4: Checking the design</span></h1>
<p>In an ideal world, a max-diff experimental design has the following characteristics, where each alternative appears:</p>
<ol>
<li>At least 3 times.</li>
<li>The same number of times.</li>
<li>With each other alternative the same number of times (e.g., each alternative appears with each other alternative twice).</li>
</ol>
<p>Due to a combination of maths and a desire to avoid respondent fatigue, few max-diff experimental designs satisfy these three requirements (the last one is particularly tough).</p>
<p>Above, I described a design with 10 alternatives, 5 alternatives per question, and 6 questions. Below, I show the outputs where I have changed of alternatives per question from 5 to 4. This small change has made a good design awful. How can we see it is awful? The first thing to note is that 6 warnings are shown at the bottom.</p>
<p><img sizes="(max-width: 897px) 100vw, 897px" alt="" class="wp-image-1704" src="https://i0.wp.com/www.displayr.com/wp-content/uploads/2017/05/BadDesignA.png?w=450&ssl=1" data-recalc-dims="1"></p>
<p><img sizes="(max-width: 913px) 100vw, 913px" alt="" class="wp-image-1705" src="https://i0.wp.com/www.displayr.com/wp-content/uploads/2017/05/BadDesignB.png?w=450&ssl=1" data-recalc-dims="1"></p>
<p> </p>
<p>The first warning is telling us that we have ignored the advice about how to compute the number of questions, and we should instead have at least 8 questions. (Or, more alternatives per question.)</p>
<p>The second warning is telling us that we have an alternative that only appears two times, whereas good practice is that we should have each alternative appearing three times.</p>
<p>The third alternative tells us that some alternatives appear more regularly than others. Looking at the <span>frequencies</span> output, we can see that options appeared either 2 or 3 times. Why does this matter? It means we have collected more information about some of the alternatives than others, so may end up with different levels of precision of our estimates of the appeal of different alternatives.</p>
<p>The fourth warning is a bit cryptic. To understand it we need to look at the <em>binary correlations</em>, which are reproduced below. This <em>correlation matrix </em>shows the correlations between each of the columns of the experimental design (i.e., <span>binary.design</span> shown above). Looking at row 4 and column 8 we see a big problem. Alternative 4 and 8 are perfectly negatively correlated. That is, whenever alternative 4 appears in the design alternative 8 does not appear, and whenever 8 appears, 4 does not appear. One of the cool things about max-diff is that it can sometimes still work even with such a flaw in the experimental design. It would, however, be foolhardy to rely on this. The basic purpose of max-diff is to work out relative preferences between alternatives, and its ability to do this is clearly compromised if some alternatives are never shown with others.</p>
<p> </p>
<p><iframe width="450" src="https://embedded.azureedge.net/75668/211124/b1f12836-a438-48cd-9c36-1d0abd1d72fc.html?v=34784-768893128"></iframe></p>
<p> </p>
<p>The 5th warning tells us that there is a large range in the correlations. In most experimental designs, the ideal design results in a correlation of 0 between all the variables. Max-Diff designs differ from this, as, on average, there will always be a negative correlation between the variables. However, the basic idea is the same: we strive for designs where the correlations are close to 0 as possible. Correlations in the range of -0.5 and 0.5 should, in my opinion, cause no concern.</p>
<p>The last warning tells us that some alternatives never appear together.  We already deduced this from the binary correlations.</p>
<p>The first thing to do when you have a poor design is to increase the setting for <span>n.repeats</span>. Start by setting it to 10. Then, if you have patience, try 100, and then bigger numbers. This only occasionally works. But, when it does work it is a good outcome. If this does not work, you need to change something else. Reducing the number of alternatives and/or increasing the number of questions are usually the best places to start.</p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://www.displayr.com/create-max-diff-experimental-design-r/"> R – Displayr</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/Tlpg-0jwteU"></a></div>