Skip to content Skip to sidebar Skip to footer

Can I Use Spearman Correlation for Continuous Variables

Partial correlations are great in that you can perform a correlation between two continuous variables whilst controlling for various confounders. However, the partial correlation option in SPSS is defaulted to performing a Pearson's partial correlation which assumes normality of the two variables of interest.

But what if you want to perform a Spearman's partial correlation on non-normally distributed data?

If you go to Analyze > Correlate > Partial … you will see that there is no option to select a Spearman correlation. There is, however, a way around this using a little coding.

In this guide, I will explain how to perform a non-parametric, partial correlation in SPSS.

The required dataset

To be able to conduct a Spearman partial correlation in SPSS, you need a dataset, of course. For our example, we have the age and weight of 20 volunteers, as well as gender. What we want to test is if there is a correlation between age and weight, after controlling for gender.

Non-parametric partial correlation example data in SPSSCreating the script

For this to work, you need to enter a small piece of script into the SPSS Syntax Editor. Open up the Syntax Editor by going to File > New > Syntax .

Next, copy and paste the following code:

NONPAR CORR /MISSING = LISTWISE /MATRIX OUT(*). RECODE rowtype_ ('RHO'='CORR') . PARTIAL CORR /significance = twotail /MISSING = LISTWISE /MATRIX IN(*).

You now need to add the appropriate variables next to the NONPAR CORR and PARTIAL CORR sections.

So, next to the NONPAR CORR enter all of the variables that will be involved in the partial correlation. In our example, this would be Age, Weight and Gender.

For the PARTIAL CORR line you need to enter the two variables of interest in the correlation followed by a BY then the variables you want to control for. Make sure all of the variables you enter match the ones in your file correctly, otherwise the script will fail.

Here is what our example will look like:

NONPAR CORR Age Weight Gender /MISSING = LISTWISE /MATRIX OUT(*). RECODE rowtype_ ('RHO'='CORR') . PARTIAL CORR Age Weight BY Gender /significance = twotail /MISSING = LISTWISE /MATRIX IN(*).

And here is what it looks like in the Syntax Editor:

Non-parametric partial correlation syntax script in SPSSRunning the script

The script itself is separated into 3 parts: NONPAR CORR , RECODE and PARTIAL CORR .

The first is to perform a Spearman bivariate correlation for all variables and to add the Spearman rank correlation coefficients into a new file.

RECODE converts the row type from a Spearman (RHO) to a Pearson (CORR).

Finally, PARTIAL CORR performs the partial correlation on the desired variables by using the newly created Spearman correlation coefficients from the NONPAR CORR script.

Here is how to run the script:

1. To run the script, go to the Syntax Editor and with the NONPAR CORR section selected, hit the green play button.

Running the non-parametric partial correlation code in the syntax editor in SPSSThis will give you an output for the Spearman's rho between the variables. If you go to the SPSS Output file you will see:

Spearman correlation matrix in SPSSYou will also notice that a new SPSS data file has been created and is now open. This is usually named 'Untitled', or something similar. Within this file, you will see the Spearman's rho values and n numbers for each correlation.

2. You next need to go back to the Syntax Editor window and run the RECODE part of the script. Make sure you select the new dataset as the active worksheet for this, as you want to perform the RECODE on the new sheet. You can toggle between datasets by clicking on the drop-down menu next to Active: . In this case, we select the Unnamed sheet:

Changing the active dataset in the syntax window of SPSSClick the green play button again to run the RECODE script on this.

3. Finally, still in the Syntax window, select the PARTIAL CORR code and run this on the same Unnamed dataset. This will perform the final partial correlation.

The output

By looking in the output file, you should now see a Partial Corr box which contains the partial correlation coefficients and P values for the test:

Partial correlation matrix output in SPSSYou will see in this example that the non-parametric partial correlation for age with weight, after controlling for gender, has a coefficient value of '0.383' and has a significant value of '0.105'.

Therefore, there is not a significant correlation for age and weight after accounting for gender.

coxadezvot1955.blogspot.com

Source: https://toptipbio.com/spearman-partial-correlation-spss/

Post a Comment for "Can I Use Spearman Correlation for Continuous Variables"