我想知道线性模型中部分与系数之间的确切关系是什么,我是否应该仅使用一个或两个来说明因素的重要性和影响。
据我所知,summary我得到了系数的估计值,并且得到anova了每个因子的平方和-一个因子的平方和除以平方和加残差的和的比例为(以下代码位于中)。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
“年轻”(0.8)和“城市”(-0.1,约前者的1/8,忽略“-”)的系数大小与解释的方差不匹配(“年轻”〜19500和“城市”〜 6790,即大约1/3)。
因此,我认为我需要缩放数据,因为我假设如果一个因子的范围比另一个因子的范围大得多,那么它们的系数将很难比较:
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    
但这并没有真正的区别,部分和系数的大小(现在是标准化系数)仍然不匹配:
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
因此,可以说“年轻”解释的方差是“城市”的三倍,因为“年轻”的部分是“城市”的三倍吗?为什么“年轻”系数不是“城市”系数的三倍(忽略符号)?
我想这个问题的答案也会告诉我最初查询的答案:我应该使用部分还是系数来说明因素的相对重要性?(暂时忽略影响方向-标志-。)
编辑:
偏eta平方似乎是我所谓的偏另一个名称。etasq {heplots}是一个有用的函数,可以产生相似的结果:
etasq(mod)
          Partial eta^2
income        0.6154918
young         0.3576083
urban         0.1685162
Residuals            NA
 
 
 
