### Exercício 8### 1. # AJUSTE DE POLINÔMIOS init.h = c(600, 700, 800, 950, 1100, 1300, 1500) h.d = c(253, 337, 395, 451, 495, 534, 573) mod1 = lm(init.h~h.d) mod2 = lm(init.h~h.d+I(h.d^2)) mod3 = update(mod2,.~.+I(h.d^3)) anova(mod1,mod2,mod3) # Considerando um intervalo de confianca de 95%, o modelo de polinômio de terceiro grau não é um modelo melhor que o modelo de segundo grau. 2. bebes = read.table ("c:/users/Ricardo/Desktop/R/bebes.txt", header=TRUE, sep=";", fill=TRUE) head(bebes) bebes help(read.table) bebes = na.omit (bebes) head(bebes) table(bebes$gestation) bebes[bebes$gestation==999,] = NA table(bebes$height) bebes[bebes$height==99,] = NA table(bebes$smoke) bebes[bebes$height==9,] = NA par(mfrow=c(2,3)) plot(bwt~gestation, data=bebes) plot(bwt~parity, data=bebes) plot(bwt~age, data=bebes) plot(bwt~height, data=bebes) plot(bwt~weight, data=bebes) plot(bwt~smoke, data=bebes) mod1=lm(bwt~height, data=bebes) summary(mod3) mod2=lm(bwt~gestation, data=bebes) mod3=lm(bwt~weight, data=bebes) mod4 = update(mod3,.~.+height) anova(mod3,mod4) mod5 = update(mod4,.~.+gestation, data=bebes) anova(mod4,mod5) mod6 = update(mod5,.~.+age, data=bebes) anova(mod5,mod6) mod7 = update(mod6,.~.+smoke, data=bebes) anova(mod6,mod7) summary(mod7) mod8 = update(mod7, .~.-weight, data=bebes) summary(mod8) anova(mod8,mod7) ### O melhor modelo é o modelo que inclui o tempo de gestaçao, a altura, a idade, e se a mãe foi fumante.