# Can a variable be both random and fixed effect at the same time in a mixed effect model?

I am doing an analysis with 2 groups of patients (control and disease) whose blood pressures have been measured continuously for 24 hours. My first goal is to test the effect of GROUP on BP. In the beginning, I built the mixed effect model with TIME as random effect variable and group as fixed effect model. The model I used is listed below:

mod <- lme(BP ~ factor(GROUP), random=~1+ TIME| ID, data=gdata)


However, the experimenter wants to know the effects of GROUP on the slope of blood pressure changing per hour. In another words, we need to have blood pressure slope, which is the change of blood pressure by time, as response variable in the model. And I generated another model as bellow:

mod <- lme(BP ~ factor(GROUP)*TIME, random=~1+ TIME| ID , data=gdata)


However, in the new model, the time works both as random effect variable and fixed effect variable. I am not sure if this is allowed in the mixed effect model.

## 1 Answer

Absolutely. In fact, the vast majority of the time, you absolutely should include a fixed effect.

The reason for this is that random effects are restrained to $\sum \gamma = 0$, or always centered around 0. Thus, the random effect is the individual's estimated deviation from the group average for that individual. By leaving out the fixed effect, you would imply that the average effect of time must be 0.

• thanks for the explanation! this makes a lot of sense! (I was actually wondering if using a predictor only as a random effect was ok). – theforestecologist May 4 '18 at 20:57