brms's lf(): one or more two-sided formulas for distributional or
nonlinear parameters, added to a bf() with +. It is sugar for
passing the same formulas to bf() directly, and is useful when the
parameter formulas are built somewhere else than the response
formula.
Arguments
- ...
Two-sided formulas naming the parameter on the left, e.g.
sigma ~ xor (withnl = TRUEon thebf()) a nonlinear parameter's formulaa ~ 1 + (1 | g), or one-sided formulas named by their parameter,sigma = ~ x. As in brms,lf()also takes whatbf()takes besides formulas: a parameter fixed to a constant,sigma = 2, or equated to another,sigma1 = "sigma2".- resp
The response the formulas belong to, when the
lf()is added to a multivariate formula.NULL(the default) adds them to thebf()on the left of the+, which must then be a single formula.- center
FALSEmakes the intercept of each of these formulas an ordinary coefficient, class"b"with coef"Intercept", instead of brms's class"Intercept": the same as0 + Interceptin the formula. Seebf().NULL, the default, leaves the intercept as class"Intercept".- cmc
FALSEturns off cell-mean coding in each of these formulas: without an intercept, a factor keeps its treatment contrasts, in the population-level and the group-level terms. Seebf().NULL, the default, keeps R's cell-mean coding.
Value
An object of class frmtmb_lf, to be added to a bf().
Details
bf(y ~ x) + lf(sigma ~ z) and bf(y ~ x, sigma ~ z) give the same
model. In a multivariate model, add an lf() to the bf() of the
response it belongs to, or name that response with resp =:
bf(y1 ~ x) + bf(y2 ~ x) + bf(y3 ~ x) + lf(sigma ~ z, resp = "y3").
Examples
# the two spellings are the same model
bf(y ~ x) + lf(sigma ~ z)
#> y ~ x
#> sigma ~ z
bf(y ~ x, sigma ~ z)
#> y ~ x
#> sigma ~ z
# nonlinear parameter formulas can arrive the same way
bf(y ~ a * exp(-b * x), a ~ 1, nl = TRUE) + lf(b ~ 1 + (1 | g))
#> y ~ a * exp(-b * x) (nonlinear)
#> a ~ 1
#> b ~ 1 + (1 | g)
# in a multivariate formula, resp = says which response it modifies
bf(y1 ~ x) + bf(y2 ~ x) + bf(y3 ~ x) + lf(sigma ~ z, resp = "y3")
#> y1 ~ x
#> y2 ~ x
#> y3 ~ x
#> sigma ~ z
#> rescor: FALSE