Suppose we wish to design a new experiment that tests for a significant difference between the mean effective life of four insulating fluids at an accelerated load of 35kV. The variance of fluid life is estimated to be 3.5 hrs based on preliminary data. We would like this test to have a type 1 error probability of 0.05, and for this test to have an 80% probability of rejecting the assumption that the mean life of all the fluids are the same if there is a difference greater than 2 hours between the mean lives of the fluids, with a min of 18 hrs and max of 20 hrs.
How many samples of each fluid will need to be collected to achieve this design criterion in the case of Min, Intermediate, and Max variability?
How many samples of each fluid will need to be collected to achieve the design criterion described above in the case of minimum variability?
power.anova.test(groups = 4,
n = NULL,
between.var = var(c(18,19,19,20)),
within.var = 3.5,
sig.level = 0.05,
power = 0.80)
##
## Balanced one-way analysis of variance power calculation
##
## groups = 4
## n = 20.08368
## between.var = 0.6666667
## within.var = 3.5
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
In the case of minimum variability, 21 samples from each fluid type will need to be collected.
How many samples of each fluid will need to be collected to achieve the design criterion described above in the case of intermediate variability?
power.anova.test(groups = 4,
n = NULL,
between.var = var(c(18,18.66,19.33,20)),
within.var = 3.5,
sig.level = 0.05,
power = 0.80)
##
## Balanced one-way analysis of variance power calculation
##
## groups = 4
## n = 18.16131
## between.var = 0.7414917
## within.var = 3.5
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
In the case of intermediate variability, 19 samples from each fluid type will need to be collected.
How many samples of each fluid will need to be collected to achieve the design criterion described above in the case of maximum variability?
power.anova.test(groups = 4,
n = NULL,
between.var = var(c(18,18,20,20)),
within.var = 3.5,
sig.level = 0.05,
power = 0.80)
##
## Balanced one-way analysis of variance power calculation
##
## groups = 4
## n = 10.56952
## between.var = 1.333333
## within.var = 3.5
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
In the case of maximum variability, 11 samples from each fluid type will need to be collected.
The experimenter decided to collect six observations for each type of fluid, resulting in the following test data. All measurements are the associated fluid life in hours at a 35 kV load.
Fluid_1<-c(17.6,18.9,16.3,17.4,20.1,21.6)
Fluid_2<-c(16.9,15.3,18.6,17.1,19.5,20.3)
Fluid_3<-c(21.4,23.6,19.4,18.5,20.5,22.3)
Fluid_4<-c(19.3,21.1,16.9,17.5,18.3,19.8)
dat<-data.frame(Fluid_1,Fluid_2,Fluid_3,Fluid_4)
dat
## Fluid_1 Fluid_2 Fluid_3 Fluid_4
## 1 17.6 16.9 21.4 19.3
## 2 18.9 15.3 23.6 21.1
## 3 16.3 18.6 19.4 16.9
## 4 17.4 17.1 18.5 17.5
## 5 20.1 19.5 20.5 18.3
## 6 21.6 20.3 22.3 19.8
Before beginning ANOVA, data has to be in a tidy format. Using package “tidyr”, the pivot_longer function is used to organize the format that is suitable for ANOVA using R.
library(tidyr)
dat<-pivot_longer(dat,c(Fluid_1,Fluid_2,Fluid_3,Fluid_4))
dat
## # A tibble: 24 × 2
## name value
## <chr> <dbl>
## 1 Fluid_1 17.6
## 2 Fluid_2 16.9
## 3 Fluid_3 21.4
## 4 Fluid_4 19.3
## 5 Fluid_1 18.9
## 6 Fluid_2 15.3
## 7 Fluid_3 23.6
## 8 Fluid_4 21.1
## 9 Fluid_1 16.3
## 10 Fluid_2 18.6
## # ℹ 14 more rows
Test the hypothesis that the mean life of fluids is the same against the alternative that they differ at an alpha = 0.10 level of significance.
\[H_{0}:\mu_{i}=\mu\]
\[H_{1}:\mu_{i}\ne\mu \]
Where:
\[\mu_{i}=The\ mean\ life\ of\ the\ fluid\ in\ the\ i^{th}\ treatment\] \[\mu=The\ Grand\ Mean\ of\ All\ Observations \]
aov.model<-aov(value~name,data = dat)
summary(aov.model)
## Df Sum Sq Mean Sq F value Pr(>F)
## name 3 30.17 10.05 3.047 0.0525 .
## Residuals 20 65.99 3.30
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The P value from the ANOVA test is 0.0525. The level of significance used in this test was alpha = 0.10. Since the P-value is less than alpha, there is sufficient evidence to indicate that the mean life of the four fluids differs; therefore, the null hypothesis can be rejected.
Is the model adequate? (show plots and comment)
plot(aov.model, which = 1)
As seen in the Residual vs. Fitting plot above, the variance appears to be constant across all four fluid types. The red line follows closely to zero for all fluids indicating an even spread of data for each treatment.
plot(aov.model, which = 2)
Based on the Q-Q Residuals plot, there are a few outliers on the top right and the bottom left, but overall the data appears to be normally distributed.
plot(aov.model, which = 3)
The trend line in red is fairly flat across the range of fitted values and does not show a trend in spread. The variance does not appear perfectly uniform across all fluid types, but there is not strong evidence of a systematic trend of the variance.
plot(aov.model, which = 5)
All four fluids scatter evenly above and below the middle zero line indicating that there isn’t a single fluid that is consistently higher or lower than expected. Fluid 2 has the widest spread indicating that it is the most unpredictable of those tested; while, fluid 4 is a little more tightly clustered making it more consistent. Although there are differences between the fluids, these differences are not large.
Something worth noting for all four plots was that data points 6, 7, & 21 were identified as being outliers. It maybe worth investigating the source of these erroneous results to identify if they are true or if there was some other issue that may have caused these measurements.
Based on the results from the four plots, it appears that the two main assumptions of ANOVA have been satisfied.
This ANOVA model is adequate.
Assuming the null hypothesis in question 1 is rejected, which fluids significantly differ using a familywise error rate of alpha = 0.10 (use Tukey’s test). Include the plot of confidence intervals.
library(car)
TukeyHSD(aov.model, conf.level = 0.90)
## Tukey multiple comparisons of means
## 90% family-wise confidence level
##
## Fit: aov(formula = value ~ name, data = dat)
##
## $name
## diff lwr upr p adj
## Fluid_2-Fluid_1 -0.7000000 -3.2670196 1.8670196 0.9080815
## Fluid_3-Fluid_1 2.3000000 -0.2670196 4.8670196 0.1593262
## Fluid_4-Fluid_1 0.1666667 -2.4003529 2.7336862 0.9985213
## Fluid_3-Fluid_2 3.0000000 0.4329804 5.5670196 0.0440578
## Fluid_4-Fluid_2 0.8666667 -1.7003529 3.4336862 0.8413288
## Fluid_4-Fluid_3 -2.1333333 -4.7003529 0.4336862 0.2090635
plot(TukeyHSD(aov.model, conf.level = 0.90))
Fluid 2 and Fluid 3 are the only pair that significantly differs since the upper and lower 90% confidence interval does not include 0.
It is a good idea to include this at the end of every RMarkdown document
# Question 1
## Minimum Variability
power.anova.test(groups = 4,
n = NULL,
between.var = var(c(18,19,19,20)),
within.var = 3.5,
sig.level = 0.05,
power = 0.80)
## Intermediate Variability
power.anova.test(groups = 4,
n = NULL,
between.var = var(c(18,18.66,19.33,20)),
within.var = 3.5,
sig.level = 0.05,
power = 0.80)
## Maximum Variability
power.anova.test(groups = 4,
n = NULL,
between.var = var(c(18,18,20,20)),
within.var = 3.5,
sig.level = 0.05,
power = 0.80)
# Question 2
## Data Entry
Fluid_1<-c(17.6,18.9,16.3,17.4,20.1,21.6)
Fluid_2<-c(16.9,15.3,18.6,17.1,19.5,20.3)
Fluid_3<-c(21.4,23.6,19.4,18.5,20.5,22.3)
Fluid_4<-c(19.3,21.1,16.9,17.5,18.3,19.8)
dat<-data.frame(Fluid_1,Fluid_2,Fluid_3,Fluid_4)
dat
## Data Re-organizing for ANOVA
library(tidyr)
dat<-pivot_longer(dat,c(Fluid_1,Fluid_2,Fluid_3,Fluid_4))
dat
## Part a - ANOVA Test
aov.model<-aov(value~name,data = dat)
summary(aov.model)
## Part b - Model Adequacy Check
### Residuals vs Fitted Plot
plot(aov.model, which = 1)
### Residual Q-Q Plot
plot(aov.model, which = 2)
### Scale-Location Plot
plot(aov.model, which = 3)
### Residuals vs Leverage Plot
plot(aov.model, which = 5)
## Part c - Tukey's Test
library(car)
TukeyHSD(aov.model, conf.level = 0.90)
plot(TukeyHSD(aov.model, conf.level = 0.90))