6
votes

I am trying to compute a partial correlation in R in between 2 continuous variables adjusted for a categorical variable with 3 levels.

A        B        Category
146.0    315.71   Level 1
66.73    301.22   Level 2
2487.07  115.94   Level 3
.        .        .
.        .        .

The function pcor.test in package "ppcor" requires all the variables being numeric, i.e.:

pcor.test(x, y, z, method = c("pearson", "kendall", "spearman"))

How I can calculate partial correlation using categorical variables for adjustment?

1

1 Answers

1
votes

I think You can do this in better way. Compute a correlation in every subset for levels in "Category". Then You can compare the r scores using Fisher transformation.

Adjusting correlation using categorical variable is bad idea.