Partial Correlations in Minitab, SPSS, and R Contents Required Background.....................................................................................................................................................................................1 Required Software .........................................................................................................................................................................................1 Introduction to Partial Correlation ..................................................................................................................................................................1 The Dataset ...................................................................................................................................................................................................1 Partial Correlation in Minitab ..........................................................................................................................................................................3 Partial Correlation in SPSS............................................................................................................................................................................. 6 Partial Correlation in R....................................................................................................................................................................................7
Required Background • •
Everyone should have read the correlational analysis handout. Minitab users should also have read the regression handouts.
Required Software
SPSS Data File
Minitab Project File
Importable CSV for R
Introduction to Partial Correlation Sometimes a researcher wants to know the relationship between two variables while the effects of a third variable are held constant. Suppose that we have three variables 1, 2, and 3 and we wish to find the relationship between 1 and 2, with the effects of 3 removed from both. In fact what we want to do is correlate the residual scores of 1 and 2, after the parts of 1 and 2 predictable from 3 have been subtracted. Such a correlation is the partial correlation between variables 1 and 2. The hypothesis test for partial correlation is as follows: Null Hypothesis: There is no relationship between variables 1 and 2, controlling for variable 3. Alternative Hypothesis: There is a relationship between variables 1 and 2, controlling for variable 3. If none of this sounds familiar, then be sure to the handout on correlational analysis! It is important to note that df = N -3 for a partial correlation.
The Dataset The dataset contains 60 months (five years) of data for gum sales at a local gas station. The dataset has sales, profit, and interest payments related to the financing needed to keep gum in stock. We will use this dataset to determine the partial correlation between sales and profit while controlling for interest. Sales
Profit
Interest
1000.353
622.4942 0.091133
1002.397
633.519
1002.533
628.9583 0.09306
0.075942
1000.203 619.9433 0.097221 998.8394 624.6088 0.093203 1001.446 620.994
0.079934
998.7064 619.8922 0.099347 999.674
624.8208 0.092392
999.6134 619.7023
0.096176
999.8236 620.59
0.121516
1002.165 621.4117
0.089523
998.689
619.6785 0.106308
1001.022 620.0485 0.074995 999.9149 617.8404 0.106124 1001.139
618.9093 0.077288
1006.329 620.3996 0.116421 998.2196 619.1251
0.115927
998.9801 621.7212
0.101649
1000.288 618.7025 0.113458 996.5589 616.1512
0.114679
1000.089 622.0761 0.113273 998.7415
619.9917 0.104669
1003.915
619.5725
999.6691 620.22
0.114711 0.083765
1006.869 619.4585 0.126936 1000.172
664.0557 0.125803
1000.475
620.0632 0.092193
999.9872 635.2364 0.134719 997.0804 620.9062 0.101591 999.6016 619.6734
0.084133
1001.892 629.8217 0.111984 1000.955 621.6027 0.130565 1000.009 620.6367 0.118512 988.2348 638.4808 0.112619 849.6505 620.1895 0.070818 1002.495 615.7424
0.123398
1000.025 621.2187 0.09072 999.9833 618.6298 0.110015 1001.6
616.0545 0.111069
999.4087 622.4164 0.100356 988.2799 642.6215 0.09193 998.8874 629.3984 0.091031 1004.184 615.9057
0.080091
1000.638 621.7297
0.092491
996.3747
620.3224 0.084668
998.786
619.8416 0.101254
1001.569
620.8446 0.107874
998.8819 609.9203 0.107182 1000.651
624.5568 0.093991
1000.609 617.8202 0.123875 999.6975 620.6607 0.07318 1000.202 631.3125
0.091016
999.9956 620.7116
0.104061
999.8952 616.8328 0.110036 1000.049 621.6332 0.11326 1000.479
622.4718 0.083627
999.0202 620.1061 0.082309 1000.197
623.1537
1004.124 619.154
0.076498 0.134071
998.8365 622.6228 0.083686
Partial Correlation in Minitab Minitab does not natively support partial correlations and you have to perform a trick as to get the partial correlation. Thus we will use linear regression as to calculate the needed values for the partial correlation calculation and then perform the hypothesis test. The hypothesis test for partial correlation is as follows: Null Hypothesis: There is no relationship between sales and profit, controlling for interest. Alternative Hypothesis: There is a relationship between sales and profit, controlling for interest. The workflow is simple: • • •
Perform a regression between profit and interest while storing the residuals of the regression (RESI1). Perform a regression between sales and interest while storing the residuals of the regression (RESI2). Perform a correlation using RESI1 and RESI2. The result will be the partial correlation between sales and profit because the regressions remove the effects of Interest.
Step 1: Open the project file and perform a regression between Profit and Interest. Follow the screenshots and you should be fine because you read the regression guide, right? If not, go read it—it’s good for you!
Click on Storage… and be sure to check Residuals. Click OK, twice.
Step 2: Make sure the residuals are stored in RESI1. All you have to do is make sure the column is listed.
Step 3: Repeat Step 1 for Sales and Interest. You should obtain a second column of residuals.
Step 4: Perform a correlation between both columns of residuals. (Did you read the guide on correlational analyses? You should!) Follow the screenshots:
Step 5: Read the results!
The realationship between sales and profit was subjected to a partial correlations controlling for interest payments. The partial correlation was found to be insignifcant, r(57) = -0.027, p = 0.838. Thus there is no detectable relationship between sales and profit, controlling for interest payments.
Partial Correlation in SPSS The hypothesis test for partial correlation is as follows: Null Hypothesis: There is no relationship between sales and profit, controlling for interest. Alternative Hypothesis: There is a relationship between sales and profit, controlling for interest. Step 1: Open the SAV file and select Analyze->Correlate->Partial…
Step 2: Fill in the Partial Correlations box. The Variables are the variables between which we’re seeking a partial correlation. The Controlling for holds the varible we wish to partial out. Thus fill in the box as shown and click OK.
Step 3: Read the results! Correlations Control Variables
Sales Correlation
Sales
Significance (2-tailed) df
Profit
1.000
-.027
.
.839
0
57
-.027
1.000
.839
.
57
0
Interest Correlation Profit
Significance (2-tailed) df
The realationship between sales and profit was subjected to a partial correlations controlling for interest payments. The partial correlation was found to be insignifcant, r(57) = -0.027, p = 0.839. Thus there is no detectable relationship between sales and profit, controlling for interest payments.
Partial Correlation in R Make sure you have installed and loaded the ppcor library: install.packages(“ppcor”) library(ppcor) The hypothesis test for partial correlation is as follows: Null Hypothesis: There is no relationship between sales and profit, controlling for interest. Alternative Hypothesis: There is a relationship between sales and profit, controlling for interest. Step 1: Import and attach the dataset in R-Studio. See the video guide at the blog in case you forgot how to import and attach. The dataset will be called PartialCorr. Step 2: Execute the pcor() command upon the dataset: pcor(PartialCorr) Step 3: Read the results! > pcor(PartialCorr) $estimate Sales Profit Interest Sales 1.00000000 -0.02695726 0.25421374 Profit -0.02695726 1.00000000 0.07988651 Interest 0.25421374 0.07988651 1.00000000 $p.value Sales Profit Interest Sales 0.0000000 0.8386686 0.0472040 Profit 0.8386686 0.0000000 0.5451366 Interest 0.0472040 0.5451366 0.0000000 $statistic Sales Profit Interest Sales 0.0000000 -0.2035968 1.9844652 Profit -0.2035968 0.0000000 0.6050637 Interest 1.9844652 0.6050637 0.0000000 $n [1] 60 $gp [1] 1 $method [1] "pearson"
The realationship between sales and profit was subjected to a partial correlations controlling for interest payments. The partial correlation was found to be insignifcant, r(57) = -0.027, p = 0.839. Thus there is no detectable relationship between sales and profit, controlling for interest payments.