-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrmsformula-helpers.Rmd
64 lines (60 loc) · 3.84 KB
/
brmsformula-helpers.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
brmsformula-helpers Linear and Non-linear formulas in brms
#### Description
Helper functions to specify linear and non-linear formulas for use with brmsformula.
Usage
<pre><code>
nlf(formula, ..., flist = NULL, dpar = NULL, resp = NULL,
loop = NULL)
lf(..., flist = NULL, dpar = NULL, resp = NULL, cmc = NULL)
set_nl(nl = TRUE, dpar = NULL, resp = NULL)
brmsformula-helpers 35
set_rescor(rescor = TRUE)
set_mecor(mecor = TRUE)
</code></pre>
#### Arguments
formula 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, skew_normal, 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 and frechet families);
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 component 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 oneinflation probability); disc (discrimination) for ordinal models; bs, ndt, and bias (boundary separation, non-decision time, and initial bias of the wiener
diffusion model). By default, distributional parameters are modeled on the log scale if they can be positive only or on the logit scale if the can only be within the unit interval. See ’Details’ for more explanation.
#### Value
For lf and nlf a list that can be passed to brmsformula or added to an existing brmsformula
or mvbrmsformula object. For set_nl and set_rescor a logical #### Value that can be added to an
existing brmsformula or mvbrmsformula object.
See Also
brmsformula, mvbrmsformula
#### Examples
```{r}
# add more formulas to the model
bf(y ~ 1) +
nlf(sigma ~ a * exp(b * x)) +
lf(a ~ x, b ~ z + (1|g)) +
gaussian()
# specify 'nl' later on
bf(y ~ a * inv_logit(x * b)) +
lf(a + b ~ z) +
set_nl(TRUE)
# specify a multivariate model
bf(y1 ~ x + (1|g)) +
bf(y2 ~ z) +
set_rescor(TRUE)
```
* flist Optional list of formulas, which are treated in the same way as formulas passed via the ... argument.
* dpar Optional character string specifying the distributional parameter to which the formulas passed via ... and flist belong.
* resp Optional character string specifying the response variable to which the formulas passed via ... and flist belong. Only relevant in multivariate models.
* loop Logical; Only used in non-linear models. Indicates if the computation of the non-linear formula should be done inside (TRUE) or outside (FALSE) a loop over observations. Defaults to TRUE.
* cmc Logical; Indicates whether automatic cell-mean coding should be enabled when
removing the intercept by adding 0 to the right-hand of model formulas. Defaults
to TRUE to mirror the behavior of standard R formula parsing.
* nl Logical; Indicates whether formula should be treated as specifying a non-linear model. By default, formula is treated as an ordinary linear model formula.
* rescor Logical; Indicates if residual correlation between the response variables should be modeled. Currently this is only possible in multivariate gaussian and student models. Only relevant in multivariate models.
* mecor Logical; Indicates if correlations between latent variables defined by me terms should be modeled. Defaults to TRUE.
36 brmshypothesis