View source: R/brm_optimizing.R
brm_optimizing | R Documentation |
Maximum-likelihood fitting of a brm-style model
brm_optimizing(
formula = NA,
data = NA,
...,
iter = 2000,
brmModel = NA,
strata = NA,
crossvals = 0,
bootstrap = NA,
refresh = 0
)
formula |
Model formula |
data |
Model data |
... |
Additional arguments to pass to an initial |
iter |
Number of iterations. If |
brmModel |
An initial brm model to re-fit using maximum-likelihood. |
strata |
The strata to use in resampling; a vector the length of the data set's rows. If all values are equal, no stratification is used in resampling |
crossvals |
Number of cross-validations [currently not implemented] |
bootstrap |
Bootstrapping is done by default if |
refresh |
Should progress be printed? Use This function is an attempt to merge the usability and flexibility of Several major limitation persists, however. One limitation is that sampling methods
inherently provide distributions of parameters whereas maximum-likelihood methods do not.
The simplest solution to this would be using the Hessian of the optimization, but this matrix
is not always well-behaved. A potentially more robust solution is to bootstrap the model (i.e.,
in principle, draw parameters from their sampling distribution by resampling data with replacement
and re-fitting the model), but this leads to the second limitation.
As of now the implementation of In summary, the user is advised to proceed with caution. Repeated maximum-likelihood fitting and bootstrapping are likely to be the most beneficial applications of this method, but the current implementation is somewhat unstable for these applications. |
Most errors and warnings can be ignored; they are likely do due hiccups in the
pipeline that do not influence the final outcome. The error
Error in chol.default(-H)
indicates that the Hessian was ill-behaved and
direct approximations of the estimates' standard errors were likely impossible.
As long as the resulting object contains Est.Error
and CI, however,
it is likely that at least one estimation run allowed for these approximations.
m1 <- brm_optimizing(Sepal.Width ~ Sepal.Length * Petal.Width + (1|Species),iris)
m_cv_1 <- brm_optimizing(Sepal.Width ~ Sepal.Length * Petal.Width + (1|Species),iris
,strata = iris$Species,iter = 500,
bootstrap = F, crossvals = 50)
m_cv_2 <- brm_optimizing(Sepal.Width ~ Sepal.Length * Petal.Width,iris
,strata = iris$Species,iter = 500,
bootstrap = F, crossvals = 50)
m_cv_1$logLik_oos - m_cv_2$logLik_oos # m_cv_1 is much better! test 1, 50 crossvals: 57.7; test 2: ; test 3:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.