# Variable controlling in linear regression and covariates

I am analyzing cardiac data and have interests in cardiac problems and exercise. I just want to focus on the exercise effect and found AGE is significant variable. I'd like to control AGE variable because it was not my interest.

All the variables were AGE, GENDER, blood pressure, smoke, BMI, drink, stress, exercise and the dependent variable is cardiac problem(the sum of cases of cardiomyopathy, heart failure, myocardial infarction), and the sample size is 2200.

After simple linear regression, I found the AGE, GENDER, blood pressure (measurement), BMI, exercise(time per week), stress (PWI-SF score) were significant. I separated the data by GENDER and made models by adding variables in order. The problem is I just want to focus on the association among the variables without AGE effect. Although AGE is important variable in the disease data, I'd like to deal with it as confounder.

I found this page explaining how to controlling AGE factor in the analysis.

http://rstudio-pubs-static.s3.amazonaws.com/310471_2dbd42091bab4771af1d39f687b2ac20.html

I understood this is an example of the subtracting the regression effect of the non-interesting variable from the dependent variable. i.e.

new_Y = Y - predict(lm(Y ~ AGE)).
model = lm(data, Y ~ AGE + excercise + ...)
new_model = lm(data, new_Y ~ AGE + exercise + ...)


This looks different from ANCOVA, subtracting covariates from the variable.

Actually, I failed ANCOVA in r depending on the order of the variables (I couldn't control the AGE effect) and succeeded by this method.

So, I'd like to know whether my understanding is right and hopefully the reference. Thank you.

• The modelliing in the linked page seems like some kind of lngitudinal model which may not be appropriate for you study and data. Please edit the question to include details of all the variables you have and the size of the dataset. Mar 3 at 9:30
• @RobertLong edited, thanks. Mar 3 at 10:19

First of all, try not to be too concerned with p values. They are heavily reliant on sample size. Second, the linked document is not relavent to your analysis as far as I can tell.

I would suggest a multivariable regression model.

You should include variables in your model based on expert knowlege of cardiology - if there is reason to believe that all the variables are associated with the outcome then they should be considered for inclusion in the model.

In your case it seems that age is a possible confounder - along with gender.

There is no point in splitting the data by gender and this will just lead to a loss of statistical power. Instead you can interact gender with your main exposure, exercise.

Then the issue becomes how to handle the other variables: Blood Pressure, BMI and Stress. It seems plausible that the main exposure, exercise, causes (negatively affects) all three of these, and also that all 3 of these may be causes of the outcome. As such, they lie on the causal path between exercise and thee outcome. That is, they are mediators and should NOT be included in the model, otherise you will only be estimating the direct effect of exercise, and not the total affect (the direct affect plus the mediated/ indirect effects)

It is always good to draw a causal diagram / DAG in this type of situation. Here is one that reflects the assumptions in the previous paragraph:

This was produced using http://www.dagitty.net/dags.html#

According to this diagram the correct model would be:

lm(Cardiac ~ Exercise + Gender + Age, data = mydata)


If you want to allow for different effects in each gender then you can also fit the interaction, as mentioned above:

lm(Cardiac ~ Exercise + Gender + Exercise:Gender + Age, data = mydata)


Of course it is possible that you disagree with the causal assumptions above. For example, you might believe that BMI causes exercise (because people with high BP will be encouraged to exercise more). This is a judgement you have to make yourself, and this reflects some of the inherent problems in analysing observational (rather than experimental) data. I would strongly recommend reading this post:
How do DAGs help to reduce bias in causal inference?

• Maybe the similar view point, cause I thought the Structure Equation Model, other values as potential variables, but before the process, I think regression should be conducted first and wanted to get rid of confounders. I should think about the attached web page contents. Thank you for your opinion! Mar 3 at 11:15
• You're welcome. I haven't studied the linked page in detail but at a glance, some of the things they are doing seem very strange to me. And, I agree, an SEM model might be useful. Mar 3 at 11:30