Solutions - Lab 6 - Factorial Designs

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Solutions - Lab 6 - Factorial Designs

Learning outcomes

At the end of this practical students should be able to:


• use R to analyse experiments with a factorial treatment structure where the experimental design is a
CRD or RCBD;
• use R to generate randomisations for experiments for factorial treatment structures where the experi-
mental design is a CRD or RCBD;
All of the data for this practical is in the Data6.xlsx file.

Exercise 1 - 2-Way Factorial - CRD

We will work through this exercise as a class.


The daily herbage dry matter consumption (kg) of grazing cattle was estimated by two methods, (Method A
and Method B). In addition to grazing, the cattle received one of three concentrate mixtures (Mix R, Mix S,
and Mix T). Six cattle were used for each of the resulting six treatment combinations. The data is found in
the Herbage sheet in the Data6.xlsx file.
(i) Read the data into R and process it as required. In other words, convert treatment factors to data type;
factor using the as.factor function.
library(readxl)

## Warning: package 'readxl' was built under R version 3.5.1


herb<-read_excel("Data6.xlsx",sheet="Herbage")
str(herb)

## Classes 'tbl_df', 'tbl' and 'data.frame': 36 obs. of 3 variables:


## $ Method : chr "A" "A" "A" "A" ...
## $ Mixture : chr "R" "R" "R" "R" ...
## $ DryMatter: num 8.3 9.4 9.4 9.4 9.4 11.3 9.9 10.4 8.6 10.8 ...
Since Method and Mixture have been read in as character data types we need to convert each to a factor.
herb$Method<-as.factor(herb$Method)
herb$Mixture<-as.factor(herb$Mixture)

(ii) Calculate the mean for each level of both factors; Method and Mixture. Comment on any trends you see.
tapply(herb$DryMatter,herb$Method,mean)

## A B
## 9.333333 7.788889
tapply(herb$DryMatter,herb$Mixture,mean)

## R S T
## 8.891667 8.841667 7.950000
There seems to differences of at least 1kg between each level of each treatment factor.

1
(iii) Calculate the mean for each combination of the levels of each factor. This is called a marginal mean
and requires new R code, see below. Is there a particular combination that is worst or best? Generate an
interaction plot. Is their evidence of an interaction?
with(herb, tapply(DryMatter, list(Mixture=Mixture,Method=Method), mean) )

## Method
## Mixture A B
## R 9.533333 8.250000
## S 9.416667 8.266667
## T 9.050000 6.850000
interaction.plot(herb$Mixture,herb$Method,herb$DryMatter)
9.5

herb$Method
mean of herb$DryMatter

9.0

A
B
8.5
8.0
7.5
7.0

R S T

herb$Mixture

You can see that the distance between the Method means remains the same (or very similar) across all
Mixtures. That is, there is the same Method effect for each level of Mixture. This indicates that there isn’t
a significant interaction between the two treatment factors.
(iv) Test the assumptions for using an ANOVA model. Are they met? If no, then consider transformations of
the response.
The plots below indicate the assumptions of normality and constant variance have been met.
herb.aov<-aov(DryMatter~Mixture*Method,data=herb)
par(mfrow=c(2,2))
hist(rstandard(herb.aov))
plot(herb.aov$fitted.values,(rstandard(herb.aov)))
qqnorm(rstandard(herb.aov))
abline(0,1)

2
Histogram of rstandard(herb.aov)

(rstandard(herb.aov))

2
Frequency

0
4

−2
0

−3 −2 −1 0 1 2 7.0 7.5 8.0 8.5 9.0 9.5

rstandard(herb.aov) herb.aov$fitted.values

Normal Q−Q Plot


Sample Quantiles

2
0
−2

−2 −1 0 1 2

Theoretical Quantiles

(V) Once you have a model where the assumptions have been met. Identify the significant effects and perform
an appropriate LSD test.
The ANOVA table is shown below.
summary(herb.aov)

## Df Sum Sq Mean Sq F value Pr(>F)


