我有以下回归
c<- glm (z[2:length(z)]~ Dxu10+Dxi10+Dxa10+Dxb10+Dxc10 +Dxd10+Dxe10+Dxf10)
我为变量选择执行steepAIC
st1<-stepAIC(c, scale = 0,direction = c("both"),trace = 1, keep = NULL, steps = 1000,
use.start = FALSE,k = 2)
st2<-stepAIC(c, scale = 0,direction = c("forward"),trace = 1, keep = NULL, steps =
1000,use.start = FALSE,k = 2)
st3<-stepAIC(c, scale = 0,direction = c("backward"),trace = 1, keep = NULL, steps =
1000,use.start = FALSE,k = 2)
我从中获得
summary(st1)$coefficients
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.006993197279 0.00184524256 3.789852580 0.0001837029031540622766791038
Dxu10 -0.716501556217 0.07390750712 -9.694570743 0.0000000000000000002079180098
Dxi10 0.590876615303 0.10750681474 5.496178235 0.0000000857314345082674945844
Dxa10 0.844200223791 0.15866854150 5.320526778 0.0000002086989035634347231570
Dxb10 0.956284808429 0.21125669477 4.526648538 0.0000087898612369329389218398
Dxc10 1.078511870491 0.29582536479 3.645772131 0.0003164334473070340479974871
Dxd10 1.155441543282 0.56627553660 2.040422848 0.0422232960663285333824390477
summary(st2)$coefficients
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.006993197279 0.00184524256 3.789852580 0.0001837029031540622766791038
Dxu10 -0.716501556217 0.07390750712 -9.694570743 0.0000000000000000002079180098
Dxi10 0.590876615303 0.10750681474 5.496178235 0.0000000857314345082674945844
Dxa10 0.844200223791 0.15866854150 5.320526778 0.0000002086989035634347231570
Dxb10 0.956284808429 0.21125669477 4.526648538 0.0000087898612369329389218398
Dxc10 1.078511870491 0.29582536479 3.645772131 0.0003164334473070340479974871
Dxd10 1.155441543282 0.56627553660 2.040422848 0.0422232960663285333824390477
summary(st3)$coefficients
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.006993197279 0.001847746243 3.7847173574 0.0001876030310082417635643426
Dxu10 -0.716494801892 0.074007787774 -9.6813433213 0.0000000000000000002379841555
Dxi10 0.590829933159 0.107652704302 5.4882962485 0.0000000897284090545896811496
Dxa10 0.844467615482 0.158884293731 5.3149848588 0.0000002155548361048376260901
Dxb10 0.954943794890 0.211552134711 4.5139879879 0.0000093181083254695419243810
Dxc10 1.085079304770 0.296378110020 3.6611317371 0.0002992055447114028610307301
Dxd10 1.063561741624 0.581825116235 1.8279749566 0.0685986302886704285564078987
Dxe10 1.107517771712 1.600387682825 0.6920309270 0.4894813128833755966340390842
Dxf10 0.455031358074 1.231561429324 0.3694751616 0.7120479544944554595176100520
我想从摘要(st1),摘要(st2)和摘要(st3)中提取系数“Dxd10”,“Dxc10”等的名称,在各自的列Pr(&gt; | t |)中小于0.1。
我知道如何逐个提取系数“summary(st1)$ coefficients [2,4]”而不是名字。我相信哪个功能会有效,但尝试没有成功
答案 0 :(得分:3)
lapply(list(st1, st2, st3), function(x) {
tmp <- coef(summary(x))[, 4]
names(tmp)[tmp < 0.1]
})
这将返回一个向量列表,包括系数的名称。