View source: R/cs_sampling_brms.R
cs_sampling_brms | R Documentation |
cs_sampling_brms is a wrapper function that takes inputs in the form of model statements in familiar brms syntax. Then brms helper functions build Stan models and call cs_sampling.
cs_sampling_brms( svydes, brmsmod, data, family, par_brms = NA, prior = NULL, stanvars = NULL, knots = NULL, ctrl_stan = list(chains = 1, iter = 2000, warmup = 1000, thin = 1), rep_design = FALSE, ctrl_rep = list(replicates = 100, type = "mrbbootstrap"), stancode_args = list(), standata_args = list(), H_estimate = "MCMC", matrix_sqrt = "eigen", sampling_args = list() )
svydes |
|
brmsmod |
|
data |
|
family |
|
par_brms |
|
prior |
|
stanvars |
|
knots |
|
ctrl_stan |
|
rep_design |
|
ctrl_rep |
|
stancode_args |
|
standata_args |
|
H_estimate |
|
matrix_sqrt |
|
sampling_args |
|
The output of cs_sampling.
#continuous dependent variable # Survey Design Information library(survey) data(api) apistrat$wt <- apistrat$pw /mean(apistrat$pw) dstrat <- svydesign(id=~1,strata=~stype, weights=~wt, data=apistrat, fpc=~fpc) #Define and Run the Stan Model Via BRMS Wrapper library(brms) set.seed(12345) model_formula <- formula("api00|weights(wt) ~ ell + meals + mobility") mod.brms <- cs_sampling_brms(svydes = dstrat, brmsmod = brmsformula(model_formula, center = FALSE), data = apistrat, family = gaussian()) #Plot the results plot(mod.brms) plot(mod.brms, varnames = paste("b", 1:4, sep =""))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.