% COMANDOS EM R REFERENTES AO EXEMPLO RECRUTAS recrutas = read.table("c:\\recrutas.txt", header=TRUE) attach(recrutas) require(robustbase) par(mfrow=c(1,2)) boxplot(split(ninfec,habito)) adj(split(ninfec,habito)) boxplot(split(ninfec,local)) adj(split(ninfec,local)) boxplot(split(ninfec,fetaria)) adj(split(ninfec,fetaria)) boxplot(split(ninfec,genero)) adj(split(ninfec,genero)) ajuste1_recrutas = glm(ninfec ~ habito + local + fetaria + genero + + habito*local + habito*local + habito*fetaria + local*fetaria + local*genero + + fetaria*genero, family=poisson) require(MASS) stepAIC(ajuste1_recrutas) ajuste2_recrutas = glm(ninfec ~ habito + local + fetaria + genero + + habito*local + habito*fetaria + local*fetaria + local*genero, family=poisson) summary(ajute2_recrutas) fit.model = ajuste2_recrutas source("c:\\envel_pois") ajuste3_recrutas = glm.nb(ninfec ~ habito + local + fetaria + genero + + habito*local + habito*local + habito*fetaria + local*fetaria + local*genero + + fetaria*genero) stepAIC(ajuste3_recrutas) ajuste4_recrutas = glm.nb(ninfec ~ habito + local + genero + local*genero) fit.model = ajuste4_recrutas source("c:\\envel_nbin") source("c:\\diag_cook_nbin") ajuste5_recrutas = glm.nb(ninfec ~ habito + local + genero + local*genero, subset=-249) summary(ajuste5_recrutas) ajuste6_recrutas = glm.nb(ninfec ~ habito + local + genero) summary(ajuste6_recrutas) ajuste7_recrutas = glm.nb(ninfec ~ habito + local) summary(ajuste7_recrutas) fit.model = ajuste7_recrutas source("c:\\envel_nbin") source("c:\\diag_cook_nbin") require(gamlss) ajuste8_recrutas = gamlss(ninfec ~ habito + local, family=NBI) summary(ajuste8_recrutas) plot(ajuste8_recrutas) wp(ajuste8_recrutas) rqres.plot(ajuste8_recrutas, howmany=6, type="wp") rqres.plot(ajuste8_recrutas, howmany=40, plot="all") ajuste9_recrutas = gamlss(ninfec ~ habito + local + fetaria + genero + fetaria*genero, ~ habito + local, family=ZAP) summary(ajuste9_recrutas) plot(ajuste9_recrutas) % Modelo Final ajuste10_recrutas = gamlss(ninfec ~ habito,~1, ~habito + local, + family=ZANBI) summary(ajuste10_recrutas) plot(ajuste10_recrutas) wp(ajuste10_recrutas) rqres.plot(ajuste10_recrutas, howmany=6, type="wp") rqres.plot(ajuste10_recrutas, howmany=40, plot="all") recrutas1 = recrutas{-249,1] ajuste11_recrutas = gamlss(ninfec ~ habito,~1, ~habito + local, + family=ZANBI, data=recrutas1) summary(ajuste11_recrutas)