# Partialling out first factor from factor analysis

Is there a way to use the factor scores from one dataset to "partial out" the effects from another dataset which has the same variables? Basically I have two datasets: healthy people and sick people. I'd run factor analysis on the healthy set (called "base"), restricting to only one factor so that it acts like a summary score:

fa=factanal(base,1,rotation="varimax",scores="regression")


Then I'd like to use the factor scores from the healthy population and regress out the factor from the sick population. The aim of this is to partial out any underlying relationships in the variables which may not be due to the people being sick. I know how to partial out the scores from the "base" data (see below) but the dimensions for fa$scores differ from the healthy vs sick people... any ideas? Is this doable? pdata=as.data.frame(matrix(0,0,nrow=nrow(base),ncol=ncol(base))) for (i in 1:ncol(base)){ pdata[,i]=residuals(lm(base[,i]~fa$scores))
}

-
Sorry, I failed to mention I'm using R to do this. –  Bstat Jul 25 '12 at 18:42
One note. What is the effect of rotation in your 1st command, there being only 1 factor extracted? –  ttnphns Jul 25 '12 at 18:55
You make a very good point! The rotation wouldn't have an effect here. I just thought factor analysis would be able to extract a summary measure among the variables and didn't think about the rotation. Would FA not be an appropriate method of approaching this then? –  Bstat Jul 25 '12 at 19:09
Could you say more about the dataset and what you would like to do? I know situations where we want to remove 1st factor (often in PCA) but I'm not sure to understand the rationale in your context (as I understand it so far). –  chl Jul 25 '12 at 22:19
Basically I have a dataset with a grouping variable (say sick vs healthy) and a bunch of variables that are known to be correlated. I want to be able to distinguish the base correlation (from the healthy population) from the correlation that's DUE to the disease. I know I can maybe just compare the two correlation matrices between the two groups but I'm actually also doing something additional to the covariance/correlation matrix for the disease group (i.e., glasso for sparse covariance estimation) so I need to "remove" the base relationships first. Does that explanation help? –  Bstat Jul 26 '12 at 3:06
show 1 more comment