ezMixed {ez} | R Documentation |
Compute evidence for fixed effects in an mixed effects modelling context
Description
This function provides assessment of fixed effects and their interactions via generalized mixed effects modelling, or generalized additive mixed effects modelling for effects involving numeric predictors to account for potentially non-linear effects of such predictors. See Details section below for implementation notes.
Usage
ezMixed(
data
, dv
, family = gaussian
, random
, fixed
, covariates = NULL
, add_q = FALSE
, fix_gam = TRUE
, cov_gam = TRUE
, gam_smooth = c('s','te')
, gam_bs = 'ts'
, gam_k = Inf
, use_bam = FALSE
, alarm = FALSE
, term_labels = NULL
, highest = Inf
, return_models = TRUE
, correction = AIC
, progress_dir = NULL
, resume = FALSE
, parallelism = 'none'
, gam_args = NULL
, mer_args = NULL
)
Arguments
data |
Data frame containing the data to be analyzed. |
dv |
.() object specifying the column in |
family |
Family to use to represent error. |
random |
.() object specifying one or more columns in |
fixed |
.() object specifying one or more columns in |
covariates |
.() object specifying one or more columns in |
add_q |
Logical. If TRUE, quantile values of each observation will be computed for each effect and interaction and these quantile values will be added as a fixed effect predictor. This permits investigating the effect of the fixed effect predictors specified in |
fix_gam |
Logical. If TRUE (default), generalized additive modelling is used to evaluate the possibly-non-linear effects of numeric fixed effect predictors. |
cov_gam |
Logical. If TRUE (default), generalized additive modelling is used to represent the possibly-non-linear effects of numeric covariates. |
gam_smooth |
Vector of one or more elements that are character strings specifying the name of the smoother to use when using gam. If a list of two elements, the first element will be used when evaluating effects and interactions that include a single numeric predictor, while the second element will be used when evaluating effects and interactions that involve multiple numeric predictors. |
gam_bs |
Character specifying the name of the smooth term to use when using gam. |
gam_k |
Numeric value specifying the maximum value for |
use_bam |
|
alarm |
Logical. If TRUE, call the |
term_labels |
Vector of one or more elements that are character strings specifying effects to explore (useful when you want only a subset of all possible effects and interactions between the predictors supplied to the |
highest |
Integer specifying the highest order interaction between the fixed effects to test. The default value, |
return_models |
Logical. If TRUE, the returned list object will also include each lmer model (can become memory intensive for complex models and/or large data sets). |
correction |
Name of a correction for complexity to apply (ex. AIC, BIC, etc) to each model's likelihood before computing likelihood ratios. |
progress_dir |
Character string specifying name of a folder to be created to store results as they are computed (to save RAM). |
resume |
Logical. If TRUE and a value is passed to the |
parallelism |
Character string specifying whether and how to compute models in parallel. If “none”, no parallelism will be employed. If “pair”, the restricted and unrestricted models for each effect will be computed in parallel (therefore using only 2 cores). If “full”, then effects themselves will be computed in parallel (using all available cores). Parallelism assumes that a parallel backend has been specified (as in |
gam_args |
Single character string representing arguments to be passed to calls to |
mer_args |
Single character string representing arguments to be passed to calls to |
Details
Computation is achieved via lmer
, or gam
when the effect under evaluation includes a numeric predictor. Assessment of each effect of interest necessitates building two models: (1) a “unrestricted” model that contains the effect of interest plus any lower order effects and (2) a “restricted” model that contains only the lower order effects (thus “restricting” the effect of interest to zero). These are then compared by means of a likelihood ratio, which needs to be corrected to account for the additional complexity of the unrestricted model relative to the restricted model. The default applied correction is Akaike's Information Criterion (AIC), which in the context of mixed effects models has been demonstrated to be asymptotically equivalent to cross-validation, a gold-standard technique for ensuring that model comparisons optimize prediction of new data.
The complexity-corrected likelihood ratio returned by ezMixed
is represented on the log-base-2 scale, which has the following convenient properties:
(1) Resulting values can be discussed as representing “bits of evidence” for or against the evaluated effect.
(2) The bits scale permits easy representation of both very large and very small likelihood ratios.
(3) The bits scale represents equivalent evidence between the restricted and unrestricted models by a value of 0.
(4) The bits scale represents ratios favoring the restricted model symmetrically to those favoring the unrestricted model. That is, say one effect obtains a likelihood ratio of 8, and another effect obtains a likelihood ratio of 0.125; both ratios indicate the same degree of imbalance of evidence (8:1 and 1:8) and on the bits scale they faithfully represent this symmetry as values 3 and -3, respectively.
Value
A list with the following elements:
summary |
A data frame summarizing the results, including whether warnings or errors occurred during the assessment of each effect and the bits of evidence associated with each. |
formulae |
A list of lists, each named for an effect and containing two elements named “unrestricted” and “restricted”, which in turn contain the right-hand-side formulae used to fit the unrestricted and restricted models, respectively. |
errors |
A list similar to |
warnings |
A list similar to |
models |
(If requested by setting |
Author(s)
Michael A. Lawrence mike.lwrnc@gmail.com
Visit the ez
development site at http://github.com/mike-lawrence/ez
for the bug/issue tracker and the link to the mailing list.
References
Glover S, Dixon P. (2004) Likelihood ratios: a simple and flexible statistic for empirical psychologists. Psychonomic Bulletin and Review, 11 (5), 791-806.
Fang, Y. (2011). Asymptotic equivalence between cross-validations and Akaike information criteria in mixed-effects models. Journal of the American Statistical Association, 9, 15-21.
See Also
lmer
, glmer
, gam
, ezMixedProgress
, ezPredict
, ezPlot2
Examples
#Read in the ANT data (see ?ANT).
data(ANT)
head(ANT)
ezPrecis(ANT)
#Run ezMixed on the accurate RT data
rt = ezMixed(
data = ANT[ANT$error==0,]
, dv = .(rt)
, random = .(subnum)
, fixed = .(cue,flank,group)
)
print(rt$summary)
## Not run:
#Run ezMixed on the error rate data
er = ezMixed(
data = ANT
, dv = .(error)
, random = .(subnum)
, fixed = .(cue,flank,group)
, family = 'binomial'
)
print(er$summary)
## End(Not run)