lnccbrown / HSSM

Development of HSSM package
Other
71 stars 10 forks source link

Bug when specifying uncorrelated random effects #405

Closed gingjehli closed 1 month ago

gingjehli commented 2 months ago

Let's assume I want to fit a hierarchical model with three layers (trials that are nested in participants which are nested in groups). Let's further assume that the random effects (intercepts and coefficients) are:

Following STAN/lme4 notation, I would define the model as follows: v ~ 1 + group + (zSTN + zGPe)*group + (1 + zSTN + zGPe | participant_id) + (1 + zSTN + zGPe | group/participant_id) + (1 + zSTN + zGPe || group)

Though, it looks like that the standard notation of double bars "||" is not recognized in HSSM. Double bars typically indicate that I don't want to estimate correlations between intercepts and slopes. The above model would be a simplification of a full hierarchical model specified as follows (for which I would need to estimate the full correlation matrix): v ~ 1 + group + (zSTN + zGPe)*group + (1 + zSTN + zGPe | group/participant_id)

We might want to add somewhere that the STAN/lme4 notation of double bars is not supported for now (but the notation of nesting "/" is supported 👍 ).

AlexanderFengler commented 2 months ago

Hey @gingjehli,

it looks like the double bar notation is a shortcut to specify via otherwise longer syntax. Maybe you can get mileage out of https://stats.stackexchange.com/questions/134184/lme4-bar-specification-for-random-effects to at least confirm that you can in principle specify the desired model.

If not, it I will push harder on feature requests for backend packages, if yes, then we can leave it at a note that double-bars don't work and one needs to specify the desired behavior explicitly from lower level components.