# Random effects for a continuous variable in a mixed Effects Models

I intend to fit a mixed effects model and all of my covariates are continuous. One of the covariates, say x2, is time (from enrollment) when the treatment was initiated and it is thought (by clinician) to dictate the response to treatment and is different for different individuals. I am ok with inclusion of the fixed effects. How do we include x2 in the model. My model is of the form fit=lmer(y~(x2|id) + x1 + x2^2 + x2^3 + x3 + x4 + x5 + x6)

As you may notice, x2 has quadratic parts that are left as fixed effects. Is this statistically sound?

g

Without knowing anything about any other variables, your model is almost there, but you should include x2 among the fixed effects. i.e.

fit<-lmer(y~x1+x2+x2.squared+x2.cubed+x4+x5+x6+(x2|id))


However, the random time by id interaction means everyone has a random slope at time 0, but have identical quadratic and cubic trends. Unless there is an element to your data that prevents this, you probably want to include random quadratic and cubic trends.

fit<-lmer(y~x1+x2+x2.squared+x2.cubed+x4+x5+x6+(x2+x2.squared+x2.cubed|id))


The model is harder to fit (hopefully it converges), but if everyone truly has a different response to x2, it likely won't only occur on 1 of its components.

• (+1). What about using orthogonal polynomials in such a setting? Apr 17, 2015 at 21:37
• Well the variable is time, which I assume is continuous, and I assume you are referring to contrast codes for categorical variables, so I'm not sure how they apply. The other problem is the sparse description of the "setting" by OP. Apr 18, 2015 at 22:29