2
$\begingroup$

I'm doing a retrospective study where I want to analyze whether a certain treatment (surgery A vs. surgery B) has an effect on the health status after the surgery measured with different parameters (blood measures for example which are continuous variables but also measures like certain complications which are categorial). Since it is a retrospective study I couldn't control for the gender distributions within the two conditions (A vs. B). When looking at the data I see that there are many more males in one condition than in the other. So now I think the best will be to predict health status depending on the kind of surgery adjusted for gender (and possibly age too). Since treatment and gender are both categorial variables I wondered how I can both include them in a linear model, do I need to dummy code both? And how would this look like in R for example?

Another related question is that there are also data on the blood measures from before the surgery so it would be reasonable to also adjust for those differences within the different conditions, correct? Could I do this in the same model? And another questions which comes to mind in this context is whether it would be reasonable to have some multilevel analysis (within and between) effects?

Help is highly appreciated!

$\endgroup$

1 Answer 1

1
$\begingroup$

Yes, you can do all of those things.

The first model would be: $$ \operatorname{blood\_measure}_i=\beta_0+\beta_1\operatorname{treatment_i}+\beta_2\operatorname{gender_i} $$

In R:

lm(blood_measure ~ treatment + gender, data)

The second model would simply be: $$ \operatorname{blood\_measure}_i=\beta_0+\beta_1\operatorname{treatment_i}+\beta_2\operatorname{gender_i} + \beta_3\operatorname{pre\_test\_result} $$

In R:

lm(blood_measure ~ treatment + gender + pre_test_result, data)

Note that in R you don't need to dummify categorical variables. As you see in the formulas above, you can simply pass your variables as factors and R will take care of it.

Finally, if you had reasons to believe that there might be an interaction between, say, treatment and gender (e.g. the response to treatment A is different for males and females), then you could add an interaction in the following way:

lm(blood_measure ~ treatment + gender + treatment:gender, data)

Or equivalently:

lm(blood_measure ~ treatment * gender, data)
$\endgroup$
4
  • $\begingroup$ Great, thank you so much! And e.g. in the first model this would count as "adjusting for gender" since it is "just" included as another predictor. Or will this only have an effect on the interpretation of the model and how I need to report it? $\endgroup$
    – Wupppa
    Commented Sep 24, 2021 at 13:34
  • $\begingroup$ @Wupppa yes, by including gender in the model you are "adjusting" or "controlling" for it. When it comes to interpretation, you may say something like: "on average, treatment A patients showed higher levels of the blood measure, controlling for gender". $\endgroup$
    – Adrià Luz
    Commented Sep 24, 2021 at 14:04
  • $\begingroup$ Another question, I hope I don't bother you. Would it be more reasonable to run a ANOVA if I have only categorial independent variables? Thank you! $\endgroup$
    – Wupppa
    Commented Sep 24, 2021 at 15:02
  • $\begingroup$ @Wupppa ANOVA and the linear regression models shown above are equivalent. $\endgroup$
    – Adrià Luz
    Commented Sep 24, 2021 at 15:35

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.