Last active
October 1, 2015 10:07
-
-
Save MartinMacharia/6152b3ca1f7e121ef96a to your computer and use it in GitHub Desktop.
ANOVA, Addditive& Interactive effects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x2=c(4,25,13,7,56,90,2,82) | |
x2=array(x2,c(2,4)) | |
x2 | |
tab=LTT.Kenya_Exe | |
tab | |
tab2=tab[1:464, 1:7] | |
tab2 | |
names(tab2) | |
tab3=subset(tab,Site=="Bon" & "Nin"=="N0", select=c(Site,Var,Fert,Nin,Yield)) | |
write.csv(tab, "LLT_BonN0") | |
write.csv(tab,"C:/Users/machariam/Desktop/LLT_BonN0") | |
#Analyis of variance | |
a=aov(tab$Yield~tab$Var) | |
a | |
summary(a) | |
par(mfrow=c(2,2)) | |
plot(a) | |
hist(tab2$Yield) | |
tab4=subset(tab,Yield<4,select=c(Site,Var,Fert,Nin,Yield)) | |
a1=aov(tab4$Yield~tab4$Var) | |
par(mfrow=c(2,2)) | |
plot(a1) | |
#Additive and interactive effects | |
names(tab) | |
tab5=subset(tab,Yield<4&Site=="Bon",select=c(Site,Var,Fert,Nin,Ssn,Yield)) | |
View(tab5) | |
a2=aov(Yield~Var*Fert*Nin*Ssn,data=tab5) | |
summary(a2) | |
#Fert-fertility status, Nin-Nitrogen level, Ssn- Season | |
#signifcant difference in yield between variety irrespsctive of fertility | |
#status, N inputs and season | |
#Not significant=additive effect=N input has consistent effect on yield for all varieties, | |
#irrespective of fertility status and season | |
#significant interactive effect=the yiled response of variety to N input is | |
#different across seasons, irrespective of fertility status of soils | |
#Post-hoc pairwise comparison | |
require(stats) | |
TukeyHSD(a2) | |
#Principles of Non-parametric tests | |
#Try this if the sample is small and does not assume normal | |
#Creating barplots with error bars | |
tab6=aggregate(tab2$Yield, by=list(tab2$Var, tab2$Fert, tab2$Nin, tab2$Ssn),FUN="mean") | |
tab6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment