1 Question:1

1.Suppose we wish to design a new experiment that tests for a significant difference between the mean effective life of these 4 insulating fluids at an accelerated load of 35kV.  The variance of fluid life is estimated to be 4.5hrs 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 1 hourbetween the mean lives of the fluids.

a.How many samples of each fluid will need to be collected to achieve this design criterion?

b.Suppose we wish to have an 80% probability of detecting a difference between mean fluid lives of 30minutes, how many samples would need to be collected?

1.1 Solution 1:

library(pwr)

SETTING UP THE DATA:

k <- 4
alpha <- .05
prob <- .8
variance <- 4.5
difference1 <- 1
effectSize1 <- sqrt((difference1^2)/variance)

SOLVING PART 1A :

?pwr.anova.test
pwr.anova.test(k=4 ,n=NULL,f=effectSize1,sig.level = alpha, power = prob)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 4
##               n = 13.28401
##               f = 0.4714045
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group

CONCLUSION:

----> we would need 14 samples from each group

SOLVING PART 1B:

Setting up the data:

difference2 = .5
effectSize2 <- sqrt((difference2^2)/variance)
pwr.anova.test(k=4 ,n=NULL, f=effectSize2, sig.level = alpha, power = prob)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 4
##               n = 50.04922
##               f = 0.2357023
##       sig.level = 0.05
##           power = 0.8
## 
## NOTE: n is number in each group

CONCLUSION:

----> We would need sample sizes of 51 observations from each population

2 Question 2:

1.The effective life of insulating fluids at an accelerated load of 35kV is being studied. Test data have been obtained for the four types of fluid.  The data from this experiment is given below.

a.Given that n=6 samples of each fluid type were collected, with what power will a hypothesis test with an a=0.10 level of significance be able to detect a difference of 1 hour between the mean lives of the tested fluids?  

b.Test the hypothesis that the life of fluids is the same against the alternative that they differ at an a=0.10 level of significance (Remember to enter the data in a tidy format when using R, or to pivot_longer to a tidy format using tidyr )

c.Is the model adequate? (show plots and comment)

d.Assuming the null hypothesis in question 1 is rejected, which fluids significant differ using a familywise error rate of a=0.10 (use Tukey’s test).  Include the plot of confidence intervals. 

2.1 Solution 2:

We computed the standard deviation of data “Life” and used below:

Life <- c(17.6, 18.9, 16.3, 17.4, 20.1, 21.6, 16.9, 15.3, 18.6, 17.1, 19.5, 20.3, 21.4, 23.6, 19.4, 18.5, 20.5, 22.3, 19.3, 21.1, 16.9, 17.5, 18.3, 19.8)

PART 2A:

pwr.anova.test(k = 4, n = 6, f = 1/sd(Life), sig.level = 0.1, power=NULL)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 4
##               n = 6
##               f = 0.4890694
##       sig.level = 0.1
##           power = 0.5618141
## 
## NOTE: n is number in each group

Conclusion:

----> To detect a difference of 1 hour between the mean lives of the tested fluids would be 56.18%.

PART 2B:

SETTING UP DATA IN TIDYR FORMAT:

Life <- c(17.6, 18.9, 16.3, 17.4, 20.1, 21.6, 16.9, 15.3, 18.6, 17.1, 19.5, 20.3, 21.4, 23.6, 19.4, 18.5, 20.5, 22.3, 19.3, 21.1, 16.9, 17.5, 18.3, 19.8)
Type <- c(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4)
Type <- as.factor(Type)
Pop <- cbind(Life, Type)
Pop <- data.frame(Pop)
Pop$Type <- as.factor(Pop$Type)
str(Pop)
## 'data.frame':    24 obs. of  2 variables:
##  $ Life: num  17.6 18.9 16.3 17.4 20.1 21.6 16.9 15.3 18.6 17.1 ...
##  $ Type: Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 1 2 2 2 2 ...
print(Pop)
##    Life Type
## 1  17.6    1
## 2  18.9    1
## 3  16.3    1
## 4  17.4    1
## 5  20.1    1
## 6  21.6    1
## 7  16.9    2
## 8  15.3    2
## 9  18.6    2
## 10 17.1    2
## 11 19.5    2
## 12 20.3    2
## 13 21.4    3
## 14 23.6    3
## 15 19.4    3
## 16 18.5    3
## 17 20.5    3
## 18 22.3    3
## 19 19.3    4
## 20 21.1    4
## 21 16.9    4
## 22 17.5    4
## 23 18.3    4
## 24 19.8    4

Now running the ANOVA:

aov.model<-aov(Life~Type,data=Pop)
summary(aov.model)
##             Df Sum Sq Mean Sq F value Pr(>F)  
## Type         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

Conclusion:

----> Since our p-value is 0.0525, so we would reject the null hypothesis at a significance level of 0.10, and we would conclude that there’s a significant difference between mean lives of the tested fluids

PART 2C:

Testing Model Adequacy:

plot(aov.model)

CONCLUSION:

----> Looking at our plots of all four populations, we conclude that model is adequate as the data seems to fulfill the assumptions of normality and constant variance i.e

• From Residuals Vs Fitted Plot, we can see that the residuals have almost the same spread over the fitted values, depicting constant variance.

• From Normal Probability Plot, we can see that most of the data follows fairly a straight line, depicting “Normality”.

----> Hence our ANOVA test results should hold

PART 2D:

Using Tukey’s Test to test which fluids significant differ using a family wise error rate of a=0.10:

TukeyHSD(aov.model, conf.level = 0.9)
##   Tukey multiple comparisons of means
##     90% family-wise confidence level
## 
## Fit: aov(formula = Life ~ Type, data = Pop)
## 
## $Type
##           diff        lwr       upr     p adj
## 2-1 -0.7000000 -3.2670196 1.8670196 0.9080815
## 3-1  2.3000000 -0.2670196 4.8670196 0.1593262
## 4-1  0.1666667 -2.4003529 2.7336862 0.9985213
## 3-2  3.0000000  0.4329804 5.5670196 0.0440578
## 4-2  0.8666667 -1.7003529 3.4336862 0.8413288
## 4-3 -2.1333333 -4.7003529 0.4336862 0.2090635
plot(TukeyHSD(aov.model))

CONCLUSION:

----> From the result of Tukey’s Test, fluids 2 and 3 significantly differ at the \(\alpha\) = 0.1 level.