I have developmental data collected across several grades (1-6), where each child in each grade is measured many times. I would like to be able to assess whether there are any linear or non-linear trends in the response variable across grade. Does it make sense to run a first lmer treating grade as continuous, obtain the residuals, then run a second lmer treating grade as a factor? That is:
fit1 = lmer(
formula = response ~ (1|child)+grade_as_numeric
, data = my_data
, family = gaussian
)
my_data$resid = residuals(fit1)
fit2 = lmer(
formula = resid ~ (1|child)+grade_as_factor
, data = my_data
, family = gaussian
)
As I understand it, fit1 will tell me if there are any linear trends in the data, while fit2 will tell me if there are any non-linear trends in the data in addition to the linear trends obtained in fit1.
If this is sensible, how might I apply it to a second binomial response variable given that the residuals from a binomial model are not 0/1?