Helper function used within mm and hm to specify
which variables should be included at each level of the model. Supports both
free variables (with coefficients to be estimated) and fixed variables (with
coefficients held constant using fix).
Arguments
- ...
Unquoted variable names from your data, combined using
+(formula-style). Supports:Simple variables:
vars(x + y)Interactions:
vars(x * y)orvars(x:y)Transformations:
vars(I(x^2))orvars(I(x + y))Fixed coefficients:
vars(fix(x, 1.0) + y)
Note: Numeric literals like
1,0, or-1are ignored (no intercept support in mm/hm blocks).
Value
A bml_vars object containing:
formula: Formula object for use withmodel.matrix()free: Character vector of base variable namesfixed: List of variables with fixed coefficients (if any)
Returns NULL if no variables are specified.
Examples
if (FALSE) { # \dontrun{
# Simple variable specification (formula-style with +)
vars(income + education)
# Single variable
vars(income)
# Interactions
vars(income * education) # expands to income + education + income:education
vars(income:education) # interaction only
# Transformations
vars(I(income^2)) # squared term
vars(income + I(income^2)) # linear and squared
# Mix free and fixed variables
vars(fix(exposure, 1.0) + income + education)
# Use in mm() specification
mm(
id = id(pid, gid),
vars = vars(rile + ipd),
fn = fn(w ~ 1/n),
RE = FALSE
)
} # }