Specifies a multiple-membership level where group-level units (e.g., occupations) are composed of member-level units (e.g., tasks). Each block aggregates the weighted member records into one or more group-level features whose coefficients are estimated by the main model. The components map onto the framework's notation \(\theta^{micro,f}(M_{it})\):
id = id(mmid, mainid): the membership structure \(S_{it}\)vars = vars(x): the member attributes \(x_{kt}\)w = w(~ ...): the weights \(w_{ikt}\) (who counts)fn = fn("..."): the aggregation function \(f\) (how contributions combine);fn("sum")is the additive case, other types are emergent features (variance, concentration, thresholds, ...)RE = re(...): member random effects, aggregated by the weights (\(\sum_k w_{ikt} u_{0k}\), plus random slopes viare(1 + x))name: block name for referencing the feature in main-formula interactions (auto-generated when omitted)
Arguments
- id
An
idobject:id(mmid, mainid).- vars
A
varsobject with member attributes, orNULLfor weights-only blocks (RE-only, orfn("hhi")-family).- w
A
wobject specifying the weights. Default:w(~ 1/n, scale = TRUE)(equal weights).- fn
A
fnobject selecting the aggregation function. Default:fn("sum")(the additive weighted mean).- RE
Random effects:
TRUE(shorthand forre(1)), areobject, orNULL/FALSEfor none. Only available withfn("sum"): member random effects do not compose with dispersion-type features.- FE
Fixed effects: a
feobject, orNULL. Mutually exclusive withRE. With many members this is weakly identified — preferRE(partial pooling) at the member level.- name
Optional block name (unquoted or string) used to reference the block's feature in main-formula interactions (e.g.
Ax:education). Auto-generated from the feature when omitted (e.g.A_x,V_x). Must not collide with a data column.- ...
Not used; catches removed arguments (
c =, andar =, which moved into the effects grammar:RE = re(1, ar = TRUE)) with a migration message.
Details
One mechanism. Every block emits group-level feature(s) whose
coefficients are main-model coefficients (class "b", labeled by the
feature name, e.g. A_x). fn("sum") is the additive case
\(\theta = \beta A_x + \sum_k w_k u_{0k}\): the feature \(A_x\) plus the
optional RE. There is no separate "sum mode".
Multiple blocks can be combined with + to stack features
(mean + variance + concentration, ...). RE can be specified for one
block per member-id group.
References
Rosche, B. (2026). A Multilevel Model for Coalition Governments: Uncovering Party-Level Dependencies Within and Between Governments. Political Analysis.
Examples
if (FALSE) { # \dontrun{
# Additive aggregation (weighted mean effect)
mm(id = id(task, occ), vars = vars(x), w = w(~ importance, scale = TRUE), fn = fn("sum"))
# With member random intercepts
mm(id = id(task, occ), vars = vars(x), w = w(~ 1/n), fn = fn("sum"), RE = TRUE)
# Random intercept + slope (residual effect heterogeneity)
mm(id = id(task, occ), vars = vars(x), w = w(~ 1/n), fn = fn("sum"), RE = re(1 + x))
# Emergent features
mm(id = id(task, occ), vars = vars(x), w = w(~ 1/n), fn = fn("var"))
mm(id = id(task, occ), w = w(~ importance), fn = fn("hhi"))
mm(id = id(task, occ), vars = vars(x), w = w(~ 1/n),
fn = fn("threshold", c = est(), kappa = 10))
mm(id = id(task, occ), vars = vars(x), w = w(~ 1/n), fn = fn("smax", kappa = est()))
# Named block, referenced in a cross-level interaction
bml(Y ~ education + Ax:education +
mm(name = Ax, id = id(task, occ), vars = vars(x), w = w(~ 1/n), fn = fn("sum")),
data = dat)
} # }