Linear and Non-linear formulas in brms

Helper functions to specify linear and non-linear formulas for use with brmsformula.

nlf(formula, ..., flist = NULL, dpar = NULL)

lf(..., flist = NULL, dpar = NULL)

set_nl(nl = TRUE, dpar = NULL)


Non-linear formula for a distributional parameter. The name of the distributional parameter can either be specified on the left-hand side of formula or via argument dpar.


Additional formula objects to specify predictors of non-linear and distributional parameters. Formulas can either be named directly or contain names on their left-hand side. The following are distributional parameters of specific families (all other parameters are treated as non-linear parameters): sigma (residual standard deviation or scale of the gaussian, student, lognormal exgaussian, and asym_laplace families); shape (shape parameter of the Gamma, weibull, negbinomial, and related zero-inflated / hurdle families); nu (degrees of freedom parameter of the student family); phi (precision parameter of the beta and zero_inflated_beta families); kappa (precision parameter of the von_mises family); beta (mean parameter of the exponential componenent of the exgaussian family); quantile (quantile parameter of the asym_laplace family); zi (zero-inflation probability); hu (hurdle probability); zoi (zero-one-inflation probability); coi (conditional one-inflation probability); disc (discrimination) for ordinal models; bs, ndt, and bias (boundary separation, non-decision time, and initial bias of the wiener diffusion model). All distributional parameters are modeled on the log or logit scale to ensure correct definition intervals after transformation. See 'Details' for more explanation.


Optional list of formulas, which are treated in the same way as formulas passed via the ... argument.


Optional character string specifying the distributional parameter to which the formulas passed via ... and flist belong.


Logical; Indicates whether formula should be treated as specifying a non-linear model. By default, formula is treated as an ordinary linear model formula.


For lf and nlf a list that can be passed to brmsformula or added to an existing brmsformula object. For set_nl a list that can be added to an existing brmsformula object.

See Also


  • brmsformula-helpers
  • nlf
  • bf-helpers
  • lf
  • set_nl
  • lf
  • set_nl
# add more formulas to the model
bf(y ~ 1) + 
  nlf(sigma ~ a * exp(b * x), a ~ x) + 
  lf(b ~ z + (1|g), dpar = "sigma") +

# specify 'nl' later on
bf(y ~ a * inv_logit(x * b)) +
  lf(a + b ~ z) +

# }
Documentation reproduced from package brms, version 1.9.0, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.