## Mixture 2 6.74 3.369 1.374 0.26852
## Method 1 21.47 21.468 8.758 0.00597 **
## Mixture:Method 2 1.96 0.980 0.400 0.67391
## Residuals 30 73.54 2.451
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The interaction is not significant so we can proceeed to examine the main effects. The code for performing
LSD tests based on the interaction effect is given below for future use.
library(agricolae)
LSD.test(herb.aov, c("Method", "Mixture"), console = TRUE)

To assess the main effect - Method we use the code below. Note that we have only have 2 levels so we don’t
need to perform an LSD. The F-test in the ANOVA informs us that there is a significant difference between
both levels. The LSD.test provides other ouput such as CIs which may be useful for reporting on.
library(agricolae)
LSD.test(herb.aov, "Method", console = TRUE)

##

3
## Study: herb.aov ~ "Method"
##
## LSD t Test for DryMatter
##
## Mean Square Error: 2.451333
##
## Method, means and individual ( 95 %) CI
##
## DryMatter std r LCL UCL Min Max
## A 9.333333 1.270942 18 8.579668 10.086999 6.8 11.3
## B 7.788889 1.795055 18 7.035223 8.542554 3.1 10.6
##
## Alpha: 0.05 ; DF Error: 30
## Critical Value of t: 2.042272
##
## least Significant Difference: 1.065844
##
## Treatments with the same letter are not significantly different.
##
## DryMatter groups
## A 9.333333 a
## B 7.788889 b
There is no significant effect of Mixture in the amount of herbage consumed, either in the form of an interaction
with Method (P = 0.67), or as a main effect (P = 0.27). However there was a highly significant effect of
Method (P = 0.006), with those assayed using Method A having a significantly higher mean consumption
than those assayed using Method B.

Exercise 2 - More Treatment Structures

A microbiologist conducted an experiment to assess the survival of Salmonella typhinerium when subjected
to various treatments. A factorial treatment design was used, the treatments being various combinations of
sorbic acid, pH, and water activity. The density of Salmonella seven days after the treatment began was
recorded. The Salmonella data is in the form loge (density/ml), to 2 decimal places.
The data is found in the Salmonella sheet in the Data6.xlsx file.
There is a slight trick to analysing this experiment which will improve your ability to analyse factorial
experiments in general.
The table below shows you how to specify the treatment structure and individual interaction term in a
factorial design involving 2 factors, A and B.

term command
2-way factorial A*B
2-way interaction A:B

(i) Import the data into R and describe the data using numerical and graphical summaries. In particular
does the exploratory data analysis (EDA) show any difference in S.typhinerium density between the levels of
each of the treatment factors (a) sorbic acid (b) pH (c) water activity? Is there evidence of an interaction
using interaction plots. No need to look at marginal means as the interaction plots summarise these.
Some hints for the EDA are:
• in many experiments we will have treatment factors which have a numerical value (as is the case here)

4
but for ANOVA-type problems we are comparing the mean response between each value so we need to
tell R the data type is a factor. If we don’t, it will fit a regression model which is Topics 7-9. This
will result in the wrong type of analysis.
• use the tapply function in conjunction with the summary function;
• boxplots for individual levels of a factor are likely to be the most informative as compared to numerical
summaries they visually show the spread of the observations as well. Example R code is below.
boxplot(Density~pH,data=salm)

• to create interaction plots use the interaction.plot function. You will need one of these for each
2-way interaction in your model.
library(readxl)
salm<-read_excel("Data6.xlsx",sheet="Salmonella")
str(salm)

## Classes 'tbl_df', 'tbl' and 'data.frame': 45 obs. of 4 variables:


## $ Sorbic.Acid: num 0 0 0 100 100 100 200 200 200 0 ...
## $ pH : num 5 5.5 6 5 5.5 6 5 5.5 6 5 ...
## $ Activity : num 0.78 0.78 0.78 0.78 0.78 0.78 0.78 0.78 0.78 0.82 ...
## $ Density : num 4.2 4.34 4.31 4.18 4.39 4.13 4.15 4.12 3.93 4.52 ...
salm$Sorbic.Acid<-as.factor(salm$Sorbic.Acid)
salm$pH<-as.factor(salm$pH)
salm$Activity<-as.factor(salm$Activity)
str(salm)

