2
$\begingroup$

I have some physiological data that I would like to remove the gender & age effects from it. I used the model in R

lm(Measure~Physio+Age+Gender) 

My question is for the next stage of analysis I would like to use the Measure without the gender & age effects. Which outcome variable of lm should I be using?

$\endgroup$
8
  • 1
    $\begingroup$ What is the next stage of analysis anyway? It's relevant for answering this in a way that will be helpful $\endgroup$ Commented Oct 29, 2016 at 20:27
  • $\begingroup$ Two things I have in mind: (1) To fit a model to the physiological data with the gender & age effects removed. That can be done by regression? (2) To compare two groups of people in terms of their treatment received, but without gender & age effects (which is correlated with the physiological data). Thanks! $\endgroup$
    – TTZ
    Commented Oct 29, 2016 at 22:21
  • $\begingroup$ So for #2 you want to control for gender and age? Is "Physio" the treatment? What do you mean by "removed?" $\endgroup$ Commented Oct 29, 2016 at 22:23
  • $\begingroup$ Indeed for #2, I would like to control for gender and age. Physiological data are the EEG measures obtained, which may be described by a histogram for each subject. I would like to model this histogram controlling for age and gender effects. Apologies, by "removed" I meant "control for gender and age". $\endgroup$
    – TTZ
    Commented Oct 30, 2016 at 10:43
  • $\begingroup$ what do you mean by "model this histogram"? $\endgroup$ Commented Oct 30, 2016 at 22:09

1 Answer 1

3
$\begingroup$

You are looking for the residuals from your model, they are the bit left over after you subtract out the predicted values. Handily R has a resid() extractor function for you to save you the hassle of working it out yourself. If you did want to see the predicted values for some reason it is no surprise that there is a predict() method for lm objects.

$\endgroup$
6
  • 1
    $\begingroup$ Are you sure that's what they're asking for? It looks to me like they want a posterior prediction from model <- lm(Measure~Age+Gender), i.e. m <- fitted(model); s <- summary(model)$sigma; rnorm(length(m), m, s). That would be an approximate expected distribution of Measure by "integrating out" age and gender. This is not at all the same thing as the residual. $\endgroup$ Commented Oct 29, 2016 at 13:15
  • 1
    $\begingroup$ @ssdecontrol that is a good point. Perhaps it is worth posting it as an alternative answer? $\endgroup$
    – mdewey
    Commented Oct 29, 2016 at 13:23
  • $\begingroup$ @ssdecontrol Many thanks for pointing out! Is it correct that rnorm(length(m), m, s) returns the distribution that has age and gender covariates removed? Would "m" be the measures that have age and gender covariates removed? $\endgroup$
    – TTZ
    Commented Oct 29, 2016 at 13:40
  • 1
    $\begingroup$ (+1 to the post as well as the two comments - apparently I am the only upvoter in this thread!) I think that this is a bit of a philosophical point. In the case we analyse the residuals we take the stance that all X variables "add up" to give us the final Measure. In the case of analysing the "approximate expected distribution" we assume that the variables X determine Measure and given enough of them Measure should be perfectly determined. Pick your poison... $\endgroup$
    – usεr11852
    Commented Oct 29, 2016 at 14:15
  • $\begingroup$ @usεr11852 i suppose it comes down to how literally you want to interpret the term "subtract". I'll post my comment as an answer when I'm no longer posting from my phone. $\endgroup$ Commented Oct 29, 2016 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.