You are on page 1of 1

txt")
Mosca
# Realizando el modelo
mod<-lm(Porcentaje~Spray,Mosca)
summary(aov(mod))
#Prueba de Duncan
library(agricolae)
anva<-aov(Porcentaje~Spray,Mosca)
compd<-duncan.test(anva,"Spray")
compd
compd<-duncan.test(anva,"Spray",group=FALSE)
compd
#Prueba de Dunnet
library(multcomp)
cdu <- glht(mod, linfct = mcp(Spray = "Dunnett"))
summary(cdu)
# Contrastes O togonales (Balanceados)
cme<-deviance(mod)/df.residual(mod)
Porcentaje<-Mosca[,1]
Spray<-Mosca[,2]
yp<-tapply(Porcentaje,Spray,mean)
yp
S<-sqrt(cme/5*(1^2+1^2+(-1)^2+(-1)^2))
t<-(yp[1]*1+yp[2]*1+yp[3]*(-1)+yp[4]*(-1)-0)/S
t
pt(q = t,df=16)
#Contraste ortogonales con la prueba F
vp<-c(64.6 ,59.0 ,65.0 ,59.8)
sce<-44.0
r=5
ct<-c(1,-1,1,-1)
scc1<-r*((t(ct)%*%vp)^2)/(sum(ct^2))
scc1
ct2<-c(0,-1,0,1)
scc2<-r*((t(ct2)%*%vp)^2)/(sum(ct2^2))
scc2
ct3<-c(-1,0,1,0)
scc3<-r*((t(ct3)%*%vp)^2)/(sum(ct3^2))
scc3
tr<-4
gle<-r*tr-tr
gle
cme<-sce/gle
fuente<-c("Q1","Q2","Q3","Residuals")
gl<-c(1,1,1,gle)
SC<-c(scc1,scc2,scc3,sce)
CM<-SC/gl
Fc<-c(round(CM[1:3]/CM[4],4),"")
Fc1<-as.numeric(Fc[1:3])
pvalue1<-round(1-pf(Fc1,1,gle),4)
pvalue<-c(pvalue1,"")
data.frame(fuente,gl,SC,CM,Fc,pvalue)