View source: R/robustLM_bayes.R
robustLM_bayes | R Documentation |
Fits a median linear regression, with random effects (i.e., mixed-effects model) if desired,
using brm
and the asymmetric laplace distribution (fitting quantile = .5, i.e., median).
Then fits a set of models dropping each fixed-effect term in turn, and uses
bridge sampling to estimate the Bayes Factors of the full model relative to each
sub-model. Returns the full model, with a data frame model$bayes_factors
with
each fixed effect's log (base 3) Bayes Factor.
robustLM_bayes(formula, data, ..., iter = 10000, showProgress = T, quiet = T)
formula |
Formula, as in |
data |
Data, as in |
... |
Additional arguments to pass to |
iter |
Number of iterations. More is better, within reasonable time constraints |
showProgress |
Show a small progress bar? |
quiet |
Logical. To show model progress, or hide it. |
Bridge sampling is run 5 times for each effect, and the most conservative (i.e., equivocal) of the resulting BF is returned.
These models are computationally expensive and require quite a bit of memory. Without enough
memory they will likely crash the R session. Other sources of errors or crashing may be
out-of-date packages, such as RcppParallel
, StanHeaders
, brms
, bridgesampling
.
While using algorighm = 'fullrank'
speeds up the model (over the default algorithm = 'sampling'
by a factor of over 3.5 in preliminary tests), it would be advised
to fit and compare several fitting runs to assess the robustness of the resulting coefficients and Bayes Factors. In brief tests, some
values have been quite consistent across fitting runs and others have not when using fullrank
or meanfield
; in general, waiting for
sampling
provides the most robust estimates.
brm
, bayes_factor
, and brmsfamily
.
## Not run:
# This fairly simple example takes about 160 seconds on a fairly good computer.
m <- robustLM_bayes(mot ~ ufov * enum, dat_cochraneEtAl_2019_PLOSOne)
m$bayes_factors
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.