回复 第1楼 的 szwaf:
doctorjxd老师说的那样,如下面的例子:
> require(graphics)<br />
><br />
> ## Annette Dobson (1990) "An Introduction to Generalized Linear Models".<br />
> ## Page 9: Plant Weight Data.<br />
> ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)<br />
> trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)<br />
> group <- gl(2, 10, 20, labels = c("Ctl","Trt"))<br />
> weight <- c(ctl, trt)<br />
> lm.D9 <- lm(weight ~ group)<br />
> summary(lm.D9)</p>
<p>Call:<br />
lm(formula = weight ~ group)</p>
<p>Residuals:<br />
Min 1Q Median 3Q Max<br />
-1.0710 -0.4938 0.0685 0.2462 1.3690 </p>
<p>Coefficients:<br />
Estimate Std. Error t value Pr(>|t|)<br />
(Intercept) 5.0320 0.2202 22.850 9.55e-15 ***<br />
groupTrt -0.3710 0.3114 -1.191 0.249<br />
---<br />
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</p>
<p>Residual standard error: 0.6964 on 18 degrees of freedom<br />
Multiple R-squared: 0.07308, Adjusted R-squared: 0.02158<br />
F-statistic: 1.419 on 1 and 18 DF, p-value: 0.249</p>
<p>> names(lm.D9)<br />
[1] "coefficients" "residuals" "effects" "rank"<br />
[5] "fitted.values" "assign" "qr" "df.residual"<br />
[9] "contrasts" "xlevels" "call" "terms"<br />
[13] "model"<br />
> summary(lm.D9)$coefficients<br />
Estimate Std. Error t value Pr(>|t|)<br />
(Intercept) 5.032 0.2202177 22.85012 9.547128e-15<br />
groupTrt -0.371 0.3114349 -1.19126 2.490232e-01<br />
> summary(lm.D9)$residuals<br />
1 2 3 4 5 6 7 8 9 10 11<br />
-0.862 0.548 0.148 1.078 -0.532 -0.422 0.138 -0.502 0.298 0.108 0.149<br />
12 13 14 15 16 17 18 19 20<br />
-0.491 -0.251 -1.071 1.209 -0.831 1.369 0.229 -0.341 0.029<br />
><br />
</p>