## Classes 'tbl_df', 'tbl' and 'data.frame': 45 obs. of 4 variables:


## $ Sorbic.Acid: Factor w/ 3 levels "0","100","200": 1 1 1 2 2 2 3 3 3 1 ...
## $ pH : Factor w/ 3 levels "5","5.5","6": 1 2 3 1 2 3 1 2 3 1 ...
## $ Activity : Factor w/ 5 levels "0.78","0.82",..: 1 1 1 1 1 1 1 1 1 2 ...
## $ Density : num 4.2 4.34 4.31 4.18 4.39 4.13 4.15 4.12 3.93 4.52 ...
First we calculate summary statistics for different levels of each treatment factor.
tapply(salm$Density,salm$Sorbic.Acid,summary)

## $`0`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.200 4.430 5.060 5.303 6.060 6.700
##
## $`100`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.130 4.290 4.850 4.999 5.530 6.520
##
## $`200`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.930 4.265 4.410 4.891 5.315 6.430
tapply(salm$Density,salm$pH,summary)

## $`5`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.150 4.245 4.790 5.082 5.960 6.510
##
## $`5.5`
## Min. 1st Qu. Median Mean 3rd Qu. Max.

5
## 4.120 4.365 4.950 5.066 5.665 6.700
##
## $`6`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.930 4.300 4.850 5.045 5.535 6.650
tapply(salm$Density,salm$Activity,summary)

## $`0.78`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 3.930 4.130 4.180 4.194 4.310 4.390
##
## $`0.82`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.180 4.270 4.310 4.387 4.430 4.850
##
## $`0.86`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.29 4.41 4.85 4.79 5.01 5.35
##
## $`0.9`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.010 5.200 5.430 5.532 5.870 6.140
##
## $`0.94`
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 6.180 6.250 6.430 6.418 6.520 6.700
There are a lot of statistics to examine which is where graphical summaries are easier to interpret.
The boxplots for each level of Sorbic.Acid show that Density decreases as the Sorbic.Acid increases, this
is based off the median values. However it should be noted the distributions at each level do overlap each
other which may indicate no significant differences.
boxplot(Density~Sorbic.Acid,data=salm,main=" ",xlab="Sorbic Acid",ylab="Density")

6
6.5
6.0
5.5
Density

5.0
4.5
4.0

0 100 200

Sorbic Acid

The boxplots for each level of pH show that there is little difference in Density, this is based off the median
values.
boxplot(Density~pH,data=salm,main=" ",xlab="pH",ylab="Density")

7
6.5
6.0
5.5
Density

5.0
4.5
4.0

5 5.5 6

pH

The boxplots for each level of Activity show that Density increases as the Activity increases quite
markedly, this is based off the median values. Also note the distributions for each level in some cases do not
overlap at all, for example 0.78 and 0.82 are quite distinct from 0.9 and 0.94.
boxplot(Density~Activity,data=salm,main=" ",xlab="Activity",ylab="Density")

8
6.5
6.0
5.5
Density

5.0
4.5
4.0

0.78 0.82 0.86 0.9 0.94

Activity

There are three 2 factor interactions which we can explore with interaction plots. When interpreting the
interaction plots we are looking for changes in the shape of the lines for different levels of the treatment
factor shown in the inset.
interaction.plot(salm$Sorbic.Acid,salm$pH,salm$Density)

9
salm$pH
5.3
mean of salm$Density

5
5.2

6
5.5
5.1
5.0
4.9
4.8

0 100 200

salm$Sorbic.Acid

The pH and Sorbic.Acid interaction plot does not have parallel lines, the difference being when pH = 5.
There may be an interaction here but formal hypothesis testing is needed to determine this.
interaction.plot(salm$Sorbic.Acid,salm$Activity,salm$Density)

10
6.5

salm$Activity
mean of salm$Density

0.94
6.0

0.9
0.86
5.5

0.82
0.78
5.0
4.5
4.0

0 100 200

salm$Sorbic.Acid

