Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to calculate proportion of variance explained by each independent variable?

    I'm running an OLS model and I know the R2 gives the variance explained by the model, but what code do I use to get proportion of variance explained by each independent variable?

    I've checked books, forums etc. Thanks for the help!

  • #2
    Unless the variables are all independent of each other, which is very unusual in real world data, this is not really a well posed question. The whole is not the sum of the parts here. Different variables may compete with each other by having some shared variance. And there can be interference effects as well.

    In my circles, if we do this, we report the variance added by each variable in the model when it was added to the regression last. So something like this:

    Code:
    local xvars x1 x2 x3 x4 // etc.
    regress y `xvars'
    local full_model_r2 = e(r2)
    gen byte include = e(sample)
    
    foreach x of local xvars {
        local short_list: subinstr local xvars "`x'" ""
        regress y `short_list' if include
        display "Variance contribution of `x': =`full_model_r2' - e(r2)"
    }
    But again, do not expect these proportions of variance to add up to the total model proportion of variance.

    Comment


    • #3
      Originally posted by Cameron Whitley View Post
      I'm running an OLS model and I know the R2 gives the variance explained by the model, but what code do I use to get proportion of variance explained by each independent variable?

      I've checked books, forums etc. Thanks for the help!
      Please visit http://research.uni-leipzig.de/rego/. The command "rego" is probably what you want.
      Ho-Chuan (River) Huang
      Stata 19.0, MP(4)

      Comment

      Working...
      X