Calculating Partial Correlation Matrix with Excel VBA

Partial Correlation
It is simply defined as the measure of the relationship between two or more variables while controlling for the effects of one or more additional variables.

For example, study of partial correlation between price and demand would involve studying the relationship between price and demand excluding the effect of price of related goods, disposable income, taste and preference etc.

Derivation
1. Compute correlation matrix
=CORREL(OFFSET(firstvariable_range,,ROWS($1:1)-1),OFFSET(firstvariable_range,,COLUMNS($A:A)-1))

For example, you have a 4 X 4 matrix and data for variables are entered in cells A2:D8 so paste this formula in cell G3  =CORREL(OFFSET($A$2:$A$8,,ROWS($1:1)-1),OFFSET($A$2:$A$8,,COLUMNS($A:A)-1))
In this case, firstvariable_range is A2:A8.

For detailed explanation, visit this link Correlation Matrix using Excel Formula

Download the workbook used in this example and play around with the formula to test your understanding.

2. Compute Partial correlation matrix

How to Execute
1. Open Excel. Press Alt F11 to open VB editor
2. Go to Insert >> Module
3. In module, paste the above code to VB editor 
4. Close VB editor window
5. Select the range of a table M15:P18
6. Enter =PartialCor(G3:J6) and Hit Ctrl Shift Enter
7. After pressing Ctrl Shift Enter you will find {=PartialCor(G3.:J6)}
    across all the cells in matrix


ListenData Logo
Spread the Word!
Share
Related Posts
About Author:
Deepanshu Bhalla

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and Human Resource.

0 Response to "Calculating Partial Correlation Matrix with Excel VBA"

Post a Comment

Next → ← Prev
Looks like you are using an ad blocker!

To continue reading you need to turnoff adblocker and refresh the page. We rely on advertising to help fund our site. Please whitelist us if you enjoy our content.