The Activity and Sorbic.Acid interaction plot does have parallel lines so there is not likely to be an
interaction. Note that the traces for different Activity levels are quite well separated in most cases which is
further evidence of a treatment effect for Activity.
interaction.plot(salm$pH,salm$Activity,salm$Density)

11
6.5

salm$Activity
mean of salm$Density

0.94
6.0

0.9
0.86
5.5

0.82
0.78
5.0
4.5

5 5.5 6

salm$pH

The Activity and pH interaction plot does have parallel lines so there is not likely to be an interaction. Note
that the traces for different Activity levels are quite well separated in most cases which is further evidence
of a treatment effect for Activity.
(ii) Write out the model you are fitting in terms of main effects and interactions, words are fine. Note, that
each of these will have an associated statistical hypotheses. Obtain an ANOVA for these data, including
appropriate interaction terms in the model.
What do you notice in the ANOVA table when your run the full 3-way factorial ANOVA? Use the summary
function to extract the ANOVA table.
Run the model again but only include the interactions involving two factors: do not include the three
factor interaction term. Why are we not including the three factor interaction? HINT: look at the data
in Excel and manually calculate the mean Density for when pH = 5.0, Activity = 0.78 and Sorbic.Acid
= 0. How many observations were used to calculate the mean?
The model in words is:
density = sorbic acid + pH + activity (main effects) +
sorbic acid:pH + sorbic acid:activity + activity:pH (2 factor interactions) +
sorbic acid:pH:activity (3 factor interaction)
We are not fitting the 3 factor interaction as there is no replication at that level. For every combination of
the three factors (Sorbic.Acid, Activity and pH), there is only one observation, so if this is fitted there will
be zero degrees of freedom; replication would be needed to fit a three-way interaction. Effectively, by not
fitting a three factor interaction, this term, becomes the Residual term.
To illustrate compare the output from a model with and without the 3 factor interaction.

12
salm.aov<-aov(Density~Sorbic.Acid*pH*Activity,data=salm)
summary(salm.aov)

## Df Sum Sq Mean Sq
## Sorbic.Acid 2 1.366 0.683
## pH 2 0.011 0.005
## Activity 4 30.077 7.519
## Sorbic.Acid:pH 4 0.209 0.052
## Sorbic.Acid:Activity 8 0.501 0.063
## pH:Activity 8 0.452 0.056
## Sorbic.Acid:pH:Activity 16 0.635 0.040
salm.aov<-aov(Density~Sorbic.Acid*pH*Activity-Sorbic.Acid:pH:Activity,data=salm)
summary(salm.aov)

## Df Sum Sq Mean Sq F value Pr(>F)


## Sorbic.Acid 2 1.366 0.683 17.196 0.000103 ***
## pH 2 0.011 0.005 0.133 0.876834
## Activity 4 30.077 7.519 189.367 2.96e-13 ***
## Sorbic.Acid:pH 4 0.209 0.052 1.319 0.305270
## Sorbic.Acid:Activity 8 0.501 0.063 1.578 0.208120
## pH:Activity 8 0.452 0.056 1.422 0.260864
## Residuals 16 0.635 0.040
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(iii) Test that the model assumptions have been met.
The residual diagnostics show that the data is normally distributed, has constant variance and has no obvious
outliers. The response has been log transformed so this is no surprise.
par(mfrow=c(2,2))
hist(rstandard(salm.aov))
plot(salm.aov$fitted.values,(rstandard(salm.aov)))
qqnorm(rstandard(salm.aov))
abline(0,1)

13
Histogram of rstandard(salm.aov)

(rstandard(salm.aov))

2
Frequency

0
4

−2
0

−2 −1 0 1 2 4.0 4.5 5.0 5.5 6.0 6.5

rstandard(salm.aov) salm.aov$fitted.values

Normal Q−Q Plot


Sample Quantiles

2
0
−2

−2 −1 0 1 2

Theoretical Quantiles

