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))
}