【发布时间】:2015-06-06 07:43:24
【问题描述】:
我正在尝试使用 rms 包的 fastbw 函数进行后向回归,如下所示(使用 mtcars 数据集):
> mod = ols(mpg~am+vs+cyl+drat+wt+gear, mtcars)
> mod
Linear Regression Model
ols(formula = mpg ~ am + vs + cyl + drat + wt + gear, data = mtcars)
Model Likelihood Discrimination
Ratio Test Indexes
Obs 32 LR chi2 58.26 R2 0.838
sigma 2.7008 d.f. 6 R2 adj 0.799
d.f. 25 Pr(> chi2) 0.0000 g 6.383
Residuals
Min 1Q Median 3Q Max
-4.3807 -1.4314 -0.5405 1.5828 5.4703
Coef S.E. t Pr(>|t|)
Intercept 39.9804 8.8745 4.51 0.0001
am 1.5981 1.9927 0.80 0.4301
vs 0.8011 1.9201 0.42 0.6801
cyl -1.3163 0.7033 -1.87 0.0730
drat 0.3488 1.6201 0.22 0.8313
wt -3.0390 0.9510 -3.20 0.0038
gear -1.1450 1.1420 -1.00 0.3256
> modbw = fastbw(mod)
> modbw
Deleted Chi-Sq d.f. P Residual d.f. P AIC R2
drat 0.05 1 0.8296 0.05 1 0.8296 -1.95 0.838
vs 0.17 1 0.6800 0.22 2 0.8974 -3.78 0.837
am 0.58 1 0.4473 0.79 3 0.8509 -5.21 0.833
gear 0.42 1 0.5194 1.21 4 0.8766 -6.79 0.830
Approximate Estimates after Deleting Factors
Coef S.E. Wald Z P
Intercept 39.686 1.8040 21.999 0.00000000
cyl -1.508 0.4362 -3.457 0.00054706
wt -3.191 0.7962 -4.008 0.00006128
Factors in Final Model
[1] cyl wt
以下是该模型的结构:
> str(modbw)
List of 10
$ result : num [1:4, 1:8] 0.0463 0.1701 0.5775 0.4152 1 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:4] "drat" "vs" "am" "gear"
.. ..$ : chr [1:8] "Chi-Sq" "d.f." "P" "Residual" ...
$ names.kept : chr [1:2] "cyl" "wt"
$ factors.kept : int [1:2] 3 5
$ factors.deleted: int [1:4] 4 2 1 6
$ parms.kept : int [1:3] 1 4 6
$ parms.deleted : int [1:4] 5 3 2 7
$ coefficients : Named num [1:3] 39.69 -1.51 -3.19
..- attr(*, "names")= chr [1:3] "Intercept" "cyl" "wt"
$ var : num [1:3, 1:3] 3.254 -0.303 -0.358 -0.303 0.19 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:3] "Intercept" "cyl" "wt"
.. ..$ : chr [1:3] "Intercept" "cyl" "wt"
$ Coefficients : num [1:4, 1:7] 41.26 43.17 42.39 39.69 1.68 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : NULL
.. ..$ : chr [1:7] "Intercept" "am" "vs" "cyl" ...
$ force : NULL
- attr(*, "class")= chr "fastbw"
以下是summary的输出结构(summary.lm函数不适用于此模型):
> summary(modbw)
Length Class Mode
result 32 -none- numeric
names.kept 2 -none- character
factors.kept 2 -none- numeric
factors.deleted 4 -none- numeric
parms.kept 3 -none- numeric
parms.deleted 4 -none- numeric
coefficients 3 -none- numeric
var 9 -none- numeric
Coefficients 28 -none- numeric
force 0 -none- NULL
>
> summary.lm(modbw)
Error in if (p == 0) { : argument is of length zero
但我在其中任何一个中都找不到 P 值。如何获取 fastbw 函数最终模型的 P 值列表?
【问题讨论】:
-
我很确定
fastbw不 用于统计推断...您是否可以访问 Harrell 的书回归建模策略 ? -
P 值出现在输出中。所以它在这里也必须相当重要。为什么在结构中的任何地方都看不到它?
标签: r regression linear-regression rms