formula
Classes¶
Functions¶
bf(formula, **formula_args)
¶
Set up a model formula for brms package.
Allows defining (potentially non-linear) additive multilevel models for all parameters of the assumed response distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
formula
|
str
|
brms formula specification, e.g., "y ~ x + (1|group)" |
required |
**formula_args
|
dict
|
Additional brms::brmsformula() arguments:
|
{}
|
Returns:
| Type | Description |
|---|---|
FormulaResult
|
Object with .r (R brmsformula object) and .dict (Python dict) attributes |
See Also
brms::brmsformula : R documentation https://paulbuerkner.com/brms/reference/brmsformula.html fit : Fit model using formula
Examples:
Basic formula:
With QR decomposition for numerical stability:
Multivariate formula:
lf(*formulas, flist=None, dpar=None, resp=None, center=None, cmc=None, sparse=None, decomp=None)
¶
Specify linear formulas for distributional / non-linear parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*formulas
|
str or FormulaResult
|
One or more formulas (e.g. "sigma ~ x", "nu ~ z"). |
()
|
flist
|
list
|
Additional formulas passed as a list. |
None
|
dpar
|
str
|
Name of the distributional parameter (e.g. "sigma"). |
None
|
resp
|
str
|
Response name in multivariate models. |
None
|
center
|
optional
|
Passed through to brms::lf(). |
None
|
cmc
|
optional
|
Passed through to brms::lf(). |
None
|
sparse
|
optional
|
Passed through to brms::lf(). |
None
|
decomp
|
optional
|
Passed through to brms::lf(). |
None
|
Returns:
| Type | Description |
|---|---|
FormulaResult
|
Object that can be added to a bf() formula via +. |
Examples:
nlf(formula, *extra, flist=None, dpar=None, resp=None, loop=None)
¶
Specify non-linear formulas for distributional parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
formula
|
str
|
Non-linear formula, e.g. "sigma ~ a * exp(b * x)". |
required |
*extra
|
str or FormulaResult
|
Additional named parameters or formulas (rarely needed here; typically you use lf() for those). |
()
|
flist
|
list
|
Additional formulas passed as a list. |
None
|
dpar
|
str
|
Name of the distributional parameter. |
None
|
resp
|
str
|
Response name in multivariate models. |
None
|
loop
|
bool
|
Whether to compute inside a loop (brms::nlf(loop=...)). |
None
|
Returns:
| Type | Description |
|---|---|
FormulaResult
|
Object that can be added to a bf() formula via +. |
Examples:
acformula(autocor, resp=None)
¶
Specify autocorrelation terms to add to a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
autocor
|
str
|
One-sided formula with autocorrelation terms, e.g. "~ arma(p = 1, q = 1)". |
required |
resp
|
str
|
Response name in multivariate models. |
None
|
Returns:
| Type | Description |
|---|---|
FormulaResult
|
Object that can be added to a bf() formula via +. |
Examples:
set_rescor(rescor=True)
¶
Control residual correlations in multivariate models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rescor
|
bool
|
Whether to model residual correlations. |
True
|
Returns:
| Type | Description |
|---|---|
FormulaResult
|
Object that can be added to a multivariate formula via +. |
Examples:
set_mecor(mecor=True)
¶
Control correlations between latent me-terms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mecor
|
bool
|
Whether to model correlations between me() latent variables. |
True
|
Returns:
| Type | Description |
|---|---|
FormulaResult
|
Object that can be added to a formula via +. |
Examples:
set_nl(dpar=None, resp=None)
¶
Mark a formula as non-linear (or parts of it).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dpar
|
str
|
Distributional parameter name (if only part of the model is non-linear). |
None
|
resp
|
str
|
Response name in multivariate models. |
None
|
Returns:
| Type | Description |
|---|---|
FormulaResult
|
Object that can be added to a formula via +. |
Examples: