make_stancode(formula, data, family = NULL, prior = NULL, autocor = NULL, nonlinear = NULL, threshold = c("flexible", "equidistant"), sparse = FALSE, cov_ranef = NULL, sample_prior = FALSE, stan_funs = NULL, save_model = NULL, ...)
formula
or
brmsformula
(or one that can be coerced to that classes):
A symbolic description of the model to be fitted.
The details of model specification are explained in
brmsformula
.data.frame
(or one that can be coerced to that class)
containing data of all variables used in the model.link
argument allowing to specify
the link function to be applied on the response variable.
If not specified, default links are used.
For details of supported families see
brmsfamily
.
By default, a linear gaussian
model is applied.NULL
(the default)
formula
is treated as an ordinary formula.
If not NULL
, formula
is treated as a non-linear model
and nonlinear
should contain a formula for each non-linear
parameter, which has the parameter on the left hand side and its
linear predictor on the right hand side.
Alternatively, it can be a single formula with all non-linear
parameters on the left hand side (separated by a +
) and a
common linear predictor on the right hand side.
As of brms 1.4.0, we recommend specifying non-linear
parameters directly within formula
."flexible"
provides the standard unstructured thresholds and
"equidistant"
restricts the distance between
consecutive thresholds to the same value.FALSE
).
For design matrices with many zeros, this can considerably
reduce required memory. For univariate sparse models, it may be
sensible to prevent the design matrix from being centered
(see 'Details' for more information), as centering may
reduce sparsity. Sampling speed is currently not improved or
even slightly decreased.data
that are used as grouping factors.
All levels of the grouping factor should appear as rownames
of the corresponding matrix. This argument can be used,
among others to model pedigrees and phylogenetic effects.
See vignette("brms_phylogenetics")
for more details.FALSE
). Among others, these samples can be used
to calculate Bayes factors for point hypotheses.
Alternatively, sample_prior
can be set to "only"
to
sample solely from the priors. In this case, all parameters must
have proper priors.NULL
or a character string.
In the latter case, the model code is
saved in a file named after the string supplied in save_model
,
which may also contain the full path where to save the file.
If only a name is given, the file is saved in the current working directory.make_stancode(rating ~ treat + period + carry + (1|subject),
data = inhaler, family = "cumulative")
make_stancode(count ~ log_Age_c + log_Base4_c * Trt_c
+ (1|patient) + (1|visit),
data = epilepsy, family = "poisson")
Run the code above in your browser using DataLab