Instructions
Create an R notebook and include all the code and interpretations/explanations needed to answer the two questions below.
Question 1 (60 points)
A researcher is interested in studying three types of fertilization methods (100 lb., 150 lb., and 200 lb.) and two levels of irrigation (A and B) on biomass yield. The possible treatment combinations were randomly assigned to 30 plots of land, where each treatment was assigned the same number of plots. You can find the data you need for this exercise in the file Biomass.csv (Canvas/ Module 3/ Resources). Answer the following questions using a significance level of 0.05.
Note: You MUST read the Biomass.csv file into R using the following way:
Biomass_df = read.csv ("Biomass.csv",colClasses = c("numeric","factor","factor"))
Once you do that, a data frame called “Biomass_df” will be available in R with the data you need to answer this question.
str(Biomass_df)
## 'data.frame': 30 obs. of 3 variables:
## $ biomass : num 3250 3151 3300 3290 3300 ...
## $ fertilizer: Factor w/ 3 levels "100","150","200": 1 1 1 1 1 2 2 2 2 2 ...
## $ irrigation: Factor w/ 2 levels "A","B": 1 1 1 1 1 1 1 1 1 1 ...
3 Fertilizer (100 lb., 150 lb., and 200 lb.)
2 Irragation (A and B)
3 * 2 = 6 treatments
Number of replicates = Total observations / # treatments
Number of replicates = 30 / 6 = 5 replicates
The outcome variable
The factor (or factors)
Fertilization Method
Type of Irrigation
The levels of the factor (or levels of the factors)
# Fertilization Method
levels(Biomass_df$fertilizer)
## [1] "100" "150" "200"
# Type of Irrigation
levels(Biomass_df$irrigation)
## [1] "A" "B"
For the effect of the Fertilization Method:
For the effect of the Type of Irrigation:
For the interaction between Irrigation and Fertilization:
twoway_biomass= aov(biomass ~ fertilizer * irrigation, data=Biomass_df)
summary (twoway_biomass)
## Df Sum Sq Mean Sq F value Pr(>F)
## fertilizer 2 500454 250227 3.536 0.04508 *
## irrigation 1 707175 707175 9.994 0.00422 **
## fertilizer:irrigation 2 557130 278565 3.937 0.03322 *
## Residuals 24 1698195 70758
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Interpret the results of ANOVA:
The diet Fertilization Method interpretation: The PV of the fertilization method(0.04508) is less than alpha(0.05); therefore we can reject Ho and support Ha. We can conclude that at least two of the fertilization method has a different average biomass.
The Irrigation effect interpretation: The PV for irrigation(0.00422) is less than alpha(0.05); therefore, therefore we can reject Ho and support Ha. We can conclude that there is a statistical difference between the two types of irrigation.
The interaction effect interpretation: The PV for the interaction is 0.03322, that is less than alpha(0.05); therefore we can reject Ho and support Ha. The data give us evidence to claim that the effect of Fertilization on the biomass yield depends (is affected by) on the type of irrigation.
Note: Stating that “the interaction is evident because the lines are not parallel” (or a similar statement based on observing that the lines are not parallel) does NOT count as a valid explanation.
interaction.plot(x.factor = Biomass_df$fertilizer,
trace.factor = Biomass_df$irrigation,
response = Biomass_df$biomass,
type = "b",
legend = TRUE,
col = c("red", "blue"),
pch = c(1, 2),
xlab = "Fertilizer",
ylab = "Mean of Biomass")
The lines for each irrigation are not parallel. Instead, they show a pattern where the biomass changes differently for each type of irrigation as the fertilizer change. For irrigation A, the biomass remains relatively stable across different fertilizer. For irrigation B, there is a noticeable increase in biomass as the fertilizer increases. The difference in biomass between the two irrigation is more pronounced at 200lb of Fertilizer. This indicates that the effect of fertilizer on biomass is dependent on the level of irrigation.
Question 2 (40 points)
A study is done to determine if there is a difference in the average strength of a filament fiber produced by three machines. Researchers are also interested in studying the possible effect of changing the filament diameter on strength. Researchers decided to do the analysis using an alpha of 0.10.
The data for this exercise can be found in the file Filament.csv (Canvas/ Module 3/ Resources). You MUST read the Filament.csv file into R using the following way:
Open a code chunk in your notebook, insert the following code, and run the code chunk:
Filament_df = read.csv ("Filament.csv",colClasses = c("numeric","factor","factor"))
str(Filament_df)
## 'data.frame': 15 obs. of 3 variables:
## $ strength: num 36 41 39 42 49 40 48 39 45 44 ...
## $ diameter: Factor w/ 3 levels "20","24","28": 1 2 3 1 2 3 1 2 3 1 ...
## $ machine : Factor w/ 3 levels "M1","M2","M3": 1 1 1 1 1 2 2 2 2 2 ...
The outcome variable
The factor (or factors)
The levels of the factor (or levels of the factors)
# Diameter
levels(Filament_df$diameter)
## [1] "20" "24" "28"
# Machine
levels(Filament_df$machine )
## [1] "M1" "M2" "M3"
For the effect of the Diameter:
For the effect of the Machine:
For the interaction between diameter and machine:
twoway_filament= aov(strength ~ diameter * machine, data=Filament_df)
summary (twoway_filament)
## Df Sum Sq Mean Sq F value Pr(>F)
## diameter 2 38.8 19.40 1.394 0.3183
## machine 2 120.9 60.43 4.343 0.0682 .
## diameter:machine 4 103.2 25.81 1.854 0.2377
## Residuals 6 83.5 13.92
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The effect of the Diameter interpretation: The PV of the Diameter(0.3183) is more than alpha(0.10); therefore we can not reject Ho. We can conclude that does not affect the average strength.
The effect of the Machine interpretation: The PV for the Machine(0.0682) is less than alpha(0.10); therefore, therefore we can reject Ho and support Ha. We can conclude that at least two of the machine produce different average strength.
The interaction effect interpretation: The PV for the interaction is 0.2377, that is more than alpha(0.10); therefore we cannot reject Ho. The data give us evidence to claim that the effect of diameter on the strength does not depend (is not affected by) on the machine.
sort(tapply(Filament_df$strength, Filament_df$machine, mean))
## M3 M1 M2
## 36.0 41.4 43.2
TukeyHSD(twoway_filament, which = "machine")
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = strength ~ diameter * machine, data = Filament_df)
##
## $machine
## diff lwr upr p adj
## M2-M1 2.00 -5.239221 9.2392206 0.6897091
## M3-M1 -4.64 -11.879221 2.5992206 0.2012444
## M3-M2 -6.64 -13.879221 0.5992206 0.0685727
Since the PV of the difference between machine 2 (M2) and machine 3 (M3) is 0.068, which is less than alpha(0.1), we can conclude that there is a statistical difference between the strength of the filaments produced by machine 2 and machine 3.