gpt4 book ai didi

r - lm 中因子的奇怪名称

转载 作者:行者123 更新时间:2023-12-03 16:54:27 28 4
gpt4 key购买 nike

我正在使用来自包鼠标的男孩数据集的数据。当我对其中一个因子变量 (phb) 运行回归时,输出会显示这些因子,但给它们的名称与数据中的名称不同。我想知道为什么会这样。有没有办法纠正它?

library(mice)
data(boys)
# phb is already an ordered factor
table(boys$phb)

P1 P2 P3 P4 P5 P6
63 40 19 32 50 41

>summary(lm(age~factor(phb),data=boys))

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 14.22660 0.09610 148.033 <2e-16 ***
factor(phb).L 6.24873 0.20493 30.492 <2e-16 ***
factor(phb).Q 0.06451 0.23668 0.273 0.785
factor(phb).C 0.10205 0.22300 0.458 0.648
factor(phb)^4 -0.12415 0.23413 -0.530 0.596
factor(phb)^5 -0.12713 0.27299 -0.466 0.642

所以,我的问题是为什么它输出 .L、.Q、.C、^4、^5?我做了一些研究,这似乎代表线性、二次、三次。为什么会这样?我只是希望它是因子(phb)。P1 等。

最佳答案

尝试
因子( x ,有序 = FALSE )

关于r - lm 中因子的奇怪名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33112956/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com