2
$\begingroup$

I'm trying to calculate the partial correlation between continuous variables $X$ and $Y$ while controlling for $Z$ (a categorical variable with three possible categories).

Tutorials and answered questions all state that it's possible by using dummy values. But they all assume only two categories, so I'm not sure if more than two will work. How sound will the results be?

Further, what possible procedures can I take if the collected data violate normality?

$\endgroup$

2 Answers 2

1
$\begingroup$

When your categorical control variable has three categories, you need to construct and control for two dummy code variables to appropriately represent all three categories. In other words, both dummy variables need to be included when you compute the partial correlation.

$\endgroup$
3
  • $\begingroup$ I'm not sure I follow what you mean here. Could you elaborate a bit? $\endgroup$ Commented Feb 12 at 23:01
  • 1
    $\begingroup$ Sure. @Yousif asked about how to control for (partial out) a categorical variable Z with 3 categories from the relationship between X and Y. Assuming Z is nominal (3 unordered groups), you need two dummy code variables (D1 and D2) to adequately represent the information contained in Z, and you need to include both D1 and D2 in the calculation of the partial correlation (controlling for/partialling out both D1 and D2). $\endgroup$ Commented Feb 13 at 20:06
  • $\begingroup$ Thats more clear now. May want to edit that into your answer. $\endgroup$ Commented Feb 14 at 0:19
1
$\begingroup$

For starters, you don't need normally distributed data to run a correlation. Common correlational measures like Pearson or Spearman simply don't have this as an assumption and generally don't behave all that different with non-normal data unless there is some non-linearity going on.

Second, there certainly exist ways to look at categorical-by-continuous correlations (e.g. point biserial correlation) but as you already noted it is typically used for two-level factors. The problem is that even categorical-by-categorical correlations that allow for more than two levels (e.g. Cramer's $V$) do not really give an accurate picture of where the association is coming from, only that one exists and the magnitude of that association.

I think there are two perhaps better options here. The first is to simply run by-group correlations so you can see what the correlation is between the categories and compare their relative differences in strength. The other option is to simply run a regression if you believe the grouping variable and another continuous variable are the causes of the other continuous variable. If you believe there is some relationship between the two independent variables then you can model an interaction too.

An example of by-group correlations below, where each flower species has its own correlation:

# Correlation Matrix (pearson-method)

Group      |   Parameter1 |  Parameter2 |    r |       95% CI | t(48) |         p
---------------------------------------------------------------------------------
setosa     | Petal.Length | Petal.Width | 0.33 | [0.06, 0.56] |  2.44 | 0.019*   
versicolor | Petal.Length | Petal.Width | 0.79 | [0.65, 0.87] |  8.83 | < .001***
virginica  | Petal.Length | Petal.Width | 0.32 | [0.05, 0.55] |  2.36 | 0.023*   

p-value adjustment method: Holm (1979)
Observations: 50

And a categorical-by-continuous interaction regression below, where the coefficients (the Estimate here) explain the changes in the outcome variable attributed to increases in the predictors:

                               Estimate Std. Error    t value     Pr(>|t|)
(Intercept)                   1.3275634  0.1309327 10.1392790 1.447837e-18
Petal.Width                   0.5464903  0.4900034  1.1152785 2.665889e-01
Speciesversicolor             0.4537120  0.3737007  1.2141056 2.266948e-01
Speciesvirginica              2.9130892  0.4060307  7.1745543 3.527347e-11
Petal.Width:Speciesversicolor 1.3228344  0.5552410  2.3824509 1.850365e-02
Petal.Width:Speciesvirginica  0.1007691  0.5248374  0.1920006 8.480122e-01

We can see these relationships in the plot below:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.