Learn R Programming

brms (version 1.3.1)

make_standata: Data for brms Models

Description

Generate data for brms models to be passed to Stan

Usage

make_standata(formula, data, family = "gaussian", prior = NULL, autocor = NULL, nonlinear = NULL, cov_ranef = NULL, sample_prior = FALSE, knots = NULL, control = list(), ...)

Arguments

formula
An object of class brmsformula (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specification are explained in brmsformula.
data
An object of class data.frame (or one that can be coerced to that class) containing data of all variables used in the model.
family
A description of the response distribution and link function to be used in the model. This can be a family function, a call to a family function or a character string naming the family. Every family function has a 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.
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() surrounding it. See also get_prior for more help.
autocor
An optional cor_brms object describing the correlation structure within the response variable (i.e. the 'autocorrelation'). See the documentation of cor_brms for a description of the available correlation structures. Defaults to NULL, corresponding to no correlations.
nonlinear
An optional list of formulas, specifying linear models for non-linear parameters. If 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. More information is given under 'Details'.
cov_ranef
A list of matrices that are proportional to the (within) covariance structure of the group-level 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 appear as rownames of the corresponding matrix. This argument can be used, among others, to model pedigrees and phylogenetic effects.
sample_prior
A flag to indicate if samples from all specified proper priors should be drawn additionally to the posterior samples (defaults to 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.
knots
Optional list containing user specified knot values to be used for basis construction of smoothing terms. For details see gamm.
control
A named list currently for internal usage only
...
Other potential arguments

Value

A named list of objects containing the required data to fit a brms model with Stan.

Examples

Run this code
data1 <- make_standata(rating ~ treat + period + carry + (1|subject), 
                       data = inhaler, family = "cumulative")
names(data1)

data2 <- make_standata(count ~ log_Age_c + log_Base4_c * Trt_c 
                       + (1|patient) + (1|visit), 
                       data = epilepsy, family = "poisson")
names(data2)
         

Run the code above in your browser using DataLab