<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-size: 12pt;">Caro Colegas r-br,</div><div style="font-size: 12pt;"><br></div><div style="font-size: 12pt;">Boa tarde.</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">Nesse exemplo abaixo é certo transformar um dado quantitativo em fator para depois fazer a analise de variância? Obrigado</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">Alisson Lucrécio da Costa<br></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">adi <- expand.grid(cult=gl(1,5,la=LETTERS[1]), fert=101)</div><div style="background-color: transparent;">fat <- expand.grid(cult=gl(5,5,la=LETTERS[2:6]), fert=seq(50,150,25))</div><div style="background-color: transparent;">da
<- rbind(adi, fat)</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">theta <- c(c(-194.29, -197.26, -197.85, -203.03, -190.20, -190.45),</div><div style="background-color: transparent;"> c(9.1797, 8.2686, 8.6437, 9.3438, 8.8773, 8.1872),</div><div style="background-color: transparent;"> c(-0.03382, -0.03479, -0.03632, -0.03341, -0.03597, -0.03675))</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">X <- model.matrix(~-1+cult/(fert+I(fert^2)), data=da)</div><div style="background-color: transparent;">da$eta <- X%*%matrix(theta)</div><div style="background-color: transparent;">da$y <- da$eta+rnorm(nrow(da),0,30)</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">require(lattice)</div><div
style="background-color: transparent;">xyplot(y~fert|cult, data=da, type=c("p","a"))</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">da$Fert <- factor(da$fert) #??????</div><div style="background-color: transparent;">levels(da$Fert)</div><div style="background-color: transparent;">levels(da$cult)</div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">m0 <- aov(y~cult*Fert, data=da)</div><div style="background-color: transparent;"></div><div><span></span></div><div style="background-color: transparent;">anova(m0)</div><div><br></div><div>Obrigado.</div><div></div><div> </div><div><font face="times new roman, new york, times, serif">Alisson Lucrécio da Costa</font></div></div></body></html>