predictor_competition.Rd
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, a log-likelihood test is used to decide which fixed effect structure is better fit to
predict the dependent variable.
predictor_competition( data, dependent, independent1, independent2, random.intercept = NULL, random.slope = 1 )
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. |
A dataframe containing npar, AIC, BIG, logLik, deviance, Chisq, Df, and Pr(>Chisq). Usually used without variable assignment.
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.
D. Schmitz
data("data_s") # example 1: two similarly well fit predictors predictor_competition(data = data_s, dependent = "sDur", independent1 = "typeOfS", independent2 = "pauseBin", random.intercept = "speaker") #> i Both predictors, typeOfS & pauseBin, are equally good at predicting sDur. #> Data: data #> Models: #> mdl2: sDur ~ pauseBin + (1 | speaker) #> mdl1: sDur ~ typeOfS + (1 | speaker) #> npar AIC BIC logLik deviance Chisq Df Pr(>Chisq) #> mdl2 4 -500.04 -487.99 254.02 -508.04 #> mdl1 5 -475.28 -460.22 242.64 -485.28 0 1 1 # example 2: one predictor is better than the other predictor_competition(data = data_s, dependent = "sDur", independent1 = "typeOfS", independent2 = "slideNumber", random.intercept = "speaker") #> i We have a winner! #> Data: data #> Models: #> mdl2: sDur ~ slideNumber + (1 | speaker) #> mdl1: sDur ~ typeOfS + (1 | speaker) #> npar AIC BIC logLik deviance Chisq Df Pr(>Chisq) #> mdl2 4 -458.17 -446.13 233.08 -466.17 #> mdl1 5 -475.28 -460.22 242.64 -485.28 19.109 1 1.235e-05 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1