Pages

Monday, August 25, 2014

Continuous or Discrete Latent Structure? Correspondence Analysis vs. Nonnegative Matrix Factorization

A map gives us the big picture, which is why mapping has become so important in marketing research. What is the perceptual structure underlying the European automotive market? All we need is a contingency table with cars as the rows, attributes as the columns, and the cells as counts of the number of times each attribute is associated with each feature. As shown in a previous post, correspondence analysis (CA) will produce maps like the following.


Although everything you need to know about this graphic display can be found in that prior post, I do wish to emphasize a few points. First, the representation is a two-dimensional continuous space with coordinates for each row and each column. Second, the rows (cars) are positioned so that the distance between any two rows indicates the similarity of their relative attribute perceptions (i.e., different cars may score uniformly higher or lower, but they have the same pattern of strengths and weaknesses). Correspondingly, the columns (attributes) are located closer to each other when they are used similarly to describe the automobiles. Distances between the rows and columns are not directly shown on this map, yet the cross-tabulation from the original post shows that autos are near the attributes on which they performed the best. The analysis was conducted with the R package anacor, however, the ca r package might provide a gentler introduction to CA especially when paired with Greenacre's online tutorial.

CA yields a continuous representation. The first dimension separates economy from luxury vehicles, and the second dimension differentiates between the smaller and the larger cars. Still, one can identify regions or clusters within this continuous space. For example, one could easily group the family cars in the third quadrant. Such an interpretation is consistent with the R package from which the dataset was borrowed (e.g., Slide #6). A probabilistic latent feature model (plfm) assumes that the underlying structure is defined by binary features that are hidden or unobserved.

What is in the mind of our raters? Do they see the vehicles as possessing more or less of the two dimensions from the CA, or are their perceptions driven by a set of on-off features (e.g., small popular, sporty status, spacious family, quality luxury, green, and city car)? If the answer is a latent category structure, then the success of CA stems from its ability to reproduce the row and column profiles from a dimensional representation even when the data were generated from the perceived presence or absence of latent features. Alternatively, the seemingly latent features may well be nothing more than an uneven distribution of rows and columns across the continuous space. We have the appearance of discontinuity simply because there are empty spaces that could be filled by adding more objects and features.

Spoiler alert: An adaptive consumer improvises and adopts whenever representational system works in that context. Dimensional maps provide the overview of the terrain and seem to be employed whenever many objects and/or features need to be consider jointly. Detailed trade-offs focus in on the features. No one should be surprised to discover a pragmatic consumer switching between decision strategies with their associated spatial or category representations over the purchase process as needed to complete their tasks.

Nonnegative Matrix Factorization of Car Perceptions

I will not repeat the comprehensive and easy to follow analysis of this automobile data from the plfm R package. All the details are provided in Section 4.3 of Michel Meulders' Journal of Statistical Software article (see p. 13 for a summary). Instead, I will demonstrate how nonnegative matrix factorization (NMF) produces the same results utilizing a different approach. At the end of my last post, you can find links to all that I have written about NMF. What you will learn is that NMF extracts latent features when it restricted everything to be nonnegative. This is not a necessary result, and one can find exceptions in the literature. However, as we will see later in this post, there are good reasons to believe that NMF will deliver feature-like latent variables with marketing data.

We require very little R code to perform the NMF. As shown below, we attach the plfm package and the dataset named car, which is actually a list of three elements. The cross-tabulation is an element of the list with the name car$freq1. The nmf function from the NMF package takes the data matrix, the number of latent features (plfm set the rank to 6), the method (lee) and the number of times to repeat the analysis with different starting values. Like K-means, NMF can find itself lost in a local minimum, so it is a good idea to rerun the factorization with different random start values and keep the best solution. We are looking for a global minimum, thus we should set nrun to a number large enough to ensure that one will find a similar result when the entire nmf function is executed again.

library(plfm)
data(car)
 
library(NMF)
fit<-nmf(car$freq1, 6, "lee", nrun=20)
 
h<-coef(fit)
max_h<-apply(h,1,function(x) max(x))
h_scaled<-h/max_h
library(psych)
fa.sort(t(round(h_scaled,3)))
 
w<-basis(fit)
wp<-w/apply(w,1,sum)
fa.sort(round(wp,3))
 
coefmap(fit)
basismap(fit)

Created by Pretty R at inside-R.org

In order not to be confused by the output, one needs to note the rows and columns of the data matrix. The cars are the rows and the features are the columns. The basis is always rows-by-latent features, therefore, our basis with be a cars-by-six latent features. The coefficient matrix is always latent features-by-columns or six-latent features-by-observed features. It is convenient to print the transpose of the coefficient matrix since the number of latent features is often much less than the number of observed features.

Basic Matrix
Green
Family
Luxury
Popular
City
Sporty
Toyota Prius
0.82
0.08
0.08
0.00
0.01
0.02
Renault Espace
0.09
0.71
0.02
0.00
0.19
0.00
Citroen C4 Picasso
0.18
0.58
0.00
0.10
0.14
0.00
Ford Focus Cmax
0.00
0.50
0.04
0.35
0.11
0.00
Volvo V50
0.24
0.39
0.29
0.08
0.00
0.00
Mercedes C-class
0.04
0.01
0.69
0.00
0.11
0.16
Audi A4
0.00
0.10
0.43
0.14
0.12
0.21
Opel Corsa
0.17
0.00
0.00
0.83
0.01
0.00
Volkswagen Golf
0.00
0.02
0.29
0.67
0.02
0.00
Mini Cooper
0.00
0.00
0.15
0.00
0.70
0.15
Fiat 500
0.33
0.00
0.00
0.18
0.49
0.00
Mazda MX5
0.01
0.00
0.03
0.00
0.26
0.70
BMW X5
0.00
0.18
0.26
0.00
0.00
0.56
Nissan Qashgai
0.06
0.35
0.00
0.08
0.00
0.51
Coefficient Matrix
Green
Family
Luxury
Popular
City
Sporty
Environmentally friendly
1.00
0.05
0.08
0.34
0.19
0.00
Technically advanced
0.68
0.00
0.62
0.00
0.00
0.35
Green
0.66
0.02
0.06
0.06
0.04
0.00
Family Oriented
0.35
1.00
0.24
0.08
0.00
0.00
Versatile
0.15
0.53
0.27
0.25
0.00
0.16
Luxurious
0.00
0.10
1.00
0.00
0.12
0.56
Reliable
0.21
0.27
0.95
0.69
0.06
0.18
Safe
0.08
0.34
0.88
0.41
0.00
0.10
High trade-in value
0.00
0.00
0.85
0.21
0.00
0.13
Comfortable
0.08
0.57
0.84
0.15
0.04
0.19
Status symbol
0.08
0.00
0.81
0.00
0.40
0.60
Sustainable
0.33
0.23
0.71
0.44
0.00
0.02
Workmanship
0.24
0.03
0.58
0.00
0.00
0.25
Practical
0.09
0.60
0.17
1.00
0.52
0.00
City focus
0.51
0.00
0.00
0.94
0.93
0.00
Popular
0.00
0.23
0.25
0.94
0.52
0.00
Economical
0.90
0.13
0.00
0.93
0.27
0.00
Good price-quality ratio
0.35
0.25
0.00
0.88
0.08
0.12
Value for the money
0.12
0.16
0.10
0.60
0.01
0.10
Agile
0.12
0.06
0.18
0.87
1.00
0.16
Attractive
0.04
0.08
0.58
0.33
0.79
0.50
Nice design
0.04
0.10
0.38
0.23
0.77
0.46
Original
0.36
0.00
0.00
0.03
0.76
0.21
Exclusive
0.10
0.00
0.13
0.00
0.38
0.26
Sporty
0.00
0.00
0.40
0.27
0.45
1.00
Powerful
0.00
0.12
0.70
0.02
0.00
0.74
Outdoor
0.00
0.29
0.00
0.07
0.00
0.57

As the number of rows and columns increases, these matrices become more and more cumbersome. Although we do not require a heatmap for this cross-tabulation, we will when the rows of the data matrix represent individual respondents. Now is a good time to introduce such a heatmap since we have the basis and coefficient matrices from which they are built. The basis heatmap showing the association between the vehicles and the latent features will be shown first. Lots of yellow is good for it indicates simple structure. As suggested in earlier post, NMF is easiest to learn if we use the language of factor analysis and simple structure implies that each car is associated with only one latent feature (one reddish block per row and the rest pale or yellow).


The Toyota Prius falls at the bottom where it "loads" on only the first column. Looking back at the basis matrix, we can see the actual numbers with the Prius having a weight of 0.82 on the first latent feature that we named "Green" because of its association with the observed features in the Coefficient Matrix that seem to measure an environmental or green construct. The other columns and vehicles are interpreted similarly, and we can see that the heatmap is simply a graphic display of the basis matrix. It is redundant when there are few rows and columns. It will become essential when we have 1000 respondents as the rows of our data matrix.

For completeness, I will add the coefficient heatmap displaying the coefficient matrix before it was transposed. Again, we are looking for simple structure with observed features associated with only one latent feature. We have some degree of success, but you can still see overlap between family (latent feature #2) and luxury (latent feature #3) and between popular (#4) and city (#5).


We observed the same pattern defined by the same six latent features as that reported by Meulders using a probabilistic latent feature model. That is, one can simply compare the estimated object and attribute parameters from the JSS article (p. 12) and the two matrices above to confirm the correspondence with correlations over 0.90 for all six latent variables. However, we have reached the same conclusions via very different statistical models. The plfm is a process model specifying a cognitive model of how object-attribute associations are formed. NMF is a matrix factorization algorithm from linear algebra.

The success of NMF has puzzled researchers for some time. We like to say that the nonnegative constraints direct us toward separating the whole into its component parts (Lee and Seung). Although I cannot tell you why NMF seems to succeed in general, I can say something about why it works with consumer data. Products do well when they deliver communicable benefits that differentiate them from their competitors. Everyone knows the reasons for buying a BMW even if they have no interest in owning or driving the vehicle. Products do not survive in a competitive market unless their perceptions are clear and distinct, nor will the market support many brands occupying the same positioning. Early entries create barriers so that additional "me-too" brands cannot enter. Such is the nature of competitive advantage. As a result, consumer perceptions can be decomposed into their separable brand components with their associated attributes.

Discrete or Continuous Latent Structure?

Of course, my answer has already been given in a prior spoiler alert. We do both using dimensions for the big picture and features for more detailed comparisons. The market is separable into brands offering differentiated benefits. However, this categorization has a dissimilarity structure. The categories are contrastive, which is what creates the dimensions. For example, the luxury-economy dimension from the CA is not a quantity like length or weight or volume in which more is more of the same thing. Two liters of water is just the concatenation of two one-liter volumes of water. Yet, no number of economy cars make a luxury automobile. These axes are not quantities but dimensions that impose a global ordering on the vehicle types while retaining a local structure defined by the features.

Hopefully, one last example will clarify this notion of dimension-as-ordering-of-distinct-types. Odors clearly fall along an approach-avoidance continuum. Lemons attract and sewers repel. Nevertheless, odors are discrete categories even when they are equally appealing or repulsive. A published NMF analysis of the human odor descriptor space used the term "categorical dimensions" because the "odor space is not occupied homogeneously, but rather in a discrete and intrinsically clustered manner." Brands are also discrete categories that can be ordered along a continuum anchored by most extreme features at each end. Moreover, these features that we associate with various brands differ in kind and not just intensity. Both the brands and the features can be arrayed along the same dimensions, however, those dimensions contain discontinuities or gaps where there are no intermediate brands or features.

Applying the concept of categorical dimensions to our perceptual data suggests that we may wish to combine the correspondence map and the NMF using a neighborhood interpretation of the map with the neighborhoods determined by the latent features of the NMF. Such a diagram is not uncommon in multidimensional scaling (MDS) where circles are drawn around the points falling into the same hierarchical clusters. Kruskal and Wish give us an example in Figure 14 (page 44). In 1978, when their book was published, hierarchical cluster analysis was the most likely technique for clustering a distance matrix. MDS and hierarchical clustering use the same data matrix, but make different assumptions concerning the distance metric. Yet, as with CA and NMF, when the structure is well-formed, the two methods yield comparable results.

In the end, we are not forced to decide between categories or dimensions. Both CA and NMF scale rows and columns simultaneously. The dimensions of CA order those rows and columns along continuum with gaps and clusters. This is the nature of ordinal scales that depend not on intensity or quantity but on the stuff that is being scaled. In a similar manner, the latent features or categories of NMF have a similarity structure and can be ordered. The term "categorical dimensions" captures this hybrid scaling that is not exclusively continuous or categorical.

7 comments:

  1. Interesting post.
    May be my website on CA (and on its implementation in R) could be of some use: http://cainarchaeology.weebly.com/

    Best
    Gianmarco

    ReplyDelete
    Replies
    1. I have visited your website before and thought that it provided some unique approaches to learning about CA in R. I encourage readers to take a look at your article "Making Sense of Contingency Tables in Archeology" to see an example of how much can be learned from a CA. The key is understanding that data comes as traces or signs or indicators and multivariate techniques like CA reveal the pattern that would be missed without it.

      Delete
    2. Hello,
      thanks for your reply. I am more than happy to know that you visited my website, and that you liked my JDS article.
      Just an update: I have just built an R package that incorporates some of the features of my earlier R script for CA. In addition, it provides the facility to perform some hypothesis testing via permutation. More info at my web site.
      Best
      Gm A

      Delete
  2. A very interesting example.
    There are some similarities with the results of
    topics()
    produced in the library(maptpx) of Matt Taddy.
    That function gives us an indication of the measure of *fit* of the model,
    say with 6 latent variables rather than 5 or 7.
    While maptpx is designed for multinomial rows of the data-matrix, does your use of nmf() enable me to compare different models?

    ReplyDelete
    Replies
    1. There is a vignette associated with the NMF package (http://nmf.r-forge.r-project.org/vignettes/NMF-vignette.pdf) that discusses how many latent variables to retain in Section 2.6 Estimating the Factorization Rank. Basically, instead of one value for the rank, you specify a range (e.g., instead of 6, you substitute the range 5:7). Then, the plot function will take the output from the nmf function and graph all the criteria commonly used to compare models of different rank or number of latent features. Personally, I do not find such criteria for NMF to be any more helpful than the corresponding criteria for the number of factors in confirmatory factor analysis or the number of clusters in cluster analysis. For me, interpretability takes precedence. However, you have raised a good question that certainly deserves more discussion than I have provided in this response.

      Delete
  3. Hi!
    I like your blog very much. Can you add a "subscribe by email" plugin, please? I would like to subscribe your blog through email so that I won't miss.. I'm not that much into subscribing by RSS/Atom etc..

    Thanks so much... :)

    ReplyDelete
    Replies
    1. It seems like a very reasonable request and as easy as adding a gadget to my post, except for the error message. I will look into it when I have time.

      Delete