Solved – Variance explained from factors for step-wise regression in R

rregression

I used a stepwise multiple regression to generate a model and I am trying to appropriately report the results by indicating the (additional) variance explained by each included factor. I'm not sure how to extract that information, however.

Basically my code thus far is simply:

init <- lm(dep ~ fac1 + fac2 + fac3 + fac4,data=data)
final <- stepAIC(init, direction="both")

or

final <- step(init, direction="both")

In the case of my data, the final model is final ~ fac1 + fac2 + fac3

At this point, I want to know how much variance the most important factor explains, how much additional variance is explained by adding a second factor and so on. I can get the coefficients, but I'm not sure how to extract the R/R^2 for each factor.

Where is that reported?

Thanks in advance.

Best Answer

You're unlikely to get legitimate answers to your questions using stepwise algorithms to select predictors. For details on that topic you could search for "variable selection" on this site. If you're willing and able to use a more intentional/focussed way of choosing variables, then R's relaimpo (relative importance) package should be very helpful. Its calc.relimp command calculates the change in r-squared for each predictor when the predictor is entered last (its [part r] squared, a.k.a. squared semipartial correlation) -- and/or when it is entered first (its zero-order r squared). A basic statement is

calc.relimp( mymodel, type = c("last", "first") )