Could someone please help me understand the concept of performing a t-test while controlling/adjusting for one or more variables?
E.g.: Say I have a hypothetical data set, with the following variables
sex, age, smoker, weight, height, bmi, smoking_duration, max_oxygen_uptake. Let us say I want to test if smokers have a higher
max_oxygen_uptake, than non-smokers?
Then in R I would write:
max_oxygen_uptake will likely also depend on e.g.
smoking_duration. Maybe also
sex. Therefore I am looking for something along the lines of:
How do I perform a t-test, while controlling/adjusting for other variables?
How do I decide which variables should be controlled/adjusted for?
I know it has something to do with
lm(), but I am having conceptual problems in connecting the t-test to creating a linear model?