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?

Your help will be appreciated.



1 Answer 1


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


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.


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.

  • $\begingroup$ (+1). What about using orthogonal polynomials in such a setting? $\endgroup$
    – Michael M
    Apr 17, 2015 at 21:37
  • $\begingroup$ 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. $\endgroup$
    – le_andrew
    Apr 18, 2015 at 22:29

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.