9923170071 / 8108094992 info@dimensionless.in
Select Page

WHY DO MULTI-VARIATE ANALYSIS

1. Every data-set comprises of multiple variables, so we need to understand how the multiple variables interact with each other.
2. After we understand uni-variate analysis – where we understand the behaviour of each distribution, and bi-variate analysis – where we understand how each variable relates to the other variables; we need to understand what behaviour change will happen in the trend on introduction of more variables.
3. Multi-variate analysis has good application in clustering, where we need to visualize how multiple variables show different patterns in different clusters.
4. When there are too many inter-correlated variables in the data, we’ll have to do a dimensionality reduction through techniques like Principal Component Analysis and Factor Analysis. We will cover Dimensionality Reduction Techniques in different post.

We will illustrate multi-variate analysis with the following case study:

Data:

Each row corresponds to annual spending by different customers of a whole sale distributor who sells milk / fresh grocery frozen detergent papers and delicassen in 3 different regions – Linson, Aporto and Others (Coded 1/2/3 respectively) through 2 different channels – Horeca (Hotel / Restaurant / Cafe) or Retail Channel (Coded 1/2 respectively)

PROCEDURE TO ANALYZE MULTIPLE VARIABLES

I. TABLES

Tables can be generated using xtabs function, tapply function, aggregate function and dplyr library

II. STATISTICAL TESTS

Anova

Anova can be used to understand, how a continuous variable is dependent on categorical independent variables.

In the following code we are trying to understand if sales of milk is a function of Region and Channel and their interaction.

This shows that expense of milk is dependent on channel

Chi-Square Test

Chisquare Test to understand the association between 2 factor variables

Probability is very high, 11.37%, hence we fail to reject the null hypothesis. Hence, we conclude that there is no association between channel and region.

III. CLUSTERING

Multi-Variate analysis has a very wide application in unsupervised learning. Clustering has the maximum applications of multi-variate understanding and visualizations. Many times we prefer to perform clustering before applying the regression algorithms to get more accurate predictions for each cluster.

We will do hierarchical clustering for our case study, using the following steps:

1. Seperating the columns to be analyzed

Let’s get a sample data comprising of all the items whose expenditure is to be analyzed i.e all columns except Channel and Region – like fresh, milk, grocery, frozen etc.

3. Identifying the appropriate number of clusters for k-means clustering

Though 2 clusters / 3 clusters show the maximum variance. In this case-study we are deviding the data into 10 clusters to get more specific results, visualizations and target strategies.

We can also use within-sum-of-squares method to find the number of clusters.

5. Plot wss using ggplot2 Library

We will plot the within-sum-of-squares distance using ggplot library:

We notice that after cluster 10, the wss distance increases drastically. So we can choose 10 clusters.

5. Dividing data into 10 clusters

We will apply kmeans algorithm to divide the data into 10 clusters:

6. Checking the Attributes of k-means Object

We will check the centers and size of the clusters

7. Profiling Clusters

Getting Cluster-wise summaries through mean function

9. Z-Value Normalisation

z score = (cluster_mean-population_mean)/population_sd

Where-ever we have very high z-scores it indicates, that cluster is different from the population. * Very-high z-score for fresh in cluster 8 and 9
* Very-high z-score for milk in cluster 5,6 and 9
* Very-high z-score for grocery in cluster 5 and 6
* Very-high z-score for frozen products in cluster 7, 9 and 10
* Very-high z-score for detergents paper in cluster 5 and 6

We would like to find why these clusters are so different from the population

IV. MULTI-VARIATE VISUALIZATIONS

1. To understand the correlations between each column

We observe positive correlation between:

• Milk & Grocery
• Milk & Detergents_Paper
• Grocery & Detergents_Paper

Next we will import the ggplot2 library to do the graphical representations of data data-frame.

We’ll also add the column cluster number to the data-frame object “data”.

Next we will check the cluster-wise views and how the patterns differ cluster-wise.

