1
$\begingroup$

I have a dataframe in R and wish to assess the degree to which each of my independent variables impacts the dependent variable during mixed models analysis. To do so, I've built a mixed model using only 1 independent variable, then added another independent variable and measured the change in the resulting R2 values:

library(lme4)

# Use default dataset
df <- sleepstudy

# Create function to measure r^2 values of mixed models
# See: http://stats.stackexchange.com/questions/95054/
r2.corr.mer <- function(m) {
  lmfit <-  lm(model.response(model.frame(m)) ~ fitted(m))
  summary(lmfit)$r.squared
}

# Build the models
m1 = lmer(Reaction ~ (1|Subject), data=df)
m2 = lmer(Reaction ~ Days + (1|Subject), data=df)

# Measure the r^2 values
r2.corr.mer(m1)
r2.corr.mer(m2)

In this case, I would assess Subject's impact on Reaction to be 0.44 [r2.corr.mer(m1)] and would assess Days' impact on Reaction to be 0.28 [r2.corr.mer(m2) - r2.corr.mer(m1)]. This second value accords with the R2 value one gets by running lm(Reaction ~ Days, data=df).

My question is: Is it legitimate to measure the degree to which independent variables impact the dependent variable by measuring changes in the R2 value as described above, assuming that there are no interaction terms in the model (i.e. assuming one uses only + to join independent variables)? If this is not legitimate, what is the ideal way to measure the degree to which each independent variable accounts for the variance in the dependent variable? I would be grateful for any advice others can offer on this question.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.