我正在运行线性模型来查看所涉及的独立因素的重要性。示例模型是:`
mymod1 <- lm(temp ~ bgrp+psex+tb,data=mydat)
summary(mymod1)`
我查看摘要以检查每个因素的重要性:
lm(formula = temp ~ bgrp + psex + tb, data = mydat)
Residuals:
Min 1Q Median 3Q Max
-5.6877 -0.2454 0.0768 0.3916 1.6561
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 37.324459 0.186081 200.581 < 2e-16 ***
bgrp 0.256794 0.066167 3.881 0.000115 ***
psex 0.144669 0.055140 2.624 0.008913 **
tb 0.019818 0.009342 2.121 0.034287 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.6888 on 621 degrees of freedom
(5 observations deleted due to missingness)
Multiple R-squared: 0.03675, Adjusted R-squared: 0.03209
F-statistic: 7.897 on 3 and 621 DF, p-value: 3.551e-05
现在,我想看看bgrp(1和2)和psex(1和2)这两个级别的解决方案。
如果您能帮我解决这个问题,我将不胜感激。
提前谢谢你,
巴兹
编辑:
我运行了您建议的第一个模型并得到以下结果:
mydat$bgrp <- as.factor(mydat$bgrp)
> summary(lm(temp ~ bgrp+psex+tb-1,data=mydat))
Call:
lm(formula = temp ~ bgrp + psex + tb - 1, data = apirt)
Residuals:
Min 1Q Median 3Q Max
-5.6877 -0.2454 0.0768 0.3916 1.6561
Coefficients:
Estimate Std. Error t value Pr(>|t|)
bgrp1 37.725922 0.135486 278.449 < 2e-16 ***
bgrp2 37.982716 0.129558 293.171 < 2e-16 ***
psex2 0.144669 0.055140 2.624 0.00891 **
tb 0.019818 0.009342 2.121 0.03429 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.6888 on 621 degrees of freedom
(5 observations deleted due to missingness)
Multiple R-squared: 0.9997, Adjusted R-squared: 0.9997
F-statistic: 4.788e+05 on 4 and 621 DF, p-value: < 2.2e-16
从上面的系数表来看,bgrp1 和 bgrp2 似乎是有道理的:bgrp1 代表产仔数较大的母系,后代较轻,这导致后代的直肠温度较低(37.70 摄氏度)。另一方面,bgrp2 代表产仔数较小、后代较重的终端线,这导致直肠温度较高(37.98 摄氏度)。我只是想知道,是否可以对 psex1 和 psex2 执行相同的操作,但是系数表中显示的内容可能是由于您之前所说的。
编辑:嗨,马克,
我尝试了您建议的两个选项,我可以看到 bgrp1 和 psex1 具有相同的值:
> mybgrp <- lm(formula = temp ~ bgrp+psex+tb-1, data = mydat)
> mybgrp
Call:
lm(formula = temp ~ bgrp + psex + tb - 1, data = mydat)
Coefficients:
bgrp1 bgrp2 psex2 tb
37.72592 37.98272 0.14467 0.01982
> summary(mybgrp)
Call:
lm(formula = temp ~ bgrp + psex + tb - 1, data = mydat)
Residuals:
Min 1Q Median 3Q Max
-5.6877 -0.2454 0.0768 0.3916 1.6561
Coefficients:
Estimate Std. Error t value Pr(>|t|)
bgrp1 37.725922 0.135486 278.449 < 2e-16 ***
bgrp2 37.982716 0.129558 293.171 < 2e-16 ***
psex2 0.144669 0.055140 2.624 0.00891 **
tb 0.019818 0.009342 2.121 0.03429 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.6888 on 621 degrees of freedom
(5 observations deleted due to missingness)
Multiple R-squared: 0.9997, Adjusted R-squared: 0.9997
F-statistic: 4.788e+05 on 4 and 621 DF, p-value: < 2.2e-16
> mypsex <- lm(formula = temp ~ psex+bgrp+tb-1, data = mydat)
> mypsex
Call:
lm(formula = temp ~ psex + bgrp + tb - 1, data = mydat)
Coefficients:
psex1 psex2 bgrp2 tb
37.72592 37.87059 0.25679 0.01982
> summary(mypsex)
Call:
lm(formula = temp ~ psex + bgrp + tb - 1, data = mydat)
Residuals:
Min 1Q Median 3Q Max
-5.6877 -0.2454 0.0768 0.3916 1.6561
Coefficients:
Estimate Std. Error t value Pr(>|t|)
psex1 37.725922 0.135486 278.449 < 2e-16 ***
psex2 37.870591 0.135908 278.649 < 2e-16 ***
bgrp2 0.256794 0.066167 3.881 0.000115 ***
tb 0.019818 0.009342 2.121 0.034287 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.6888 on 621 degrees of freedom
(5 observations deleted due to missingness)
Multiple R-squared: 0.9997, Adjusted R-squared: 0.9997
F-statistic: 4.788e+05 on 4 and 621 DF, p-value: < 2.2e-16
谢谢!