1
$\begingroup$

I have the following model:

lifecomp_pacc3_apoe <- lmer(z_pacc3_ds ~ 
  ls_composite*APOE_score*AgeAtVisit + CESDTotal + famhist + 
  ls_composite*I(AgeAtVisit^2)*APOE_score + BMI +  
  std_PRS_Kunkle*AgeAtVisit + std_PRS_Kunkle*I(AgeAtVisit^2)  + 
  gender + EdYears_Coded_Max20 + VisNo + X1+X2+X3+X4+X5 +
  (1 |family/DBID), 
  data = WRAP_all, REML = F)

My sample includes 6 waves data for 350 individuals (~2100 person-year obs). The predictor of interest is ls_composite, which is a composite score that only takes integer value from 1 to 5 (e.g., 1,2,3,4,5).

My question is, given my sample and model is determined, should I treat ls_composite as continuous variable or categorical variable? In theory both are ok, but my collaborators prefer treating ls_composite as categorical. I personally prefer treating it as continuous because I am worrying about the difficulties in statistical modeling. Are there any other reason treating ls_composite as continuous is better than categorical? Will treat it as a categorical variable will cause power issue in mixed model?

$\endgroup$
2
  • $\begingroup$ A power issue is all about how much data you have, how much noise there is, and how strong of an effect there is. We can't tell you if you're having power issues. Fit the model both ways and see how it looks. And look at the effect estimates of the categorical version, and see if you'd be comfortably assuming that the difference between 1 and 2 is the same as the differences between 2 and 3, 3 and 4, and 4 and 5---which is what treating it as a continuous variables assumes. $\endgroup$ Commented Apr 13, 2022 at 19:40
  • $\begingroup$ @GregorThomas Hi Gregor, thanks for your reply. For the power issue, my concern is if I treat ls_composite as categorical, there would be around 50 predictors in my model (caused by multiple interaction terms, only 30 predictors if treat it as continuous). In linear regression, there is a rule of thumb that 10 samples are needed for each additional predictor. Will this rule also apply to the lmer? I think 50 predictors are too much to fit my model with my current sample size. $\endgroup$
    – zjppdozen
    Commented Apr 13, 2022 at 19:54

1 Answer 1

2
$\begingroup$

This is a judgment call. Treating ls_composite as continuous is a special case (nested model) of the model where you treat it as categorical (i.e., if the differences between subsequent pairs happen to be identical). If the pattern is approximately linear then you will be better off treating ls_composite as continuous; otherwise you will be better off with a categorical model.

My guess is that you will lose power/predictive accuracy either way if you "guess wrong":

  • if the pattern really is approximately linear but you allow the flexibility of a categorical model, then you will lose power/run the risk of overfitting/increase variance because you have a more complex model than necessary.
  • if the pattern is not approximately linear then you will lose power/run the risk of underfitting/increase bias because you have a less complex model than necessary.

There are a variety of ways of attempting to split the difference, but unless you're very careful and do something sophisticated, most of them will constitute "data snooping" and will mess up your statistical inference, e.g.:

  • you could fit the linear/continuous-parameter version and see if there are worrying patterns/indications of non-linearity in the residuals;
  • you could fit the model with polynomial contrasts (i.e., make your predictor into an ordered factor in R), which will fit parameters L (linear), Q (quadratic), C (cubic), .4 (quartic). If the parameters beyond L are small/noisy, that suggests that you could have gotten away with the linear model in the first place ...

If you want to split the difference in an a priori way (i.e. decide in advance that you want to use somewhere between 1 and 4 degrees of freedom (× all the interaction stuff), you could use a spline model with a specified number of degrees of freedom, or a polynomial (e.g. compute the polynomial contrasts as above and then throw away a few of the highest-order terms).

Another approach is to use penalized regression splines (e.g. as implemented in the mgcv or gamm4 packages) to automatically choose the degree of complexity. (To be honest I'm not sure how this automatic selection fits in with "non-snoopy" inference ...) You will have to specifically tell mgcv to limit the maximum complexity of the spline (it is generally used for continuous variables with much finer sampling).

While it doesn't cover mixed models specifically, Chapter 3 of Frank Harrell's Regression Modeling Strategies gives very specific advice about how to 'spend degrees of freedom' (i.e. decide on model complexity), with some fairly elegant and rigorous strategies. Well worth buying or borrowing from a library ...

Unfortunately, because Harrell doesn't discuss mixed/multilevel models, he doesn't say much about how the "10-20 observations per parameter" rules of thumb generalize to the multilevel case. As a very rough guide, if a predictor varies within levels of the grouping variable then you can say $n \approx$ the number of individual observations; if it varies only between groups then $n \approx$ the number of groups. (If anyone has a good reference for this area I would love to hear about it ...)

$\endgroup$

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.