randomeffects {bmscstan} | R Documentation |
Random Effects specification on Bayesian Multilevel Single Case models using 'Stan'
Description
The BMSC function allows the flexibility of multilevel (generalised) linear models on single case analysis.
In particular, it is possible to specify the population-level (a.k.a. mixed effects) and the group-level (a.k.a. random effects) coefficients.
The specification of the population- and group-level effects can be done using the well-known lme4 notation with specific limitations:
it is no possible to estimate uncorrelated group-level effects
it is no possible to directly estimate nested effects. You need to use a trick that is specified in the Details section.
Details
lmer formulation | BMSC availability |
(1 | grouping_factor) | Yes |
(1 + slope | grouping_factor) | Yes |
(0 + slope | grouping_factor) | No |
(1 | grouping_factor1 : grouping_factor2) | Yes[^1] |
(1 | grouping_factor1 / grouping_factor2) | Yes[^2] |
[^1]: The BMSC function dose not allow the use of the interaction symbol ":", but this problem is easily solved by creating a new variable within your dataframe given by the interaction of the two factors.
[^2]: The (1 | grouping_factor1 / grouping_factor2)
syntax is the
equivalent of the explicit version
(1 \| grouping_factor1:grouping_factor2) + (1 | grouping_factor1)
.
Therefore, you need to create a new grouping factor representing the
interaction between grouping_factor1
and grouping_factor2
,
and use this in the explicit version
(1 | grouping_factor_interaction) + (1 | grouping_factor1)
.