Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #2ST4TMATE
- #One-way Analysis of variance
- data("chickwts")
- chick=chickwts
- by (data=chick$weight,INDICES = chick$feed, FUN = shapiro.test)
- ##tes homogenitas variance
- bartlett.test(weight~feed, data=chick)
- ##################################################################################
- anova1=aov(weight~feed, data=chick)
- anova1
- summary(anova1)
- ##################################################################################
- plot(weight~feed, data=chick)
- ##################################################################################
- pairwise.t.test(chick$weight,chick$feed,p.adj="bonferroni",paired=F)
- ##################################################################################
- TukeyHSD(anova1)
- ##################################################################################
- data("InsectSprays")
- Insect=InsectSprays
- #explore data
- dim(Insect)
- head(Insect)
- attach(Insect)
- summary(Insect)
- ##################################################################################
- require(stats); require(graphics)
- boxplot(count~spray, data=Insect, xlab="Type of spray", ylab="Insect count", main="Insect sprays data", varwidth=TRUE, col="lightgrey")
- ##################################################################################
- #One way analysis variance
- by(data=count, INDICES = spray, FUN=shapiro.test)
- bartlett.test(count~spray)
- ##################################################################################
- aov.Insect=aov(count~spray,data=Insect)
- summary(aov.Insect)
- ##################################################################################
- TukeyHSD(aov.Insect)
- ##################################################################################
- #Two-way anova
- hsb=data.frame(read.csv("PASTE DISINI FILE PATHNYA SAYANGG")) #mungkin datanya dikirim nanti hmm
- #uji homogen varian
- bartlett.test(science~c(female+schtyp), data=hsb)
- ##################################################################################
- anova2=aov(science~schtyp+female, data=hsb)
- summary(anova2)
- pairwise.t.test(hsb$science,c(hsb$schtyp+hsb$female),p.adj="bonferroni", paired=F)
- ##################################################################################
- #explore contoh 4.4
- data("ToothGrowth")
- Tooth=ToothGrowth
- str(Tooth)
- ##################################################################################
- Tooth$dose=as.factor(Tooth$dose)
- str(Tooth)
- ##################################################################################
- bartlett.test(len~supp, data = Tooth)
- bartlett.test(len~dose, data=Tooth)
- ##################################################################################
- #Anova two ways
- aov.vitc=aov(len~supp+dose, data=Tooth)
- summary(aov.vitc)
- ##################################################################################
- TukeyHSD(aov.vitc)
- ##################################################################################
- boxplot(len~supp+dose, data=Tooth, xlab="Dosin dan Metode Pemberian", ylab="Pertumbuhan gigi", main="Boxplot pemberian Vit C pada marmut")
- ##################################################################################
- coplot(len~dose|supp, data=Tooth, panel = panel.smooth, xlab="Toothgrowth data : length vs dose, given type of supplement")
- ##################################################################################
- #2ST4TMATE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement