1

Say I have some predictors, and I know how they affect some dependent variable:

#predictors
x1<- seq(0,10,0.1)
x2<-runif(101,0,1)
#specify how predictors affect dependent variable y
y<- 15*x1 + 10*x1*x2
#introduce random error
y.err<- rnorm(101,0.01)
y<- y + y.err

I can then model y as a function of x1 and x2 like this:

fit<- lm(y ~ x1 + x1*x2)

which yields this output:

summary(fit)

Call:
lm(formula = y ~ x1 + x1 * x2)

Residuals:
     Min       1Q   Median       3Q      Max 
-2.76646 -0.59886 -0.09115  0.70549  2.85311 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  0.38875    0.41630   0.934    0.353    
x1          14.93601    0.07409 201.585   <2e-16 ***
x2          -0.74815    0.79518  -0.941    0.349    
x1:x2       10.10469    0.13698  73.768   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.025 on 97 degrees of freedom
Multiple R-squared:  0.9997,    Adjusted R-squared:  0.9997 
F-statistic: 1.184e+05 on 3 and 97 DF,  p-value: < 2.2e-16

So, total model $R^2$ is 0.997.

I would like to know what percentage of that $R^2$ value can be attributed to x1, x2, and the interaction of x1 and x2. I am also aware of a previous post on this topic linked here, where the user has an identical question. However, the solution proposed (as I read it) was to run the correlations individually, square them, and they will sum to the full model $R^2$. This is not the case here.

colin
  • 862
  • 1
  • 11
  • 27
  • See this http://stats.stackexchange.com/questions/64010 and in particular my answer there. – amoeba Jul 16 '15 at 17:41
  • @amoeba your answer there is not super helpful. It suggests use of the Grompings relaimpo package. Only the 'lmg' metric works with higher order terms, and when applied to this model it reports that the `x2` term is more important than the `x1*x2` interaction. This is definitely false, as I have coded the relationship between `y` and the interaction explicitly above. Second, if I remove the `x2` main effect from the model, written as `y~ x1 + x1*x2 - x2`, it will not work with the relaimpo package. – colin Jul 16 '15 at 18:39
  • I am not an R user and cannot help you further. But I think that all metrics in relaimpo should work with higher order terms. – amoeba Jul 16 '15 at 21:41

0 Answers0