Re: [R] How to do covariate adjustment in R

From: Peter Langfelder <>
Date: Fri, 20 May 2011 16:23:19 -0700

On Thu, May 19, 2011 at 10:58 PM, karena <> wrote:
> Thank you so much for this reply, Peter. It helps.
> I know this is one way to adjust for covariates. However, if what I want is
> to get the 'remaining values' after adjustment. For example, say, 'gene
> expression' value is denoted as 'ge', and for each gene,
> ge=a*age+b*sex+c*per_se
> My question is: how to get the value of 'per_se' for each gene?

You could use the residuals after regressing the expression on sex and age. I think the call would be


but try it and see if it makes sense. Just note that the residual depends on how you define sex and and age; for example, if you shift age by 10, the residuals shift by a*age. Similarly, the residuals will depend on whether you use sex values (1,2) or (0,1) or (2,1) etc. for (female, male). Thus you need to be careful when interpreting the residuals. I would suggest standardizing age to mean zero so the residuals have the interpretation of expression at average age. Standardization for sex makes statistical but not biological sense since there are no samples with average sex.

Peter mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 20 May 2011 - 23:25:44 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 21 May 2011 - 00:20:08 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive