In [74]:
library(MASS)
require(graphics)
library(Cairo)
In [50]:
data <- read.table("apple.txt",
sep="",
col.names=c("Variety", "FusariumStrain", "Days", "AppleWeight",
"Radius", "FungalRadialAdvance", "RateOfAdvance"))
data$Variety = as.factor(data$Variety)
data$FusariumStrain = as.factor(data$FusariumStrain)
In [51]:
data
In [52]:
nrow(data)
In [53]:
data$RateOfAdvance
In [54]:
round(data$FungalRadialAdvance / data$Days, 4) == data$RateOfAdvance
Histograms for Apple Weight and Apple Radius
In [72]:
# 1. Open jpeg file
#jpeg("histograms.jpg", width = 750, height = 350)
svg(filename="histograms.svg",
width=5,
height=4,
pointsize=12)
# 2. Create the plot
par(mfrow=c(1, 2))
hist(data$AppleWeight, cex.axis=0.9, cex.lab=1.2, main="", xlab="Apple Weight (g)")
hist(data$Radius, cex.axis=0.9, cex.lab=1.2, main="", xlab="Apple Radius (cm)")
# 3. Close the file
dev.off()
In [70]:
# 1. Open jpeg file
jpeg("boxplots.jpg", width = 1200, height = 800)
# 2. Create the plot
par(mfrow=c(1, 3))
boxplot(AppleWeight~Variety, data=data, main="", cex.axis=0.9, cex.lab=1.2,
xlab="Apple Variety", ylab="Apple Weight (g)")
boxplot(RateOfAdvance~FusariumStrain, data=data, main="", cex.axis=0.9, cex.lab=1.2,
xlab="Fusarium Strain", ylab="Rate of Advance")
plot.design(RateOfAdvance ~ FusariumStrain + Variety, data=data, main="", cex.axis=0.9, cex.lab=1.2)
# 3. Close the file
dev.off()
In [64]:
# 1. Open jpeg file
jpeg("boxplots.jpg", width = 750, height = 600)
# 2. Create the plot
with(data, interaction.plot(x.factor=Variety, trace.factor = FusariumStrain,
cex.axis=0.9, cex.lab=1.2,
response=RateOfAdvance, fun=mean, legend=T, ylab="Rate of Advance", col=2:8))
# 3. Close the file
dev.off()
Most complex model.
In [130]:
model_fra <- aov(FungalRadialAdvance ~ Variety * FusariumStrain * AppleWeight * Days, data=data)
In [131]:
summary(model_fra)
In [132]:
coef(model_fra)
In [133]:
layout(matrix(1:4,ncol=2))
plot(model_fra)
In [134]:
model_fra_basic <- aov(FungalRadialAdvance ~ 1, data=data)
In [135]:
stepAIC(model_fra_basic, scope= ~ Variety * FusariumStrain * AppleWeight * Days)
In [136]:
best_model_fra = aov(formula = FungalRadialAdvance ~ FusariumStrain + Days, data = data)
In [137]:
summary(best_model_fra)
In [138]:
coef(best_model_fra)
In [139]:
layout(matrix(1:4,ncol=2))
plot(best_model_fra)
In [140]:
model_roa <- aov(RateOfAdvance ~ Variety * FusariumStrain * AppleWeight, data=data)
In [141]:
summary(model_roa)
In [142]:
coef(model_roa)
In [143]:
layout(matrix(1:4,ncol=2))
plot(model_roa)
In [126]:
model_roa_basic <- aov(RateOfAdvance ~ 1, data=data)
In [132]:
stepAIC(model_roa_basic, scope= ~Variety * FusariumStrain * AppleWeight)
In [128]:
best_model_roa <- aov(formula = RateOfAdvance ~ FusariumStrain + Variety + AppleWeight +
Variety:AppleWeight, data = data)
In [129]:
summary(best_model_roa)
In [130]:
coef(best_model_roa)
In [131]:
layout(matrix(1:4,ncol=2))
plot(best_model_roa)
In [ ]: