Main equation and hm() blocks: Using
fix()
Use the fix() helper inside vars() to hold
a coefficient at a specified value rather than estimating it. This works
both in the main equation and in hm() blocks.
Main equation:
# Fix the coefficient of 'exposure' to 1 (i.e., use as an offset)
m <- bml(
y ~ 1 + fix(exposure, 1) + x1 + x2,
family = "Gaussian",
data = dat
)This is equivalent to adding exposure as a predictor but
constraining its coefficient to 1 instead of estimating it. This is
useful for offsets or when prior theory dictates a specific coefficient
value.
In hm() blocks:
m <- bml(
y ~ 1 + x1 +
mm(id = id(pid, gid), fn = fn(w ~ 1/n), RE = TRUE) +
hm(id = id(cid), vars = vars(fix(investiture, 0.5) + gdp), type = "FE"),
family = "Gaussian",
data = coalgov
)In mm() blocks:
m <- bml(
Surv(dur_wkb, event_wkb) ~ 1 + majority +
mm(
id = id(pid, gid),
vars = vars(fix(cohesion, 1) + finance),
fn = fn(w ~ 1/n, c = TRUE),
RE = TRUE
),
family = "Weibull",
data = coalgov
)Here, the coefficient of cohesion is fixed at 1 while
finance is freely estimated.