R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-pc-linux-gnu (64-bit) R est un logiciel libre livré sans AUCUNE GARANTIE. Vous pouvez le redistribuer sous certaines conditions. Tapez 'license()' ou 'licence()' pour plus de détails. R est un projet collaboratif avec de nombreux contributeurs. Tapez 'contributors()' pour plus d'information et 'citation()' pour la façon de le citer dans les publications. Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide en ligne ou 'help.start()' pour obtenir l'aide au format HTML. Tapez 'q()' pour quitter R. > date() [1] "Thu Sep 22 16:14:37 2011" > ################################################### > ### chunk number 2: a02 > ################################################### > #line 78 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > (mal <- c(120,107,110,116,114,111,113,117,114,112)) [1] 120 107 110 116 114 111 113 117 114 112 > (fem <- c(110,111,107,108,110,105,107,106,111,111)) [1] 110 111 107 108 110 105 107 106 111 111 > > > ################################################### > ### chunk number 3: a03 > ################################################### > #line 86 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > tot <- c(mal,fem) > par(mfrow=c(1,2)) > hist(tot,nclass=8, las = 1, col = grey(0.7), label = T, ylim = c(0, 6), + main = "Histogramme global", xlab = "Longueur de la mâchoire [mm]") # \textit{ne dit pas grand chose} > qqnorm(tot, pch = 19) > qqline(tot) # \textit{petit échantillon} > > > ################################################### > ### chunk number 4: a04 > ################################################### > #line 100 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > shapiro.test(tot) Shapiro-Wilk normality test data: tot W = 0.9593, p-value = 0.5298 > > > ################################################### > ### chunk number 5: a05 > ################################################### > #line 104 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > shapiro.test(c(rnorm(n = 10, mean = 1, sd = 1),rnorm(n = 10, mean = 10, sd = 1))) Shapiro-Wilk normality test data: c(rnorm(n = 10, mean = 1, sd = 1), rnorm(n = 10, mean = 10, sd = 1)) W = 0.8357, p-value = 0.003093 > > > ################################################### > ### chunk number 6: a06 > ################################################### > #line 190 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > set.seed(01071966) #magic value for reproducibility > > > ################################################### > ### chunk number 7: a07 > ################################################### > #line 193 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > experience <- function(n = 5) sort(rnorm(n)) > w <- replicate(n = 1000, experience()) > par(mfrow=c(2,2), lend = "butt") > hist(w[1,], main = "Valeurs de rang 1", col = grey(0.7), xlab = "Rang 1") > hist(w[5,], main = "Valeurs de rang 5", col = grey(0.7), xlab = "Rang 5") > plot(w[1,],w[2,], xlab = "Rang 1", ylab = "Rang 2", + main = "Comparaison des rangs 1 et 2") > abline(c(0,1), col = "red", lwd = 2) > legend("bottomright", inset = 0.05, lwd = 2, col = "red", legend = "y = x") > plot(w[3,],w[5,], xlab = "Rang 3", ylab = "Rang 5", + main = "Comparaison des rangs 3 et 5") > abline(c(0,1), col = "red", lwd = 2) > legend("bottomright", inset = 0.05, lwd = 2, col = "red", legend = "y = x") > > > ################################################### > ### chunk number 8: a07bis > ################################################### > #line 213 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > apply(w,1,mean) [1] -1.185468519 -0.501683585 -0.008163906 0.497183502 1.162242672 > apply(w,1,sd) [1] 0.6832505 0.5851967 0.5474989 0.5843313 0.6652861 > round(cor(t(w)),dig=2) [,1] [,2] [,3] [,4] [,5] [1,] 1.00 0.62 0.44 0.30 0.21 [2,] 0.62 1.00 0.72 0.51 0.35 [3,] 0.44 0.72 1.00 0.70 0.41 [4,] 0.30 0.51 0.70 1.00 0.60 [5,] 0.21 0.35 0.41 0.60 1.00 > > > ################################################### > ### chunk number 9: a08 > ################################################### > #line 227 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > w <- replicate(n = 1000, experience(length(tot))) > moy <- rowMeans(w) > a1 <- (cor(sort(tot), moy))^2 > a2 <- (cor(sort(tot), qnorm(ppoints(20))))^2 > a3 <- shapiro.test(tot)$statistic > c(a1,a2,a3) W 0.9586477 0.9608445 0.9592896 > > > ################################################### > ### chunk number 10: a09 > ################################################### > #line 243 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > monplot <- function(x){ + test <- shapiro.test(x) + qqnorm(x , main = paste("W =",signif(test$statistic,3), "----", "p =",signif(test$p.value,3)), + pch = 19) + qqline(x) + } > par(mfrow =c(1,3)) > monplot(rexp(20)) > monplot(rnorm(20)) > monplot(qnorm(seq(0.025, 0.975, by = 0.05))) > > > ################################################### > ### chunk number 11: a10 > ################################################### > #line 264 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > shapiro.test(mal) Shapiro-Wilk normality test data: mal W = 0.9937, p-value = 0.9995 > shapiro.test(fem) Shapiro-Wilk normality test data: fem W = 0.8809, p-value = 0.1335 > > > ################################################### > ### chunk number 12: a11 > ################################################### > #line 279 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > plan <- gl(n = 2, k = 10, lab = c("mal","fem")) > bartlett.test(tot,plan) Bartlett test of homogeneity of variances data: tot and plan Bartlett's K-squared = 1.9942, df = 1, p-value = 0.1579 > var.test(mal,fem) F test to compare two variances data: mal and fem F = 2.681, num df = 9, denom df = 9, p-value = 0.1579 alternative hypothesis: true ratio of variances is not equal to 1 95 percent confidence interval: 0.665931 10.793829 sample estimates: ratio of variances 2.681034 > > > ################################################### > ### chunk number 13: a12 > ################################################### > #line 287 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > plot(log) > points(0.1,log(0.1),pch=20,cex=2) > points(0.6,log(0.6),pch=20,cex=2) > points(0.25,log(0.25),pch=20,cex=2) > abline(c(-0.2*log(6)+log(0.1),log(6)/0.5)) > abline(v=0.25,lty=2)#0.1+0.5*2/6 > > > ################################################### > ### chunk number 14: a13 > ################################################### > #line 327 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > f1 <- function(k) { + x <- rnorm(11, 1,5) ; y <- rnorm(21, 3,5) + vx <- var(x) ; vy <- var(y) + vmoy <- (10*vx+20*vy)/30 + w <- 30*log(vmoy) -10*log(vx) -20*log(vy) + return(w) + } > par(mfrow=c(1,2)) > w <- unlist(lapply(1:1000,f1)) > hist(w,proba=T,nclass=50) > lines(x0<-seq(0.1,10,le=50),dchisq(x0,1),lwd=2,col="red") > qqplot(qchisq(ppoints(n = 5000), df = 1), sort(w), + main = "ChiSquare 1ddl Q-Q Plot", xlab = "Theoretical Quantiles", + ylab = "Sample Quantiles", las = 1) > abline(0, 1) > > > ################################################### > ### chunk number 15: a14 > ################################################### > #line 352 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > moy <- tapply(tot,plan,mean) > par(mfrow=c(1,2)) > dotchart(tot,gr=plan,gdata=moy,gpch=19) > boxplot(split(tot,plan)) > > > ################################################### > ### chunk number 16: a15 > ################################################### > #line 362 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > TMF <- t.test(mal,fem, var.equal = TRUE) > ANOVAMF <- anova(lm(tot~plan)) > TMF Two Sample t-test data: mal and fem t = 3.4843, df = 18, p-value = 0.002647 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 1.905773 7.694227 sample estimates: mean of x mean of y 113.4 108.6 > ANOVAMF Analysis of Variance Table Response: tot Df Sum Sq Mean Sq F value Pr(>F) plan 1 115.2 115.200 12.14 0.002647 ** Residuals 18 170.8 9.489 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > > > ################################################### > ### chunk number 17: a16 > ################################################### > #line 381 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > sum((mal-mean(mal))^2)+sum((fem-mean(fem))^2) [1] 170.8 > v<-(sum((mal-mean(mal))^2)+sum((fem-mean(fem))^2))/(10+10-2) > > > ################################################### > ### chunk number 18: a17 > ################################################### > #line 386 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > md <- mean(mal)-mean(fem) > > > ################################################### > ### chunk number 19: a18 > ################################################### > #line 399 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > vd <- v*(1/10+1/10) > vd [1] 1.897778 > > > ################################################### > ### chunk number 20: a19 > ################################################### > #line 412 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > (md-20)/sqrt(vd) [1] -11.03369 > pt((md-20)/sqrt(vd),18) [1] 9.627822e-10 > > > ################################################### > ### chunk number 21: a20 > ################################################### > #line 417 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > pt((md-10)/sqrt(vd),18) [1] 0.000693747 > > > ################################################### > ### chunk number 22: a21 > ################################################### > #line 422 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > pt((md-1)/sqrt(vd),18) [1] 0.9935312 > 1-pt((md-1)/sqrt(vd),18) [1] 0.006468819 > > > ################################################### > ### chunk number 23: a22 > ################################################### > #line 426 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > mini <- signif(TMF[[4]][1],4) > maxi <- signif(TMF[[4]][2],4) > > > ################################################### > ### chunk number 24: a23 > ################################################### > #line 439 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > y1 <- c(124, 42, 25, 45, 412, 51, 1112, 46, 103, 876, 146, 340, 396) > y2 <- c(1235, 24, 1581, 1166, 40, 727, 3808, 791, 1804, 3460, 719) > par (mfrow=c(1,2)) > qqnorm(y1) ; qqline(y1) ; qqnorm(y2) ; qqline(y2) > shapiro.test(y1) Shapiro-Wilk normality test data: y1 W = 0.7547, p-value = 0.002075 > shapiro.test(y2) Shapiro-Wilk normality test data: y2 W = 0.8686, p-value = 0.07431 > > > ################################################### > ### chunk number 25: a24 > ################################################### > #line 452 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > wilcox.test(y1,y2) Wilcoxon rank sum test data: y1 and y2 W = 31, p-value = 0.01836 alternative hypothesis: true location shift is not equal to 0 > > > ################################################### > ### chunk number 26: a25 eval=FALSE > ################################################### > ## #line 456 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > ## help(wilcox.test) > > > ################################################### > ### chunk number 27: a26 eval=FALSE > ################################################### > ## #line 464 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > ## wilcox.test > > > ################################################### > ### chunk number 28: a27 eval=FALSE > ################################################### > ## #line 468 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > ## methods(wilcox.test) > > > ################################################### > ### chunk number 29: a28 eval=FALSE > ################################################### > ## #line 472 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > ## getAnywhere(wilcox.test.default) > > > ################################################### > ### chunk number 30: a29 > ################################################### > #line 476 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > t.test(mal,fem)$conf.int [1] 1.861895 7.738105 attr(,"conf.level") [1] 0.95 > wilcox.test(mal,fem,conf.int=T)$conf.int [1] 1.999999 7.999950 attr(,"conf.level") [1] 0.95 Messages d'avis : 1: In wilcox.test.default(mal, fem, conf.int = T) : impossible de calculer la p-value exacte avec des ex-aequos 2: In wilcox.test.default(mal, fem, conf.int = T) : impossible de calculer les intervalles de confiance exacts avec des ex-aequos > > > ################################################### > ### chunk number 31: a30 > ################################################### > #line 484 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > sample(1:5,2) [1] 2 1 > > > ################################################### > ### chunk number 32: a31 > ################################################### > #line 488 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > sum(sample(1:5,2)) [1] 8 > > > ################################################### > ### chunk number 33: a32 > ################################################### > #line 572 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > sim1 <- function(x=0,m,n) { + a=sample(1:(n+m),m,rep=F) + a=sum(a) + a=a-m*(m+1)/2 + return(a) + } > sim1(m=2,n=3) [1] 2 > > > ################################################### > ### chunk number 34: a33 > ################################################### > #line 582 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > w <- sapply(1:1000,sim1,m=2,n=3) > table(w) w 0 1 2 3 4 5 6 114 97 194 183 218 89 105 > dwilcox(0:6,2,3) [1] 0.1 0.1 0.2 0.2 0.2 0.1 0.1 > > > ################################################### > ### chunk number 35: a34 > ################################################### > #line 595 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > dwilcox(0:9,3,3) [1] 0.05 0.05 0.10 0.15 0.15 0.15 0.15 0.10 0.05 0.05 > > > ################################################### > ### chunk number 36: a35 > ################################################### > #line 599 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > wilcox.test (c(2.3,3.6,8.1,3.4),c(12.1,9.7,9.6,8.3),alt="l") Wilcoxon rank sum test data: c(2.3, 3.6, 8.1, 3.4) and c(12.1, 9.7, 9.6, 8.3) W = 0, p-value = 0.01429 alternative hypothesis: true location shift is less than 0 > > > ################################################### > ### chunk number 37: a36 > ################################################### > #line 603 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > wilcox.test (c(2.3,3.6,8.1,3.4),c(12.1,9.7,9.6,8.3)) Wilcoxon rank sum test data: c(2.3, 3.6, 8.1, 3.4) and c(12.1, 9.7, 9.6, 8.3) W = 0, p-value = 0.02857 alternative hypothesis: true location shift is not equal to 0 > > > ################################################### > ### chunk number 38: a37 > ################################################### > #line 607 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > wilcox.test (c(2.3,3.6,8.1,3.4),c(12.1,9.7,9.6,8.3),alt="g") Wilcoxon rank sum test data: c(2.3, 3.6, 8.1, 3.4) and c(12.1, 9.7, 9.6, 8.3) W = 0, p-value = 1 alternative hypothesis: true location shift is greater than 0 > > > ################################################### > ### chunk number 39: a38 > ################################################### > #line 681 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > arbre <- list() > arbre$hau <- c(23.4,24.4,24.6,24.9,25.0,26.2,26.3,26.8,26.8,26.9,27.0,27.6,27.7,22.5,22.9,23.7,24.0,24.4,24.5,25.3, + 26.0,26.2,26.4,26.7,26.9,27.4,28.5) > w <- as.factor(c(1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2)) > levels(w) <- c("T1","T2") > arbre$type <- w > > > ################################################### > ### chunk number 40: a39 > ################################################### > #line 689 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > arbre$hau [1] 23.4 24.4 24.6 24.9 25.0 26.2 26.3 26.8 26.8 26.9 27.0 27.6 27.7 22.5 22.9 [16] 23.7 24.0 24.4 24.5 25.3 26.0 26.2 26.4 26.7 26.9 27.4 28.5 > arbre$type [1] T1 T1 T1 T1 T1 T1 T1 T1 T1 T1 T1 T1 T1 T2 T2 T2 T2 T2 T2 T2 T2 T2 T2 T2 T2 [26] T2 T2 Levels: T1 T2 > > > ################################################### > ### chunk number 41: a40 > ################################################### > #line 694 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > table(arbre$hau > median(arbre$hau),arbre$type) T1 T2 FALSE 6 9 TRUE 7 5 > > > ################################################### > ### chunk number 42: a41 > ################################################### > #line 699 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > debout <- c(20.4,25.4,25.6,25.6,26.6,28.6,28.7,29.0,29.8,30.5,30.9,31.1) > abattu <- c(21.7,26.3,26.8,28.1,26.2,27.3,29.5,32.0,30.9,32.3,32.3,31.7) > > > ################################################### > ### chunk number 43: a42 > ################################################### > #line 705 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > arbre$hau <- c(arbre$hau,19.9,21.1,21.2,22.1,22.5,23.6,24.5,24.6,26.2,26.7) > w <- c(as.character(w), rep("T3",10)) > levels(w) <- c("T1","T2") > arbre$type <- as.factor(w) > > > ################################################### > ### chunk number 44: a43 > ################################################### > #line 711 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > arbre$hau [1] 23.4 24.4 24.6 24.9 25.0 26.2 26.3 26.8 26.8 26.9 27.0 27.6 27.7 22.5 22.9 [16] 23.7 24.0 24.4 24.5 25.3 26.0 26.2 26.4 26.7 26.9 27.4 28.5 19.9 21.1 21.2 [31] 22.1 22.5 23.6 24.5 24.6 26.2 26.7 > arbre$type [1] T1 T1 T1 T1 T1 T1 T1 T1 T1 T1 T1 T1 T1 T2 T2 T2 T2 T2 T2 T2 T2 T2 T2 T2 T2 [26] T2 T2 T3 T3 T3 T3 T3 T3 T3 T3 T3 T3 Levels: T1 T2 T3 > > > ################################################### > ### chunk number 45: a44 > ################################################### > #line 720 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > pomme <- matrix(c(527,633,642,623,377,604,600,708,550,408,606,650,662,562,500,533,567,504,667,333),ncol=4) > > > ################################################### > ### chunk number 46: a45 > ################################################### > #line 723 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > pomme [,1] [,2] [,3] [,4] [1,] 527 604 606 533 [2,] 633 600 650 567 [3,] 642 708 662 504 [4,] 623 550 562 667 [5,] 377 408 500 333 > > > ################################################### > ### chunk number 47: a45 > ################################################### > #line 727 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > pomme.vec<-as.vector(pomme) > traitement<-as.factor(row(pomme)) > bloc<-as.factor(col(pomme)) > friedman.test(pomme.vec,traitement,bloc) Friedman rank sum test data: pomme.vec, traitement and bloc Friedman chi-squared = 9.8, df = 4, p-value = 0.04393 > > > ################################################### > ### chunk number 48: a46 > ################################################### > #line 735 "/bge/penel/verif_pedadoc/pedadoc/fichestd/tdr31//tdr31.rnw" > anova(lm(pomme.vec~traitement+bloc),test="F") Analysis of Variance Table Response: pomme.vec Df Sum Sq Mean Sq F value Pr(>F) traitement 4 133419 33355 9.5763 0.001026 ** bloc 3 14987 4996 1.4343 0.281402 Residuals 12 41797 3483 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > > > > proc.time() utilisateur système écoulé 1.012 0.048 1.066