有没有办法对StepAIC的“Coefficients”部分的输出进行排序(通过估计值或t值)?
> summary(sta9);
Call:
lm(formula = rating ~ `b/d` + `v/w` + `korte klank` + `lange klank` +
`-eer, -oor, -eur` + `-aai, -ooi, -oei` + `-eeuw, -ieuw, -uw` +
`-ng` + `-nk` + schwa + `eind d` + `eind b` + open + gesloten +
`-ee` + `mv klinker 's` + tussenletter + hoofdletter + trema +
regelverkleinwoorden + `-ch, -cht` + `ei/ij` + `ou, au, ouw, auw` +
`-sch, -schr` + `i/ie` + `be-, ge-, ver-` + e + `-lijk` +
`-heid` + `-teit` + `-tie` + `-ge` + verklein + `-er, -el, -en, -em` +
leenwoord + `-air` + `c/k, c/s` + q + x + y + `-th` + accent +
ch + length + freq - 1, data = as.data.frame(scale(items16[c(7,
21:78, 85:86)])))
Residuals:
Min 1Q Median 3Q Max
-1.8271 -0.3729 -0.0522 0.3585 1.9980
Coefficients:
Estimate Std. Error t value Pr(>|t|)
`b/d` 0.026588 0.009423 2.822 0.004805 **
`v/w` 0.032920 0.009350 3.521 0.000435 ***
`korte klank` -0.029310 0.013324 -2.200 0.027885 *
`lange klank` -0.024760 0.010828 -2.287 0.022271 *
`-eer, -oor, -eur` -0.020068 0.009321 -2.153 0.031378 *
`-aai, -ooi, -oei` 0.015499 0.009259 1.674 0.094217 .
`-eeuw, -ieuw, -uw` 0.019706 0.010097 1.952 0.051045 .
`-ng` -0.045828 0.009522 -4.813 1.55e-06 ***
`-nk` -0.022971 0.009299 -2.470 0.013543 *
schwa -0.014353 0.009340 -1.537 0.124461
`eind d` 0.033766 0.010208 3.308 0.000950 ***
`eind b` 0.041695 0.009045 4.610 4.18e-06 ***
open 0.042792 0.010284 4.161 3.24e-05 ***
gesloten 0.088218 0.009863 8.944 < 2e-16 ***
`-ee` 0.014626 0.009043 1.617 0.105879
`mv klinker 's` 0.012957 0.009101 1.424 0.154628
tussenletter -0.052541 0.009850 -5.334 1.02e-07 ***
hoofdletter 0.097015 0.009283 10.451 < 2e-16 ***
trema 0.141985 0.009932 14.296 < 2e-16 ***
regelverkleinwoorden 0.031238 0.010874 2.873 0.004093 **
`-ch, -cht` -0.044193 0.009947 -4.443 9.15e-06 ***
`ei/ij` 0.041017 0.011251 3.646 0.000271 ***
`ou, au, ouw, auw` 0.021683 0.010342 2.097 0.036092 *
`-sch, -schr` -0.055558 0.009299 -5.974 2.54e-09 ***
`i/ie` 0.043021 0.010286 4.182 2.95e-05 ***
`be-, ge-, ver-` -0.022401 0.009356 -2.394 0.016705 *
e 0.051668 0.012349 4.184 2.93e-05 ***
`-lijk` -0.032245 0.009964 -3.236 0.001222 **
`-heid` -0.075044 0.010324 -7.269 4.42e-13 ***
`-teit` -0.018272 0.009826 -1.860 0.063034 .
`-tie` -0.013415 0.009448 -1.420 0.155715
`-ge` -0.019328 0.009757 -1.981 0.047673 *
verklein -0.077275 0.012170 -6.350 2.42e-10 ***
`-er, -el, -en, -em` -0.046764 0.009867 -4.739 2.23e-06 ***
leenwoord 0.117488 0.009910 11.856 < 2e-16 ***
`-air` 0.036930 0.009062 4.075 4.69e-05 ***
`c/k, c/s` 0.091685 0.009851 9.307 < 2e-16 ***
q 0.052842 0.009360 5.645 1.77e-08 ***
x 0.045299 0.009039 5.011 5.67e-07 ***
y 0.063955 0.009375 6.822 1.05e-11 ***
`-th` 0.038773 0.009380 4.134 3.65e-05 ***
accent 0.072422 0.009434 7.677 2.09e-14 ***
ch 0.029126 0.009621 3.027 0.002484 **
length 0.681405 0.013451 50.658 < 2e-16 ***
freq -0.025164 0.009157 -2.748 0.006026 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.5466 on 3597 degrees of freedom
(71 observations deleted due to missingness)
Multiple R-squared: 0.6963, Adjusted R-squared: 0.6925
F-statistic: 183.3 on 45 and 3597 DF, p-value: < 2.2e-16
我已经发现了这个
sort(sta9$coefficients, decreasing = T);
有效,但它只给我“估计”一栏......
答案 0 :(得分:3)
这是一个符合你想要的线性回归示例:
set.seed(1)
y = rnorm(10);x1 = rnorm(10);x2 = rnorm(10)
m = lm(y ~ x1+ x2)
s = summary(m)
sc = as.data.frame(s$coefficients)
sc[with(sc, order(-Estimate)), ]
这给出了:
R> sc[with(sc, order(-Estimate)), ]
Estimate Std. Error t value Pr(>|t|)
x1 0.06398 0.2405 0.2661 0.79785
(Intercept) 0.03234 0.2128 0.1519 0.88352
x2 -0.62799 0.2691 -2.3332 0.05236
您的主要问题是您使用了来自sta9
的系数向量而不是summary
命令生成的表,即比较:
sta9$coefficients
与
summary(sta9)$coefficients