I have a study wherein we enrolled about 40 subjects and from each subject we have collected repeated images of burns on subject's body. Approx. 2 burn locations on the body are selected initially and then repeatedly measured (imaged). Therefore, I have repeated measures of burn areas that are nested within a subject.
From within each image there are $TP$ correct results from $n=TP+FN$ trials, so I have an aggregated binomial likelihood.
I would like to model the intercept as burns nested in subjects, while modeling a random slope for the repeated measure (time) for each burn area.
From this post, I believe this is the correct model definition in lme4,
se.lme4_1 <- glmer(cbind(TP, FN) ~ 1 + time_delta_days + (1|subject_id:burn_id) + (1+time_delta_days|burn_id),
data = d,
family = binomial(link = "logit"))
the question I have is how is this model formula represented?
Here is my initial try:
$$TP \sim Binomial(n_i, p_i)$$ $$logit(p_i) = \alpha + \alpha_{subject[i]} + \alpha_{burn[i]} + \beta_{burn[i]}*time$$ $$\alpha_{subject[i]} \sim Normal(0, \sigma_{subject})$$ $$\sigma_{subject} \sim HalfCauchy(0,1)$$ $$\begin{bmatrix}\alpha_{burn}\\\beta_{burn}\end{bmatrix} \sim MVNormal(\begin{bmatrix}intercept_{burn}\\slope_{burn}\end{bmatrix},S)$$ $$S = \begin{pmatrix} \sigma_{slope_{burn}} & 0 \\ 0 & \sigma_{intercept_{burn}} \end{pmatrix}*R* \begin{pmatrix} \sigma_{slope_{burn}} & 0 \\ 0 & \sigma_{intercept_{burn}} \end{pmatrix}$$
$$intercept_{burn} \sim Normal(0, 10)$$ $$slope_{burn} \sim Normal(0, 10)$$
$$\sigma_{slope_{burn}} \sim HalfCauchy(0,1)$$ $$\sigma_{intercept_{burn}} \sim HalfCauchy(0,1)$$
$$R \sim LKJcorr(2)$$
I think the part of the model that is not making sense to me is how to deal with the nesting (i.e., the subject[i]).
Thanks in advance!