(iv) What are the significant effects in the model? For the significant effects use the LSD.test function
to determine which pairs are significantly different. Write overall conclusions, in terms of the statistical
hypothesis testing and in terms of the biological description of the experiment.
The ANOVA shows that none of the 2 factor interactions are significant which means we can examine the
main effects individually. The significant effects are pH and Sorbic.Acid with P-values less than 0.05.
summary(salm.aov)

## Df Sum Sq Mean Sq F value Pr(>F)


## Sorbic.Acid 2 1.366 0.683 17.196 0.000103 ***
## pH 2 0.011 0.005 0.133 0.876834
## Activity 4 30.077 7.519 189.367 2.96e-13 ***
## Sorbic.Acid:pH 4 0.209 0.052 1.319 0.305270
## Sorbic.Acid:Activity 8 0.501 0.063 1.578 0.208120
## pH:Activity 8 0.452 0.056 1.422 0.260864
## Residuals 16 0.635 0.040
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
LSD testing on the significant effects is shown below.
library(agricolae)
LSD.test(salm.aov,"Sorbic.Acid",console=T)

##
## Study: salm.aov ~ "Sorbic.Acid"
##
## LSD t Test for Density

14
##
## Mean Square Error: 0.03970778
##
## Sorbic.Acid, means and individual ( 95 %) CI
##
## Density std r LCL UCL Min Max
## 0 5.302667 0.8954126 15 5.193596 5.411737 4.20 6.70
## 100 4.998667 0.8670712 15 4.889596 5.107737 4.13 6.52
## 200 4.891333 0.8508556 15 4.782263 5.000404 3.93 6.43
##
## Alpha: 0.05 ; DF Error: 16
## Critical Value of t: 2.119905
##
## least Significant Difference: 0.1542494
##
## Treatments with the same letter are not significantly different.
##
## Density groups
## 0 5.302667 a
## 100 4.998667 b
## 200 4.891333 b
Increased concentrations of sorbic acid result in significant reductions in Salmonella levels. There was a far
greater reduction in Salmonella when the the Sorbic.Acid was increased from 0 to 100, compared with 100 to
200, suggesting that a saturation effect may be occurring. Note that based on the LSD (0.1542), the decrease
between the first two concentrations was significant but not that between the second two concentrations.
LSD.test(salm.aov,"Activity",console=T)

##
## Study: salm.aov ~ "Activity"
##
## LSD t Test for Density
##
## Mean Square Error: 0.03970778
##
## Activity, means and individual ( 95 %) CI
##
## Density std r LCL UCL Min Max
## 0.78 4.194444 0.1390244 9 4.053635 4.335254 3.93 4.39
## 0.82 4.386667 0.2006863 9 4.245857 4.527477 4.18 4.85
## 0.86 4.790000 0.3554223 9 4.649190 4.930810 4.29 5.35
## 0.9 5.532222 0.4167367 9 5.391412 5.673032 5.01 6.14
## 0.94 6.417778 0.1926641 9 6.276968 6.558588 6.18 6.70
##
## Alpha: 0.05 ; DF Error: 16
## Critical Value of t: 2.119905
##
## least Significant Difference: 0.1991352
##
## Treatments with the same letter are not significantly different.
##
## Density groups
## 0.94 6.417778 a
## 0.9 5.532222 b

15
## 0.86 4.790000 c
## 0.82 4.386667 d
## 0.78 4.194444 d
As the Activity increases, the loge (Density) of Salmonella increases approximately exponentially, and based
on the LSD (0.1991) the increase is significant at each increase in water activity with the exception of between
0.78 and 0.82.

Exercise 3 - More practice

An experiment was performed to study the control of potato blight on potatoes. A factorial treatment
structure was employed with 3 Varieties in combination with 5 Chemical treatments. The experiment was
conducted using a randomised complete block design (RCBD) with three blocks. The response is yield of
potatoes (lbs).
Analyse the experiment. The data is found in the Potato sheet in the Data6.xlsx file.
First we read in the data and convert to factor if required.
library(readxl)
pot<-read_excel("Data6.xlsx",sheet="Potato")
str(pot)

## Classes 'tbl_df', 'tbl' and 'data.frame': 45 obs. of 4 variables:


