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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With