This function fits an lme4 model using the supplied database, formula and other function arguments tuning the model fitting process.
Usage
hib_fit_lme4(
obj,
form,
family = stats::gaussian,
REML = TRUE,
calc_CIs = NULL,
optimise_ranefs = FALSE,
model_dredge = FALSE,
model_average = FALSE,
weight_specs = list(weights = NULL, weight_type = NULL),
scale_specs = list(covars_to_scale = NULL, scale_func = NULL),
relevel_specs = c(NULL),
...
)Arguments
- obj
A
HibDatabaseobject, or a list of databases.- form
Model formula in the style of lme4 - including fixed and random effects.
- family
A
familyfunction, e.g. gaussian, poisson - as allowed by lme4. Dafault is 'gaussian'.- REML
A
logical- if using a gaussian family, should the model be fitted using restricted maximum likelihood (REML, T) or maximum likelihood (F) - as inlme4::lmer().- calc_CIs
An indication of whether fixed effect confidence intervals (95%) should be calculated or not, and if so how - one of NULL, "Wald", "profile", "boot".
- optimise_ranefs
Not currently applicable - future dev
- model_dredge
Not currently applicable - future dev
- model_average
Not currently applicable - future dev
- weight_specs
A named
listcontaining "weights" and "weight_type".weights: anumericvector containing the relative weights to assign to each dataset/site, should sum to 1.weight_type: acharacter, specifying either "dataset" or "site" - i.e. should the weights argument assign relative weights to whole datasets, or for sites in each dataset.
Only applicable if a list of
HibDatabases are provided.
The length of 'weights' should be equal to the number ofHibDatabases.- scale_specs
A named
listcontaining "covars_to_scale" and "scale_func".covars_to_scaleis acharactervector of numeric covariates that should be scaled prior to modelling.scale_funcis a function that will be used to scale the specified covariates - ifNULL,base::scale()will be used.
- relevel_specs
A
vectorwhere each item is:"<covar_to_relevel_name>" = "<base_level>".- ...
Any other named arguments that can be passed to
lme4::lmer()/lme4::glmer(), e.g., na.action
Details
This function takes the supplied database object (and various other arguments), fits the specified model and returns a HibModelLME4 object.
References
Douglas Bates, Martin Maechler, Ben Bolker, Steve Walker (2015). Fitting Linear Mixed-Effects Models Using lme4. Journal of Statistical Software, 67(1), 1-48. doi:10.18637/jss.v067.i01.