Step: AIC=35.07 y ~ x1 + x4
Df Deviance AIC
> summary(glm.new)
Call:
glm(formula = y ~ x1 + x4, family = binomial, data = cancer)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.4825 -0.6617 -0.1877 0.1227 2.2844
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -6.13755 2.73844 -2.241 0.0250 * x1 0.09759 0.04079 2.393 0.0167 * x4 -1.12524 0.60239 -1.868 0.0618 . ---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 44.987 on 39 degrees of freedom Residual deviance: 29.073 on 37 degrees of freedom AIC: 35.073
Number of Fisher Scoring iterations: 6 回归方程为
P=exp(-6.13755+0.09759x1-1.12524x4)/(1+exp(-6.13755+0.09759x1-1.12524x4)) 概率估计略。
Ex6.9
我表示不想做了...
我没弄明白nls()函数里所说的start即初始值怎么设置。好像可以随便设置,只要保证函数收敛即可??
Ex7.1 (1)
>lamp<-data.frame(X=c(115,116,98,83,103,107,118,116,73,89,85,97),A=factor(rep(1:3,c(4,4,4))))
> lamp.aov<-aov(X~A,data=lamp);summary(lamp.aov) Df Sum Sq Mean Sq F value Pr(>F) A 2 1304 652.0 4.923 0.0359 * Residuals 9 1192 132.4 P值小于0.05,有显著差异。 (2)
对甲的区间估计:
> a<-c(115,116,98,83) > t.test(a)
One Sample t-test
data: a
t = 13.1341, df = 3, p-value = 0.0009534
alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 78.04264 127.95736 sample estimates: mean of x 103
或者用这个命令更简单:
>attach(lamp) > t.test(X[A==1])
乙的均值估计为111,95%置信区间为99.59932, 122.40068。 丙的均值估计为86,95%置信区间为70.08777, 101.91223。 (3)多重检验: > attach(lamp) P值不做调整:
> pairwise.t.test(X,A,p.adjust.method = \
Pairwise comparisons using t tests with pooled SD
data: X and A
1 2 2 0.351 -
3 0.066 0.013
P值进行Holm调整:
P value adjustment method: none
> pairwise.t.test(X,A,p.adjust.method = \
Pairwise comparisons using t tests with pooled SD
data: X and A
1 2 2 0.35 - 3 0.13 0.04
P value adjustment method: holm
不论采取哪种方法,都可看出乙和丙有显著差异。
Ex7.2 (1)
>lamp<-data.frame(X=c(20,18,18,17,15,16,13,18,22,17,26,19,26,28,23,25,24,25,18,22,27,24,12,14),A=factor(rep(1:4,c(10,6,6,2)))) > lamp.aov<-aov(X ~ A, data=lamp);summary(lamp.aov) Df Sum Sq Mean Sq F value Pr(>F)
A 3 351.7 117.24 15.11 2.28e-05 *** Residuals 20 155.2 7.76
P值小于0.05,可认为四个厂生产的产品的变化率有显著差异。 (2)
> attach(lamp) P值不做调整:
> pairwise.t.test(X,A,p.adjust.method = \
Pairwise comparisons using t tests with pooled SD
data: X and A
1 2 3 2 8.0e-05 - - 3 0.00053 0.47666 -
4 0.05490 6.1e-05 0.00020
P value adjustment method: none P值进行Holm调整:
> pairwise.t.test(X,A,p.adjust.method = \
Pairwise comparisons using t tests with pooled SD
data: X and A
1 2 3 2 0.00040 - - 3 0.00158 0.47666 -
4 0.10979 0.00036 0.00079
P value adjustment method: holm
由此可得,除了A1和A4,A2和A3这两组的差异不显著外,其他组合的差异都很显著。
Ex7.3
>lamp1<-data.frame(X=c(30,27,35,35,29,33,32,36,26,41,33,31,43,45,53,44,51,53,54,37,47,57,48,42,82,66,66,86,56,52 ,76,83,72,73,59,53),A=factor(rep(1:3,c(12,12,12)))) >attach(lamp1) 正态性检验:
> shapiro.test(X[A==1])
Shapiro-Wilk normality test
data: X[A == 1]
W = 0.9731, p-value = 0.9407
> shapiro.test(X[A==2])
Shapiro-Wilk normality test
data: X[A == 2]
W = 0.9708, p-value = 0.9193
> shapiro.test(X[A==3])
Shapiro-Wilk normality test
data: X[A == 3]
W = 0.9371, p-value = 0.4613 数据在三种水平下均是正态的。 方差齐性检验:
> bartlett.test(X~A,data=lamp1)
Bartlett test of homogeneity of variances
data: X by A
Bartlett's K-squared = 12.139, df = 2, p-value = 0.002312 P值小于0.05,认为各组方差不等。
Ex7.4
>lamp<-data.frame(X=c(2.79,2.69,3.11,3.47,1.77,2.44,2.83,2.52,3.83,3.15,4.70,3.97,2.03,2.87,3.65,5.09,5.41,3.47,4.92,4.07,2.18,3.13,3.77,4.26),
相关推荐: