Compare the predictive strength of two independent variables in a minimal linear (mixed effects) regression model. The function creates two identical lm or lmer objects, only differing in fixed effects structure. Then, using the Akaike Information Criterion, the better predictor is determined. A model is assumed to have a better fit, if its AIC is 2 points lower than the other's.

predictor_competition2(
  data,
  dependent,
  independent1,
  independent2,
  random.intercept = NULL,
  random.slope = 1
)

Arguments

data

The original data set for both models.

dependent

The dependent variable for both models.

independent1

The independent variable(s), i.e. the fixed effects, of the 1st model.

independent2

The independent variable(s), i.e. the fixed effects, of the 2nd model.

random.intercept

The random intercept for both models. If not random intercept is specified, regular linear models are fitted.

random.slope

The random slope for both models. The default assumes no random slope.

Value

A dataframe containing df and AIC. Usually used without variable assignment.

References

Bates, D., Maechler, M., Bolker, B., & Walker, S. (2015). Fitting Linear Mixed-Effects Models Using lme4. Journal of Statistical Software, 67(1), 1-48. doi:10.18637/jss.v067.i01.

Author

D. Schmitz & J. Esser

Examples

data("data_s")

predictor_competition2(data = data_s, dependent = "sDur", independent1 = "pauseBin", independent2 = "typeOfS")
#>  We have a winner - it's pauseBin!
#>      df       AIC
#> mdl1  3 -484.5026
#> mdl2  4 -462.1716