Milk vs Grocery vs Fresh cluster wise analysis

• We notice that if expenditure on milk is high, expenditure on grocery or fresh is high, but not both
• We notice cluster 4 contains data points on the high end of milk or grocery
• Cluster 3 has got people with high spending on milk and average spending on grocery
Relationship between Milk, Grocery and Fresh across Region across Channel

• Region 3 has more people than Region 1 and 2
• In Region 3 we observe an increasing trend between milk and fresh and grocery
• In Region 1 we notice that there is an increasing trend between milk and grocery but fresh is low
• In Region 2 we notice medium purchase of milk and grocery and fresh
• High milk / grocery sales and medium fresh sales is through channel 2
• In channel 2 there is an increasing trend between consumption of milk and consumption of grocery
• Cluster 4 has either high sales of milk or grocery or both
• Channel 2 contributes to high sales of milk and grocery, while low and medium sales of fresh

Milk vs Grocery vs Frozen Products Cluster wise analysis

• Very high sales of frozen products by cluster 11 and cluster 7
• People purchasing high quantities of milk and grocery are purchasing low quantities of frozen products
Relationship between Milk, Grocery and Frozen Products across Region

• In Region 2 and Region 3, we have clusters 1 and 3 respectively, which have high expenditure pattern on frozen products
Relationship between Milk, Grocery and Frozen across Channel

• We notice that channel 1 has many people with high purchase pattern of frozen products
• Channel 2 has some clusters (cluster no.: 5 and 6) with very high purchase pattern of milk

Relationship between Frozen Products, Grocery and Detergents Paper across Region across Channel

• In channel-2, people who are spending high on grocery are also spending low on frozen
• High sales of detergents paper and grocery are observed through channel 2
• Sales of frozen products is almost nil through channel 2
• Cluster 4 has high expenditure on Detergents_Paper
• Through channel 2 sales of frozen products is 0

Relationship between Milk, Delicassen and Detergents Paper across Region

• People who spend high on milk hardly spend on Delicassen, though in region 3 we do see comparitively more expenditure on Delicassen
• Cluster 3 in region 3 has very high expenditure on delicassen and high expenditure on milk
• Cluster 4 has high consumption pattern on milk and detergents paper

Relationship between Milk, Grocery and Detergents Paper across Channel

• Channel 2 is having an increasing trend between milk and Detergents Paper
• Where sales of detergents paper is high, the sales of milk is also high
• Channel 4 has high expense pattern on Detergents Paper or Milk
Relationship between Milk, Grocery and Detergents Paper across Region across Channel

• Channel 2 is having an increasing trend between milk and Detergents Paper
• Where sales of detergents paper is high, the sales of milk is also high
• Channel 4 has high expense pattern on Detergents Paper or Milk
Relationship between Milk, Grocery and Detergents Paper across Region across Channel

• There is a linear trend between Milk and Grocery in channel 2
• There is a linear trend between Grocery and Detergent Paper
• Channel 4 has high comption of grocery and detergents paper or grocery
• Cluster 10 has medium consumption of milk, grocery and detergents paper
• Cluster 6 has low consumption of milk and grocery and detergents paper
• Cluster 2 has lowest consumption of milk grocery and detergents paper

Based on the above understanding of cluster-wise trends, we can devise cluster-wise, region-wise, channel-wise strategies to improve the sales.

V. DIMENSIONALITY REDUCTION TECHNIQUES

We use dimensionality reduction techniques like PCA to transform larger number of independent variables into a smaller set of variables:

Principal Component Analysis

Principal component analysis (PCA) tries to explain the variance-covariance structure of a set of variables through a few linear combinations of these variables. Its general objectives are: data reduction and interpretation. Principal components is often more effective in summarizing the variability in a set of variables when these variables are highly correlated.

Also, PCA is normally an intermediate step in the data analysis since the new variables created (the predictions) can be used in subsequent analysis such as multivariate regression and cluster analysis.

We will discuss PCA in my further posts.