Function to set up a multimembership grouping term in brms. The function does not evaluate its arguments  it exists purely to help set up a model with grouping terms.
mm( ..., weights = NULL, scale = TRUE, by = NULL, cor = TRUE, id = NA, cov = NULL, dist = "gaussian" )
...  One or more terms containing grouping factors. 

weights  A matrix specifying the weights of each member.
It should have as many columns as grouping terms specified in 
scale  Logical; if 
by  An optional factor matrix, specifying subpopulations of the
groups. It should have as many columns as grouping terms specified in

cor  Logical. If 
id  Optional character string. All grouplevel terms across the model
with the same 
cov  An optional matrix which is proportional to the withongroup
covariance matrix of the grouplevel effects. All levels of the grouping
factor should appear as rownames of the corresponding matrix. This argument
can be used, among others, to model pedigrees and phylogenetic effects. See

dist  Name of the distribution of the grouplevel effects.
Currently 
if (FALSE) { # simulate some data dat < data.frame( y = rnorm(100), x1 = rnorm(100), x2 = rnorm(100), g1 = sample(1:10, 100, TRUE), g2 = sample(1:10, 100, TRUE) ) # multimembership model with two members per group and equal weights fit1 < brm(y ~ x1 + (1mm(g1, g2)), data = dat) summary(fit1) # weight the first member two times for than the second member dat$w1 < rep(2, 100) dat$w2 < rep(1, 100) fit2 < brm(y ~ x1 + (1mm(g1, g2, weights = cbind(w1, w2))), data = dat) summary(fit2) # multimembership model with level specific covariate values dat$xc < (dat$x1 + dat$x2) / 2 fit3 < brm(y ~ xc + (1 + mmc(x1, x2)  mm(g1, g2)), data = dat) summary(fit3) }