Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating partial correlation adjusted for a categorical variable

Tags:

r

correlation

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?

like image 259
JK076 Avatar asked Nov 23 '15 00:11

JK076


1 Answers

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.

like image 179
Paweł Kleka Avatar answered Sep 29 '22 17:09

Paweł Kleka