## $ Yield : num 34.1 76.3 72.2 51.9 42.9 62.1 66.3 39.1 75.1 41.7 ...
## $ Block : num 1 1 1 2 2 2 3 3 3 1 ...
## $ Variety : chr "Pontiac" "Sebago" "Sebago" "Desire" ...
## $ Chemical: chr "CuOxy4" "Dithane10" "Dithane4" "CuOxy4" ...
pot$Block<-as.factor(pot$Block)
pot$Variety<-as.factor(pot$Variety)
pot$Chemical<-as.factor(pot$Chemical)
str(pot)

## Classes 'tbl_df', 'tbl' and 'data.frame': 45 obs. of 4 variables:


## $ Yield : num 34.1 76.3 72.2 51.9 42.9 62.1 66.3 39.1 75.1 41.7 ...
## $ Block : Factor w/ 3 levels "1","2","3": 1 1 1 2 2 2 3 3 3 1 ...
## $ Variety : Factor w/ 3 levels "Desire","Pontiac",..: 2 3 3 1 3 2 3 3 1 2 ...
## $ Chemical: Factor w/ 5 levels "Control","CuOxy10",..: 3 4 5 3 2 4 4 2 5 5 ...
Graphical summaries for the main effects are easier to interpret than summary statistics.
The boxplots based on Variety show that Pontiac is the worst performing.
boxplot(Yield~Variety,data=pot,main=" ",xlab="Variety",ylab="Yield")

16
100
80
Yield

60
40
20

Desire Pontiac Sebago

Variety

The boxplots for each level of Chemical show that Dithane10 results in the greatest yield.
boxplot(Yield~Chemical,data=pot,main=" ",xlab="Chemical",ylab="Yield")

17
100
80
Yield

60
40
20

Control CuOxy10 CuOxy4 Dithane10 Dithane4

Chemical

The marginal means below show that applying no chemical (Control) to suppress potato blight results in
the worse yields for all varieties. The combination of Desire and Dithane10 result in the greatest yield.
with(pot, tapply(Yield, list(Chemical=Chemical,Variety=Variety), mean) )

## Variety
## Chemical Desire Pontiac Sebago
## Control 42.13333 14.83333 36.06667
## CuOxy10 60.53333 28.96667 45.40000
## CuOxy4 51.63333 27.80000 40.70000
## Dithane10 97.10000 65.00000 76.93333
## Dithane4 70.83333 47.50000 63.80000
interaction.plot(herb$Mixture,herb$Method,herb$DryMatter)

18
9.5

herb$Method
mean of herb$DryMatter

9.0

A
B
8.5
8.0
7.5
7.0

R S T

herb$Mixture

The interaction plot below shows the lines to be reasonably parallel so an interaction effect is unlikely.
interaction.plot(pot$Variety,pot$Chemical,pot$Yield)

19
100

pot$Chemical

Dithane10
80
mean of pot$Yield

Dithane4
CuOxy10
CuOxy4
60

Control
40
20

Desire Pontiac Sebago

pot$Variety

The residual diagnostics show that the data is normally distributed, has constant variance and has no obvious
outliers.
pot.aov<-aov(Yield~Block+Chemical*Variety,data=pot)
par(mfrow=c(2,2))
hist(rstandard(pot.aov))
plot(pot.aov$fitted.values,(rstandard(pot.aov)))
qqnorm(rstandard(pot.aov))
abline(0,1)

20
Histogram of rstandard(pot.aov)

(rstandard(pot.aov))
Frequency

2
8

0
4

−2
0

−2 −1 0 1 2 20 40 60 80 100

rstandard(pot.aov) pot.aov$fitted.values

Normal Q−Q Plot


Sample Quantiles

2
0
−2

−2 −1 0 1 2

Theoretical Quantiles

The ANOVA shows that interactions is not significant so we can examine the main effects individually. Both
are significant with P-values less than 0.05.
summary(pot.aov)

## Df Sum Sq Mean Sq F value Pr(>F)


