Usage
brm(formula, data = NULL, family = c("gaussian", "identity"),
prior = NULL, addition = NULL, autocor = NULL, partial = NULL,
threshold = c("flexible", "equidistant"), cov.ranef = NULL,
ranef = TRUE, sample.prior = FALSE, fit = NA, inits = "random",
n.chains = 2, n.iter = 2000, n.warmup = 500, n.thin = 1,
n.cluster = 1, cluster_type = "PSOCK", silent = FALSE, seed = 12345,
save.model = NULL, ...)
Arguments
formula
An object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted.
The details of model specification are given under 'Details'.
data
An optional data frame, list or environment (or object coercible by as.data.frame
to a data frame) containing
the variables in the model. If not found in data, the variables are taken from environment(formula)
,
typically the e
family
A vector of one or two character strings. The first string indicates the distribution of the dependent variable (the 'family'). Currently, the following families are supported:
"gaussian"
, "student"
, "cauchy"
,
prior
One or more brmsprior
objects created by function set_prior
and combined
using the c
method. A single brmsprior
object may be passed without c()
addition
A named list of one sided formulas each containing additional information on the response variable. The following names are allowed:
se
for specifying standard errors for meta-analysis, weights
to fit weighted regression models,
autocor
An optional cor_brms
object describing the correlation structure within the response variable (i.e. the 'autocorrelation').
See the documentation of cor_brms
partial
A one sided formula of the form ~expression
specifying the predictors with category specific effects in non-cumulative ordinal models
(i.e. in families "cratio"
, "sratio"
, or "acat"
).
threshold
A character string indicating the type of thresholds (i.e. intercepts) used in an ordinal model.
"flexible"
provides the standard unstructured thresholds and "equidistant"
restricts the distance between consecutive thresholds to
cov.ranef
A list of matrices that are proportional to the (within) covariance structure of the random effects.
The names of the matrices should correspond to columns in data
that are used as grouping factors.
All levels of the grouping factor should
ranef
A flag to indicate if random effects for each level of the grouping factor(s) should be saved (default is TRUE
).
Set to FALSE
to save memory. The argument has no impact on the model fitting itself.
sample.prior
A flag to indicate if samples from all specified proper priors should be additionally drawn.
Among others, these samples can be used to calculate Bayes factors for point hypotheses. Default is FALSE
.
fit
An instance of S3 class brmsfit
derived from a previous fit; defaults to NA
. If fit
is of class brmsfit
, the compiled model associated
with the fitted result is re-used and the arguments formula<
inits
Either "random"
or "0"
. If inits is "random"
(the default), Stan will randomly generate initial values for parameters.
If it is "0"
, all parameters are initiliazed to zero. This option is recommended fo
n.chains
Number of Markov chains (default: 2)
n.iter
Number of total iterations per chain (including burnin; default: 2000)
n.warmup
A positive integer specifying number of warmup (aka burnin) iterations. This also specifies the number of iterations used for stepsize adaptation,
so warmup samples should not be used for inference. The number of warmup should not be larger than n.
n.thin
Thinning rate. Must be a positive integer. Set n.thin > 1
to save memory and computation time if n.iter
is large. Default is 1, that is no thinning.
n.cluster
Number of clusters to use to run parallel chains. Default is 1.
cluster_type
A character string specifying the type of cluster created by makeCluster
when sampling in parallel (i.e. when n.cluster
is greater 1
). Default is "PS
silent
logical; If TRUE
, most intermediate output from Stan is suppressed.
seed
Positive integer. Used by set.seed
to make results reproducable.
save.model
Either 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 f
...
Further arguments to be passed to Stan.