I am wondering what the exact relationship between partial $R^2$ and coefficients in a linear model is and whether I should use only one or both to illustrate the importance and influence of factors.
As far as I know, with summary
I get estimates of the coefficients, and with anova
the sum of squares for each factor - the proportion of the sum of squares of one factor divided by the sum of the sum of squares plus residuals is partial $R^2$ (the following code is in R
).
library(car)
mod<-lm(education~income+young+urban,data=Anscombe)
summary(mod)
Call:
lm(formula = education ~ income + young + urban, data = Anscombe)
Residuals:
Min 1Q Median 3Q Max
-60.240 -15.738 -1.156 15.883 51.380
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.868e+02 6.492e+01 -4.418 5.82e-05 ***
income 8.065e-02 9.299e-03 8.674 2.56e-11 ***
young 8.173e-01 1.598e-01 5.115 5.69e-06 ***
urban -1.058e-01 3.428e-02 -3.086 0.00339 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 26.69 on 47 degrees of freedom
Multiple R-squared: 0.6896, Adjusted R-squared: 0.6698
F-statistic: 34.81 on 3 and 47 DF, p-value: 5.337e-12
anova(mod)
Analysis of Variance Table
Response: education
Df Sum Sq Mean Sq F value Pr(>F)
income 1 48087 48087 67.4869 1.219e-10 ***
young 1 19537 19537 27.4192 3.767e-06 ***
urban 1 6787 6787 9.5255 0.003393 **
Residuals 47 33489 713
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
The size of the coefficients for 'young' (0.8) and 'urban' (-0.1, about 1/8 of the former, ignoring '-') does not match the explained variance ('young' ~19500 and 'urban' ~6790, i.e. around 1/3).
So I thought I would need to scale my data because I assumed that if a factor's range is much wider than another factor's range their coefficients would be hard to compare:
Anscombe.sc<-data.frame(scale(Anscombe))
mod<-lm(education~income+young+urban,data=Anscombe.sc)
summary(mod)
Call:
lm(formula = education ~ income + young + urban, data = Anscombe.sc)
Residuals:
Min 1Q Median 3Q Max
-1.29675 -0.33879 -0.02489 0.34191 1.10602
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.084e-16 8.046e-02 0.000 1.00000
income 9.723e-01 1.121e-01 8.674 2.56e-11 ***
young 4.216e-01 8.242e-02 5.115 5.69e-06 ***
urban -3.447e-01 1.117e-01 -3.086 0.00339 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.5746 on 47 degrees of freedom
Multiple R-squared: 0.6896, Adjusted R-squared: 0.6698
F-statistic: 34.81 on 3 and 47 DF, p-value: 5.337e-12
anova(mod)
Analysis of Variance Table
Response: education
Df Sum Sq Mean Sq F value Pr(>F)
income 1 22.2830 22.2830 67.4869 1.219e-10 ***
young 1 9.0533 9.0533 27.4192 3.767e-06 ***
urban 1 3.1451 3.1451 9.5255 0.003393 **
Residuals 47 15.5186 0.3302
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
But that doesn't really make a difference, partial $R^2$ and the size of the coefficients (these are now standardized coefficients) still do not match:
22.3/(22.3+9.1+3.1+15.5)
# income: partial R2 0.446, Coeff 0.97
9.1/(22.3+9.1+3.1+15.5)
# young: partial R2 0.182, Coeff 0.42
3.1/(22.3+9.1+3.1+15.5)
# urban: partial R2 0.062, Coeff -0.34
So is it fair to say that 'young' explains three times as much variance as 'urban' because partial $R^2$ for 'young' is three times that of 'urban'? Why is the coefficient of 'young' then not three times that of 'urban' (ignoring the sign)?
I suppose the answer for this question will then also tell me the answer to my initial query: Should I use partial $R^2$ or coefficients to illustrate the relative importance of factors? (Ignoring direction of influence - sign - for the time being.)
Edit:
Partial eta-squared appears to be another name for what I called partial $R^2$. etasq {heplots} is a useful function that produces similar results:
etasq(mod)
Partial eta^2
income 0.6154918
young 0.3576083
urban 0.1685162
Residuals NA