I believe the same syntax is used with the lme4 package as rstanarm, but I'm having trouble figuring out exactly what the differences are between the different options when fitting a grouped random effect on the slope.
Say we have a model with formula
response ~ fixed + (1 + rand1 | group)
What exactly is the differences in assumptions between that and these three other options:
1:
response ~ fixed + (0 + rand1 | group)
2:
response ~ fixed + (-1 + rand1 | group)
3:
response ~ fixed + (1 + rand1 || group)
I know that here one answer mentioned that the || formula assumes the covariance matrix among the deviations in the parameters by level of group is diagonal, but it's not clear to me how assumptions about the covariance matrix change between that and say the 1st and 2nd options.
Options 1 and 2 should give identical results: from
?formula(it is true, but not obvious, that this specification applies here).
if
rand1is categorical (i.e., a factor)Because
(rand1|group)and (e.g.)(0+rand1|group)both specify a general positive-definite covariance matrix ("unstructured"), you should get the same overall model fit in both cases (barring effects of the prior). The difference is in the meaning of the individual elements of the covariance matrix. With(rand1|group), lme4 sets up the standard treatment contrasts, so that the first row/column of the covariance matrix corresponds to the variance of the intercept (value of the baseline level) across groups; subsequent rows/columns correspond to variances in differences between the baseline level and levels 2, 3, ... n. With(0+rand1|group), the rows/columns are variances of the measured value in the corresponding group.if
rand1is continuousThis case works differently; here
rand1 | groupgives a random effect of length 2 ({intercept, slope}) with a 2x2 covariance matrix; suppressing the intercept with+0or-1will produce a scalar-random-effect model that assumes the intercept is constant across groups but the slope varies (i.e., a single parameter estimate describing the among-group variance in the slope).