View source: R/fit_stan_model.R
fit_stan_model | R Documentation |
Fit a stan model using (modified) code and data generated by brms
fit_stan_model(
file,
seed,
bform,
bdata,
bpriors = NULL,
car1 = TRUE,
sample_prior = "no",
knots = NULL,
d_x = NULL,
family = student(),
backend = "rstan",
overwrite = FALSE,
var_car1 = NULL,
var_xcens = NULL,
cens_ind = NULL,
lcl = NULL,
lower_bound = NULL,
stancode = NULL,
...
)
file |
Load/save csvs to this filepath and name. |
seed |
Random seed passed to |
bform |
A |
bdata |
A data frame used to fit the model. |
bpriors |
Priors specified by |
car1 |
Logical. Generate CAR(1) errors? |
sample_prior |
Passed on to |
knots |
Passed on to |
d_x |
A vector representing the spacing in time of observations in each series,
equal to zero at the first timestep. If |
family |
A |
backend |
Run Stan's algorithms using |
overwrite |
Overwrite an exising model stored as CSVs? Defaults to |
var_car1 |
For multivariate models, specify which variable to generate CAR(1) errors for. |
var_xcens |
A character vector containing the names of variables with left-censoring; the order should
correspond to that of |
cens_ind |
A character vector containing the names of left-censoring indicator variables corresponding
to the contents of |
lcl |
A numeric vector of censoring limits for left-censored variables. Alternatively, a list of numeric vectors with censoring limits for
each variable and observation; the order should correspond to that of |
lower_bound |
An optional lower bound for left-censored parameters. The default is no lower bound. |
stancode |
A named character vector of length one, where the name is the model block to modify and the value is the additional Stan code. This has only been validated for the generated quantities block. |
... |
Passed on to |
A brms
model object fitted with rstan
or cmdstanr
.
library("brms")
seed <- 1
data <- read.csv(paste0(system.file("extdata", package = "bgamcar1"), "/data.csv"))
fit <- fit_stan_model(
paste0(system.file("extdata", package = "bgamcar1"), "/test"),
seed,
bf(y | cens(ycens, y2 = y2) ~ 1),
data,
prior(normal(0, 1), class = Intercept),
car1 = FALSE,
save_warmup = FALSE,
chains = 3
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.