ez (version 4.4-0)

ezMixed: 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 data that contains the dependent variable. Values in this column must be numeric.
family
Family to use to represent error.
random
.() object specifying one or more columns in data that contain random effects.
fixed
.() object specifying one or more columns in data that contain fixed effects.
covariates
.() object specifying one or more columns in data that contain variables to be used as fixed effect covariates.
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 fixed on the shape of the distribution of residuals. Of course, this only really makes sense when there IS a distribution of residuals (i.e. not binomial data).
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 k to supply to calls to gam. Higher values yield longer computation times but may better capture non-linear phenomena. If set to Inf (default), ezMixed will automatically use the maximum possible value for k given the number of unique combinations of values in the numeric predictors being evaluated. If a finite positive value is supplied, k will be set to that value or less (if the supplied k exceeds the maximum possible k for a given effect).
use_bam
Logical. If TRUE, bam is used rather than gam.
alarm
Logical. If TRUE, call the alarm function when ezMixed completes.
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 fixed argument).
highest
Integer specifying the highest order interaction between the fixed effects to test. The default value, Inf, will test to the highest possible order.
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 progress_dir argument, the progress directory will be searched for already completed effects and resume from these. Useful if a run was interrupted.
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 library(doMC);options(cores=4);registerDoMC()) and is likely only to work when running R from a unix terminal.
gam_args
Single character string representing arguments to be passed to calls to gam.
mer_args
Single character string representing arguments to be passed to calls to lmer (or glmer if the value to the family argument is not gaussian).

Value

A list with the following elements: A list with the following elements:

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.

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

Run this code
#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)

Run the code above in your browser using DataCamp Workspace