Solved – R implementation of coefficient of partial determination

anovarregression

Does anyone have suggestions or packages that will calculate the coefficient of partial determination?

The coefficient of partial determination can be defined as the percent of variation that cannot be explained in a reduced model, but can be explained by the predictors specified in a full(er) model. This coefficient is used to provide insight into whether or not one or more additional predictors may be useful in a more fully specified regression model.

The calculation for the partial r^2 is relatively straight forward after estimating your two models and generating the ANOVA tables for them. The calculation for the partial r^2 is:

(SSEreduced – SSEfull) / SSEreduced

I've written this relatively simple function that will calculate this for a multiple linear regression model. I'm unfamiliar with other model structures in R where this function may not perform as well:

partialR2 <- function(model.full, model.reduced){
    anova.full <- anova(model.full)
    anova.reduced <- anova(model.reduced)

    sse.full <- tail(anova.full$"Sum Sq", 1)
    sse.reduced <- tail(anova.reduced$"Sum Sq", 1)

    pR2 <- (sse.reduced - sse.full) / sse.reduced
    return(pR2)

    }

Any suggestions or tips on more robust functions to accomplish this task and/or more efficient implementations of the above code would be much appreciated.

Best Answer

Well, r^2 is really just covariance squared over the product of the variances, so you could probably do something like cov(Yfull, Ytrue)/var(Ytrue)var(Yfull) - cov(YReduced, Ytrue)/var(Ytrue)var(YRed) regardless of model type; check to verify that gives you the same answer in the lm case though.

http://www.stator-afm.com/image-files/r-squared.gif

Related Question