## Block 2 111 55 1.071 0.356
## Chemical 4 13251 3313 64.109 1.09e-13 ***
## Variety 2 5762 2881 55.756 1.72e-10 ***
## Chemical:Variety 8 259 32 0.628 0.748
## Residuals 28 1447 52
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
LSD testing on the main effects is shown below.
library(agricolae)
LSD.test(pot.aov,"Variety",console=T)

##
## Study: pot.aov ~ "Variety"
##
## LSD t Test for Yield
##
## Mean Square Error: 51.67237
##
## Variety, means and individual ( 95 %) CI
##

21
## Yield std r LCL UCL Min Max
## Desire 64.44667 20.05894 15 60.64477 68.24856 39.0 102.1
## Pontiac 36.82000 19.05193 15 33.01811 40.62189 11.4 69.0
## Sebago 52.58000 17.63297 15 48.77811 56.38189 33.1 88.2
##
## Alpha: 0.05 ; DF Error: 28
## Critical Value of t: 2.048407
##
## least Significant Difference: 5.376688
##
## Treatments with the same letter are not significantly different.
##
## Yield groups
## Desire 64.44667 a
## Sebago 52.58000 b
## Pontiac 36.82000 c
LSD.test(pot.aov,"Chemical",console=T)

##
## Study: pot.aov ~ "Chemical"
##
## LSD t Test for Yield
##
## Mean Square Error: 51.67237
##
## Chemical, means and individual ( 95 %) CI
##
## Yield std r LCL UCL Min Max
## Control 31.01111 12.82297 9 26.10289 35.91933 11.4 45.2
## CuOxy10 44.96667 14.75737 9 40.05844 49.87489 24.5 65.6
## CuOxy4 40.04444 12.30753 9 35.13622 44.95267 21.0 55.8
## Dithane10 79.67778 15.66212 9 74.76956 84.58600 62.1 102.1
## Dithane4 60.71111 12.97666 9 55.80289 65.61933 41.0 75.1
##
## Alpha: 0.05 ; DF Error: 28
## Critical Value of t: 2.048407
##
## least Significant Difference: 6.941274
##
## Treatments with the same letter are not significantly different.
##
## Yield groups
## Dithane10 79.67778 a
## Dithane4 60.71111 b
## CuOxy10 44.96667 c
## CuOxy4 40.04444 c
## Control 31.01111 d
The results are quite clean with one level resulting in significantly greater mean yield for both treatment
factors; Desire for Variety and Dithane10 for Chemical. From this we would recommend the use of Desire
and Dithane10 for maximise yield via supressing potato blight.

22
Exercise 4 - Generating experimental designs

For each experiment in Exercises 1-3 generate a randomisation. See Slide 26 in the Lecture Slides in Topic 6
for example code.
Exercise 1 is a 2 × 3 factorial with a CRD design with 6 replicates for each of the 6 treatment combinations.
library(agricolae)
trt<-c(2,3)
ex1<-design.ab(trt,r=6,design="crd")
head(ex1$book)

## plots r A B
## 1 101 1 1 2
## 2 102 1 1 3
## 3 103 1 2 3
## 4 104 2 2 3
## 5 105 2 1 2
## 6 106 1 2 1
Exercise 2 is a 3×3×5 factorial with a CRD design with 1 replicates for each of the 45 treatment combinations.
library(agricolae)
trt<-c(3,3,5)
ex2<-design.ab(trt,r=1,design="crd")
head(ex2$book)

## plots r A B C
## 1 101 1 3 2 4
## 2 102 1 2 2 2
## 3 103 1 3 2 3
## 4 104 1 2 1 5
## 5 105 1 2 2 4
## 6 106 1 2 3 2
Exercise 3 is a 3 × 5 factorial with a RCBD design with 3 replicates for each of the 15 treatment combinations.
library(agricolae)
trt<-c(3,5)
ex3<-design.ab(trt,r=3,design="rcbd")
head(ex3$book)

## plots block A B
## 1 101 1 3 2
## 2 102 1 2 1
## 3 103 1 1 4
## 4 104 1 3 4
## 5 105 1 1 5
## 6 106 1 3 5

23

You might also like