Solutions des TPs
671
12.4- modele.poly <- lm(y∼-1+poly(x,4,raw=TRUE))
summary(modele.poly)
coef <- coef(modele.poly)
plot(y∼x)
curve(coef[1] * x+coef[2] * x^2+coef[3] * x^3+coef[4] * x^4,add=TRUE)
• Ajustement d’un nuage de points par un polynˆ ome
12.1- T´ el´ echargez le fichier http://biostatisticien.eu/springeR/ajustpoly.
RData dans votre r´ epertoire courant.
load("ajustpoly.RData")
attach(ajustpoly)
12.2- plot(Y∼X)
12.3- modele.lin <- lm(Y∼X)
summary(modele.lin)
abline(modele.lin)
12.4- modele.poly <- lm(Y∼poly(X,3,raw=TRUE),data=ajustpoly)
summary(modele.poly)
12.5- coef <- coef(modele.poly)
curve(coef[1]+coef[2] * x+coef[3] * x^2+coef[4] * x^3,add=TRUE)
x <- seq(-3.5,3.5,length=50)
intpred <- predict(modele.poly,data.frame(X=x),
interval="prediction")[,c("lwr","upr")]
intconf <- predict(modele.poly,data.frame(X=x),
interval="confidence")[,c("lwr","upr")]
matlines(x,cbind(intconf,intpred),lty=c(2,2,3,3),
col=c("red","red","blue","blue"),lwd=c(2,2,1,1))
legend("bottomright",lty=c(2,3),lwd=c(2,1),
c("confiance","pr´ evision"),col=c("red","blue"))
Solutions des TPs du chapitre 13
A- ´
Etude sur l’ANOVA ` a un facteur
• ´
Etude sur le niveau sonore
13.1- sonore <- gl(4,6,24)
note <- c(62,60,63,59,63,59,56,62,60,61,63,64,63,67,
71,64,65,66,68,66,71,67,68,68)
Précédent

- 698/701

Suivant