This month’s newsletter on the scatter plot matrix expands on two previous newsletters. It includes an interesting set of data that examines the impact of three variables on the taste of cheddar cheese. There are correlations between each of the three variables and the taste of the cheese, but there are also correlations between the three variables. Please feel free to add comments at the end of the newsletter – perhaps on what you see in the data.
Last month, we looked at correlation analysis, which is a method of determining if a linear relationship exists between two variables. We combined the use of scatter diagrams with the calculation of the Pearson correlation coefficient. This month we will look at how to make multiple scatter diagrams in a technique called the scatter plot matrix. This technique makes it easier to visually see the relationships between several variables at the same time.
In this issue:
- The Cheddar Cheese Data Set
- Types of Correlation Review
- Scatter Diagram Review
- Correlation Coefficient Review
- Correlation Coefficient Table for Multiple Variables
- Scatter Plot Matrix
- Quick Links
The Data Set: Cheddar Cheese Taste
Cheddar cheese is a popular cheese. This example involves taking a look at what impacts the taste of the final product. This example is from the statsci.org website that is “a window to statistical science and bioinformatics on the web, with special attention to Australia.” This website has a number of datasets that you can use for examples in teaching. Here is a summary of the project:
“As cheese ages, various chemical processes take place that determine the taste of the final product. In a study of cheddar cheese from the LaTrobe Valley of Victoria, Australia, samples of cheese were analyzed for their chemical composition and were subjected to taste tests. Overall taste scores were obtained by combining the scores from several tasters. This dataset contains concentrations of various chemicals in 30 samples of mature cheddar cheese, and a subjective measure of taste for each sample. The variables “Acetic Acid” and “H2S” are the natural logarithm of the concentration of acetic acid and hydrogen sulfide respectively. The variable “Lactic Acid” has not been transformed.”
The data are shown in the table below.
|Case||Taste||Acetic Acid||H2S||Lactic Acid|
Types of Correlation Review
When comparing two variables to determine if there is a linear correlation, there are basically three types of correlation that can exist as was shown in last month’s newsletter.
A positive correlation exists between variable X and variable Y if an increase in X results in an increase in Y (and vice-versa).
- The more cigarettes you smoke, the greater the chance of lung cancer.
- If you are paid by the hour, the more hours you work, the more pay you receive.
- The more time you spend studying, the better grades you make in school.
A negative correlation exists between variable X and variable Y if a decrease in X results in an increase in Y (and vice-versa).
- The heavier your car is, the lower your gas mileage is.
- The colder it is outside, the higher your heating bill.
- The more time you spend watching TV, the lower your grades are in school.
No correlation exists. In this case, a change in X has no impact on Y (and vice-versa). There is no relationship between the two variables. For example, the amount of time I spend watching TV has no impact on your heating bill.
Remember: just because there is a correlation between two variables does not mean that one is the cause of the other. Please refer to last month’s newsletter for more discussion on this.
Scatter Diagram Review
A scatter diagram simply plots the Y variable versus the X variable. In the above data, the Y variable is the taste. There are three “X” variables: acetic acid concentration, hydrogen sulfide concentration and lactic acid concentration. One could draw three separate scatter diagrams for the each X variable and its impact on the Y variable. But there are actually more scatter diagrams to consider. What about the relationship between the three X variables? Is it possible that there is a correlation between, for example, acetic acid and lactic acid? What about between hydrogen sulfide and lactic acid? As we will see below, the scatter plot matrix gives us a quick visual look at all possible pairs of correlations.
The scatter diagram for acetic acid versus taste is shown below. It is made by simply plotting the pairs of data for each point. For example, sample 1 had a taste of 12.3 and ln(acetic acid concentration) of 4.543. The 4.543 represents the x variable and the 12.3 is the y variable on the chart below. Sample 1 is highlighted by the arrow in the scatter diagram below. The other data points represent the remaining sample pairs.
The straight line represents the “best-fit” line based on the data. There appears to be positive correlation between the two. The taste improves as the acetic acid concentration increases.
Correlation Coefficient Review
Last month we demonstrated how to calculate the Pearson correlation coefficient. Please review that newsletter for more details. The equation for the Pearson correlation coefficient is:
The correlation coefficient between taste and acetic acid concentration is R = 0.55. If R is positive, there is a positive correlation between the two variables. The closer to 1 R is, the stronger the positive correlation. If R is negative, there is a negative correlation between the two variables. The closer R is to -1, the stronger the negative correlation. There is no correlation if R is equal to zero.
We also showed how to determine the p value for the correlation. The p value between taste and acetic acid concentration is 0.002. This implies that there is a statistically significant correlation between the two variables if our chosen significance level is 0.05.
Correlation Coefficient Table for Multiple Variables
You can develop a table that contains the correlation coefficients for all possible pairs of variables. This is shown in the table below. For each pair of variables, the R value is the top value. The p value is the bottom value.
You can see that there is all the R values have a p value less than our significance level of 0.05. This means that all the correlations are statistically significant.
Scatter Plot Matrix
We are now ready to develop the scatter plot matrix. The scatter plot matrix simply plots scatter diagrams between all possible pairs of data and visually displays them so you can quickly see the relationship between the variables.
Suppose you have three variables. There are six possible combinations of pairs of the variables. The scatter plot matrix layout for three variables is shown below.
Look at the first row. Variable A is listed by its name. Then, still on row one, the scatter plot between B and A is shown next. B is in the second column. This scatter plot is x vs. y. In this row, A is always plotted on the y axis. The last scatter diagram is of C and A. The second row focuses on variable B. The first plot is another plot of the relationship between A and B, but this time B is on the y axis. You sometimes see a different picture when you switch which factor is on the y axis. It does not change the relationship – it just sometimes makes it easier to see. The process continues for all pairs of variables.
The scatter plot matrix for the taste data is shown below. What do you see?
There does appear to be a positive correlation between all the variables. The scatter plot matrix provides a quick visual check on the possible correlations.
The three X variables have significant positive correlations with taste but they are correlated with each other. Does just one of them really influence the taste? Maybe two of them? Maybe all three?
If you are trying to predict a value for Y based on the multiple X variables, you can run into problems if the X variables are highly correlated. This phenomenon is called multicollinearity. It does not reduce the predictive power of the model based on the X variables, but it does make it difficult to understand the contribution of the individual X variables.
The output from the multiple regression for taste based on the three X variables is shown below. For more information on this output, please see our two part series on linear regression from June – July 2008 at this link. You can see from the results (looking at the p values) that the acetic acid concentration does not add anything additional to the model. The p value for acetic acid concentration is large. The best model is when you include only the H2S concentration and the lactic acid concentration.
The scatter plot matrix is a great technique for seeing the relationship between pairs of variables. A scatter diagram for every pair of variables is given in the scatter plot matrix. It will give you a quick look at which variables are correlated to other variables and can be a big help in seeing what predictor variables may be correlated in regression analysis
Thanks so much for reading our publication. We hope you find it informative and useful. Happy charting and may the data always support your position.
Dr. Bill McNeese
BPI Consulting, LLC