TEbrm_advi | R Documentation |
Uses Stan's stochastic gradient ascent methods "fullrank" or "meanfield" rather than full Bayesian sampling. Is likely to be faster than typical sampling for large models, but possibly less accurate. This function fits the model several times and returns the best model (initial model selection uses Bayesian R-squared, final model selection uses 10-fold cross-validation). Beware: This re-fitting has a tendency to crash R sometimes.
TEbrm_advi(
formIn,
dataIn = data.frame(),
...,
algorithm = "fullrank",
conv_thresh = 0.5,
quiet = F
)
formIn |
Model formula, as in |
dataIn |
Data, as in |
... |
Any other argument to pass to |
algorithm |
Which ADVI algorithm to use: "meanfield" or "fullrank". |
conv_thresh |
Re-fit models are compared, with the standardized distance (mean_diff / SD) being calculated. Models keep being re-fit until at least 2 models' largest standardized differences are smaller than this value (or until a certain number of models has been fit in total, which scales inversely with this value). The better-fitting of these two models is then returned. Values over 30 will cause an error, which should not be an issue for any normal use of this function. |
quiet |
Progress is printed by default, but can be suppressed with quiet=T. |
Stochastic gradient ascent in Stan uses Automatic Differentiation Variational Inference (ADVI).
Re-fitting a model within this function is not comprehensive. If using ADVI, it is recommended
to use TEbrm_advi
multiple times, and choose the best using comparisons of fit, such as
fit_model$criteria$kfold
(estimated using
add_criterion(fit_model,'kfold')
).
vb
and http://mc-stan.org
## Not run:
## can be used in place of brm
m <- TEbrm_advi(ratio ~ resp, anstrain_s1)
summary(m)
conditional_effects(m)
## Use in the context of TEfits
m1 <- TEbrm(
acc ~ tef_change_expo3('trialNum')
,data = anstrain_s1,
,algorithm = 'meanfield'
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.