# The difference between control variable and a random effect?

Say I want to model the effect of the expression of gene A on the size of the tumor and say I have samples from several cancer types. On one hand, it seems reasonable to "control for" the cancer type so if different cancer types tends to have different expression of gene A it won't affect the effect on the size contributed by the expression levels (which is what I'm interested in). So that means to add the cancer type as a variable to the model (say: y = b0 + b1 (expression) + b2 (cancer type)).

However, it also seems reasonable to use the type as a random effect, as we "picked" the cancer types randomly (we used what was available, and we are not interested in what is the effect of each type specifically). Which one is the correct way? And why?

I'm not sure that there is a "correct" way "to model the effect of the expression of gene A on the size of the tumor," as tumor size typically has a lot more to do with the ability to detect a tumor clinically than with gene expression per se. Furthermore, the ability to detect a tumor clinically at a given size has mostly to do with anatomy. It's hard to miss a large tumor on the skin or in the mouth; it's hard to find many tumor types in the abdominal cavity until they are so large as to affect major bodily functions.

Putting that aside for now, either way of dealing with a "control variable" in general might be OK. The way you set up your model:

$$y = \beta_0 + \beta_1 \text{geneA} + \beta_2 \text{cancerType}$$

effectively allows each cancerType to have its own intercept independently of the others. In usual modeling, the intercept $$\beta_0$$ would be the tumor size with geneA expression of 0 for one reference cancerType, and $$\beta_2$$ would be a collection of coefficients representing the differences of each other cancerType from that reference intercept value. That's typically called "fixed effect" modeling.

Treating cancerType as a "random effect" also allows each cancerType to have its own intercept, but the collection of those intercepts is constrained to have a normal distribution with 0 mean. A big advantage is that you only have to estimate an overall intercept and the variance of that normal distribution, instead of separate regression coefficients for each cancerType. That also helps share information among the cancerTypes and can overcome problems when there are differences in case numbers among them. But it's not always a good choice if there is just a handful of cancerType values.

You can find much discussion of pros and cons of these approaches on this site. See this thread for an overview, and this thread for further guidance on choosing. Those link to many other related threads. Note that the terminology can be confusing; just what is meant by "fixed effects" and "random effects" can differ depending on author and context.

Finally, your writing the equation out is an important first step. Think through its implications to see if that captures what you are trying to model. The way you wrote it, the extra influence of geneA on tumor size y would be the same for each cancerType once you take the baseline differences among cancerTypes into account. Is that what you want? Or do you want the influence of geneA expression on tumor size to differ among cancerTypes? If so, you need to incorporate an interaction between geneA expression and cancerType in your model. That could in principle be handled with cancerType either as a "fixed" or a "random" effect, but then the advantage of the lower number of coefficients to estimate with cancerType treated as a random effect would tend to become overwhelming.

• Thanks! The truth is that the tumor size was an example for a general question and your answer was most helpful, thanks again.
– LLLL
Oct 13, 2021 at 13:47