<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/building-the-data-matrix-for-the-task-at-hand-and-analyzing-jointly-the-resulting-rows-and-columns/"></div></div><div><a data-url="http://www.r-bloggers.com/building-the-data-matrix-for-the-task-at-hand-and-analyzing-jointly-the-resulting-rows-and-columns/" data-counturl="http://www.r-bloggers.com/building-the-data-matrix-for-the-task-at-hand-and-analyzing-jointly-the-resulting-rows-and-columns/" data-count="horizontal" data-text="Building the Data Matrix for the Task at Hand and Analyzing Jointly the Resulting Rows and Columns" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://joelcadwell.blogspot.com/2016/06/building-data-matrix-for-task-at-hand.html"> Engaging Market Research</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<div></div>
<p>Someone decided what data ought to go into the matrix. They placed the objects of interest in the rows and the features that differentiate among those objects into the columns. Decisions were made either to collect information or to store what was gathered for other purposes (e.g., data mining).</p>
<div><a target="_blank" href="https://2.bp.blogspot.com/-3aG2eQxH1aE/V1Gw5yOtdwI/AAAAAAAAAaE/DmbdTtmZTI8NNhKAidWJe8ioALR2r4wawCLcB/s1600/beer.jpg"><img height="360" width="640" src="https://2.bp.blogspot.com/-3aG2eQxH1aE/V1Gw5yOtdwI/AAAAAAAAAaE/DmbdTtmZTI8NNhKAidWJe8ioALR2r4wawCLcB/s640/beer.jpg" border="0"></a></div>
<p>A set of mutually constraining choices determines what counts as an object and a feature. For example, in the above figure, the beer display case in the convenience store contains a broad assortment of brands in both bottles and cans grouped together by volume and case sizes. The features varying among these beers are the factors that consumers consider when making purchases for specific consumption situations: beers to bring on an outing, beers to have available at home for self and guests, and beers to serve at a casual or formal party.</p>
<p>These beers and their associated attributes would probably not have made it into a taste test at a local brewery. Craft beers come with their own set of distinguishing features: spicy, herbal, sweet and burnt (see the data set called beer.tasting.notes in the <a target="_blank" href="https://cran.r-project.org/web/packages/ExPosition/index.html">ExPosition R package</a>). Yet, preference still depends on consumption occasion for a craft beer needs to be paired with food and desires vary by time of day and ongoing activities and who is drinking with you. What gets measured and how it is measured depends on the situation and the accompanying reasons for data collection (the task at hand).</p>
<p>It should be noted that data matrix construction may evolve over time and may change with context. Rows and columns are added and deleted in order to maintain a type of synchronization with one beer suggesting the inclusion of other beers in the consideration set and at the same time inserting new columns into the data matrix in order to differentiate among the additional beers.</p>
<p>Given such mutual dependencies, why would we want to perform separate analyses of the rows (e.g., cluster analysis) and the columns (e.g., factor analysis), as if row (column) relationships were invariant regardless of the columns (rows)? That is, the similarity of the rows in a cluster analysis depends on the variables populating the columns, and the correlations among the variables are calculated as shared covariation over the rows. The correlation between two variables changes with the individuals sampled (e.g., restriction of range), and the similarity between two observations fluctuates with the basis of comparison (e.g., features included in the object representation). Given the shared determination of what gets included as the rows and the columns of our data matrix, why wouldn’t we turn to a joint scaling procedure such as correspondence analysis (when the cells are counts) or biplots (when the cells are ratings or other continuous measures)?</p>
<p>We can look at such a joint scaling using that beer.tasting.notes data set mentioned earlier in this post. Some 38 craft beers were rated on 16 different flavor profiles. Although the ExPosition R package contains functions that will produce a biplot, I will run the analysis with FactoMineR because it may be more familiar and <a target="_blank" href="http://joelcadwell.blogspot.com/2014/07/using-biplots-to-map-cluster-solutions.html">I have written about this R package previously</a>. The biplot below could have been shown in a single graph, but it might have been somewhat crowded with 38 beers and 16 ratings on the same page. Instead, by default, FactoMineR plots the rows on the Individuals factor map and the columns on the Variables factor map. Both plots come from a single principal component analysis with rows as points and columns as arrows. The result is a vector map with directional interpretation, so that points (beers) have perpendicular projections onto arrows (flavors) that reproduce as closely as possible the beer’s rating on the flavor variable.</p>
<div><a target="_blank" href="https://3.bp.blogspot.com/-UiGvHccyov0/V1HFciwcoXI/AAAAAAAAAaU/jDTlREQxg3UeHgTTsKGB8f9ZuqQVa-RfgCLcB/s1600/craft%2Bbeers.jpg"><img src="https://3.bp.blogspot.com/-UiGvHccyov0/V1HFciwcoXI/AAAAAAAAAaU/jDTlREQxg3UeHgTTsKGB8f9ZuqQVa-RfgCLcB/s1600/craft%2Bbeers.jpg" border="0"></a></div>
<p>
<div><a target="_blank" href="https://2.bp.blogspot.com/-KPszwdgkajs/V1HFi5Rx1xI/AAAAAAAAAac/30V9lmVRnPIn2iAGAnbD0EfKMFCkAG2qgCLcB/s1600/craft%2Bbeer%2Battributes.jpg"><img src="https://2.bp.blogspot.com/-KPszwdgkajs/V1HFi5Rx1xI/AAAAAAAAAac/30V9lmVRnPIn2iAGAnbD0EfKMFCkAG2qgCLcB/s1600/craft%2Bbeer%2Battributes.jpg" border="0"></a></div>
<p>Beer tasting provides a valuable illustration of the process by which we build the data matrix for the task at hand. Beer drinkers are not as likely as those drinking wine to discuss the nuances of taste so that you might not know the referents for some of these flavor attributes. As a child, you learned which citrus fruits are bitter and sweet: lemons and oranges. <a target="_blank" href="https://www.utdallas.edu/~herve/abdi-dcav2015_Beer.pdf">How would you become a beer expert?</a> You would need to participate in a supervised learning experience with beer tastings and flavor labels. For instance, you must taste a sweet and a bitter beer and be told which is which in order to learn the first dimension of sweet vs. bitter as shown in the above biplot.</p>
<p>Obviously, I cannot serve you beer over the Internet, but here is a <a target="_blank" href="http://www.beeradvocate.com/beer/profile/345/42546/">description of Wild Devil</a>, a beer positioned on the Individuals Factor Map in the direction pointed to by the labels Bitter, Spicy and Astringent on the Variables Factor Map.<br>
<blockquote><span>It’s arguable that our menacingly delicious HopDevil has always been wild. With bold German malts and whole flower American hops, this India Pale Ale is anything but prim. But add a touch of brettanomyces, the unruly beast responsible for the sharp tang and deep funk found in many Belgian ales, and our WildDevil emerges completely untamed. Floral, aromatic hops still leap from this amber ale, as a host of new fermentation flavor kicks up notes of citrus and pine.</span></blockquote>
<p>Hopefully, you can see how the descriptors in our columns acquire their meaning through an understanding of how beers are brewed. It is an acquired taste with the acquisition made easier by knowledge of the manufacturing process. What beers should be included as rows? We will need to sample all those variations in the production process that create flavor differences. The result is a relatively long feature list. Constraints are needed and supplied by the task at hand. Thankfully, the local brewery has a limited selection, as shown in the very first figure, so that all we need are ratings that will separate the five beers in tasting tray.</p>
<p>In this case the data matrix contains ratings, which seem to be the averages of two researchers. Had there been many respondents using a checklist, we could have kept counts and created a similar joint map with correspondence analysis. I showed how this might be done in <a target="_blank" href="http://joelcadwell.blogspot.com/2014/06/the-unavoidable-instability-of-brand.html">an earlier post mapping the European car market</a>. That analysis demonstrated how the Prius has altered market perceptions. Specifically, Prius has come to be so closely associated with the attributes Green and Environmentally Friendly that our perceptual map required a third dimension anchored by Prius pulling together Economical with Green and Environmental. In retrospect, had the Prius <u>not</u> been included in the set of objects being rated, would we have included Green and Environmentally Friendly in the attribute list?</p>
<p>Now, we can return to our convenience store with a new appreciation of the need to analyze jointly the rows and the columns of our data matrix. After all, this is what consumers do when they form consideration sets and attend only to the differentiating features for this smaller number of purchase alternatives. <a target="_blank" href="http://joelcadwell.blogspot.com/2014/09/attention-is-preference-foundation.html">Human attention enables us to find the cooler in the convenience store and then ignore most of the stuff in that cooler</a>. Preference learning involves knowing how to build the data matrix for the task at hand and thus simplifying the process by focusing only on the most relevant combination of objects and features.</p>
<p>Finally, I have one last caution. There is no reason to insist on homogeneity over all the cells of our data matrix. In the post referenced in the last paragraph, <a target="_blank" href="http://joelcadwell.blogspot.com/2014/09/attention-is-preference-foundation.html">Attention is Preference</a>, I used nonnegative matrix factorization (NMF) to jointly partition the rows and columns of the cosmetics market into subspaces of differing familiarity with brands (e.g., brands that might be sold in upscale boutiques or department stores versus more downscale drug stores). You should not be confused because the rows are consumers and not objects such as car models and beers. The same principles apply whenever goes in the rows. The question is whether all the rows and columns can be represented in a single common space or whether the data matrix is better described as a number of subspaces where blocks of rows and columns have higher density with sparsity across the rest of the cells. Here are these attributes that separate these beers, and there are those attributes that separate those beers (e.g., the twist-off versus pry-off cap tradeoff applies only to beer in bottles).</p>
<p><b>R Code to Run the Analysis:</b>
<div>
<div>
<pre><span># ExPosition must be installed</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/library"><span>library</span></a><span>(</span>ExPosition<span>)</span><br> <br><span># load data set and examine its structure</span><br><a target="_blank" href="http://inside-r.org/r-doc/utils/data"><span>data</span></a><span>(</span><span>&quot;beer.tasting.notes&quot;</span><span>)</span><br><a target="_blank" href="http://inside-r.org/r-doc/utils/str"><span>str</span></a><span>(</span>beer.tasting.notes<span>)</span><br><a target="_blank" href="http://inside-r.org/r-doc/utils/head"><span>head</span></a><span>(</span>beer.tasting.notes$data<span>)</span><br> <br><span># how ExPosition runs the biplot</span><br>pca.beer &lt;- epPCA<span>(</span>beer.tasting.notes$data<span>)</span><br> <br><span># FactoMiner must be installed</span><br><a target="_blank" href="http://inside-r.org/r-doc/base/library"><span>library</span></a><span>(</span><a target="_blank" href="http://inside-r.org/packages/cran/FactoMineR">FactoMineR</a><span>)</span><br> <br><span># how FactoMineR runs the biplot</span><br>fm.beer&lt;-PCA<span>(</span>beer.tasting.notes$data<span>)</span></pre>
</div>
</div>
<p><a title="Created by Pretty R at inside-R.org" target="_blank" href="http://www.inside-r.org/pretty-r">Created by Pretty R at inside-R.org</a></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/building-the-data-matrix-for-the-task-at-hand-and-analyzing-jointly-the-resulting-rows-and-columns/"></div></div><div><a data-url="http://www.r-bloggers.com/building-the-data-matrix-for-the-task-at-hand-and-analyzing-jointly-the-resulting-rows-and-columns/" data-counturl="http://www.r-bloggers.com/building-the-data-matrix-for-the-task-at-hand-and-analyzing-jointly-the-resulting-rows-and-columns/" data-count="vertical" data-text="Building the Data Matrix for the Task at Hand and Analyzing Jointly the Resulting Rows and Columns" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://joelcadwell.blogspot.com/2016/06/building-data-matrix-for-task-at-hand.html"> Engaging Market Research</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://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="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/_A9UInHIu9M"></a></div>