I don't think including the total number of items as a random effect makes sense. The approach where you divide by the total number is equivalent to estimating a binomial model. So:
glmer(Outcome/nofitems ~ time +(1|id),data,family='binomial',weights=nofitems)
is equivalent to:
glmer(cbind(Outcome,nofitems - Outcome) ~ time +(1|id),data,family='binomial')
This is the model talked about in Britt et al. (2017), The analysis of bounded count data in criminology. In reference to the comment on your post, the reason count models are not appropriate is that you have an upper bound due to the nature of the instrument. If you only have 22 deviant questions you can never have a person with 23 or more counts of deviance within any time frame. Poisson models will often have a significant amount of predicted mass above the natural cut-off, so are from the start not a very good fit to the data. The binomial model approach implicitly takes into account the differing number of items for folks, so no need to additionally include it as a covariate.
Now, this isn't my area of expertise, but I'm surprised folks think the binomial models are reasonable. The binomial model produces equivalent results to predicting the individual delinquency items, but forcing them to have the same probability of occurring. For risky behaviors, every dataset I've seen has some that are more common (e.g. smoking cigarrettes, drinking alcohol) versus behaviors that are much rarer (e.g. using heroin). The binomial model forces these to all have the same underlying predicted probability per your person covariates in the sample.
It seems to me a better approach is to let those different risk factors have a varying term to account for the different prevalence of the items. (This is very similar to item response theory -- some questions are harder and some are easier, see Osgood et al. (2002), Analyzing multiple-item measures of crime and deviance: Item response theory scaling, for another deviant behavior example.)
So here is some prototype R code, pretend your original deviance measures are in variables D1
, D2
, D3
, etc. Here I am suggesting you reshape your data from wide to long format:
dVars <- c("D1","D2","D3")
long_data <- reshape(data, varying = dVars, v.names = "DelinQ", timevar = "OutcomeI", times = dVars, direction = "long")
Then the two models below are equivalent.
glmer(cbind(Outcome,nofitems - Outcome) ~ time +(1|id),data,family='binomial') #Model with the wide data
glmer(OutcomeI ~ time + (1|id),long_data,family='binomial') #Model with the long data
But I think it probably makes sense to let the individual items have their own baseline rates of probability of occurring. You can either do this via random effects or fixed effects. (With only 22 items, which is alot, it is still hard to estimate the random effect distribution.)
glmer(Delin ~ time + DelinQ + (1|id),long_data,family='binomial') #Fixed effect for question
glmer(Delin ~ time + (1|DelinQ) + (1|id),long_data,family='binomial') #Random effect for question
This approach generalizes to items missing for some folks, same as the aggregated binomial approach.
For those who use Stata I've generated a simulation for this exact situation and illustrated the different models discussed here.