Académique Documents
Professionnel Documents
Culture Documents
> NScarab=c(59,60,62,56,63,59,62,60)
> NScarab
[1] 59 60 62 56 63 59 62 60
[1] 6 13 18 28 52 53 61 60
1
> # Visualiser les observations
>
>
> plot(X,p,ylim=c(0,1))
> # On trace une droite quelquonque
> a=4.8
> b=0.15
> Ylin=a*(X-1.7)+b
> lines(X,Ylin,col="red")
> betaline= p%*%m %*% solve(t(m)%*%m)
> predline= betaline %*% t(m)
> lines(X,predline,col="blue")
> # On trace un ajoustement non-linéaire quelquonque
>
> lines(X, logistique( 40.2 * X - 71 ),col="green")
>
1.0
0.8
0.6
p
0.4
0.2
0.0
2
> REZ=glm(cbind(Y,n-Y) ~ X, family = binomial(link=logit))
> summary(REZ)
Call:
glm(formula = cbind(Y, n - Y) ~ X, family = binomial(link = logit))
Deviance Residuals:
Min 1Q Median 3Q Max
-1.5941 -0.3944 0.8329 1.2592 1.5940
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -60.717 5.181 -11.72 <2e-16 ***
X 34.270 2.912 11.77 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> names(REZ)
> z1=REZ$coefficients[1]/5.181
> # tester l'hypothese H0: beta1=Intercept = 0
>
> alpha=0.95
> CritVal = qnorm( (alpha +1)/2 )
> abs(z1) <= CritVal
(Intercept)
FALSE
3
> # on recupère les estimateurs de beta
>
> beta.est = as.vector(REZ$coefficients)
> beta.est
1 2 3 4 5 6 7
-2.7766148 -1.6285589 -0.5661788 0.4276606 1.3563864 2.2337068 3.0596216
8
3.8444121
> predict.glm(REZ)
1 2 3 4 5 6 7
-2.7766148 -1.6285589 -0.5661788 0.4276606 1.3563864 2.2337068 3.0596216
8
3.8444121
1 2 3 4 5 6 7
-2.7766148 -1.6285589 -0.5661788 0.4276606 1.3563864 2.2337068 3.0596216
8
3.8444121
> predict(REZ,type="link")
1 2 3 4 5 6 7
-2.7766148 -1.6285589 -0.5661788 0.4276606 1.3563864 2.2337068 3.0596216
8
3.8444121
4
> predict.glm(REZ,type="response")
1 2 3 4 5 6 7
0.05860103 0.16402787 0.36211901 0.60531491 0.79517177 0.90323582 0.95519611
8
0.97904934
> predict(REZ,type="response")
1 2 3 4 5 6 7
0.05860103 0.16402787 0.36211901 0.60531491 0.79517177 0.90323582 0.95519611
8
0.97904934
> pest
0.4
0.2
0.0