Question 3.23

f1<-c(17.6,18.9,16.3,17.4,20.1,21.6)
f2<-c(16.9,15.3,18.6,17.1,19.5,20.3)
f3<-c(21.4,23.6,19.4,18.5,20.5,22.3)
f4<-c(19.3,21.1,16.9,17.5,18.3,19.8)
readings<-c(f1,f2,f3,f4)
fluidtype<-c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
fluidtype<-as.factor(fluidtype)
d<-cbind(readings,fluidtype)
d<-as.data.frame(d)
str(d)
## 'data.frame':    24 obs. of  2 variables:
##  $ readings : num  17.6 18.9 16.3 17.4 20.1 21.6 16.9 15.3 18.6 17.1 ...
##  $ fluidtype: num  1 1 1 1 1 1 2 2 2 2 ...
aov.model<-aov(readings~fluidtype)
summary(aov.model)
##             Df Sum Sq Mean Sq F value Pr(>F)  
## fluidtype    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
plot(aov.model)

library(agricolae)

lsdtest<-LSD.test(aov.model,"fluidtype",20,3.30,console = TRUE)
## 
## Study: aov.model ~ "fluidtype"
## 
## LSD t Test for readings 
## 
## Mean Square Error:  3.299667 
## 
## fluidtype,  means and individual ( 95 %) CI
## 
##   readings      std r      LCL      UCL  Min  Max
## 1 18.65000 1.952178 6 17.10309 20.19691 16.3 21.6
## 2 17.95000 1.854454 6 16.40309 19.49691 15.3 20.3
## 3 20.95000 1.879096 6 19.40309 22.49691 18.5 23.6
## 4 18.81667 1.554885 6 17.26975 20.36358 16.9 21.1
## 
## Alpha: 0.05 ; DF Error: 20
## Critical Value of t: 2.085963 
## 
## least Significant Difference: 2.187666 
## 
## Treatments with the same letter are not significantly different.
## 
##   readings groups
## 3 20.95000      a
## 4 18.81667     ab
## 1 18.65000      b
## 2 17.95000      b
plot(lsdtest)

a)

Testing Hypothesis:-

Null Hypothesis : \(H_o : \mu_1 = \mu_2 = \mu_3 = .... \mu_i = \mu\)

Alternative Hypothesis : \(H_a\) : At least one of the \(\mu_i\) differs

As p=0.0525 value is slightly greater than 0.05, hence we conclude that we failed to reject the null hypothesis and there is indication that fluid differs from each other

Using the Fisher LSD method with alpha=0.05 to make comparisons between pairs of means

From the LSD method we can conclude that t3 is significantly different from t1 and t2 as it does not lie in the same group at 5% level of significance and the least Significant Difference: 2.187666

mean(f1)
## [1] 18.65
mean(f2)
## [1] 17.95
mean(f3)
## [1] 20.95
mean(f4)
## [1] 18.81667
print(mean(f1))
## [1] 18.65
print(mean(f2))
## [1] 17.95
print(mean(f3))
## [1] 20.95
print(mean(f4))
## [1] 18.81667
sd(f1)
## [1] 1.952178
sd(f2)
## [1] 1.854454
sd(f3)
## [1] 1.879096
sd(f4)
## [1] 1.554885

b)

The mean of f1=18.65, f2=17.95, f3=20.95 and f4=18.81667. Also according to Fisher LSD test results, fluid 3 is different from the others, and it’s average life also exceeds the average lives of the other three fluid types. Hence, we will select fluid type 3 for long life objective

f1<-rnorm(6,mean=18.65,sd=1.952178)
f2<-rnorm(6,mean=17.95,sd=1.854454)
f3<-rnorm(6,mean=20.95,sd=1.879096)
f4<-rnorm(6,mean=18.81667,sd=1.554885)
fluidtype<-c(f1,f2,f3,f4)
x<-c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
meanx<-c(rep(mean(f1),6),rep(mean(f2),6),rep(mean(f3),6),rep(mean(f4),6))
residuals<-fluidtype-meanx
qqnorm(residuals)
qqline(residuals)

plot(meanx,residuals,xlab="Life (in h) at 35 kV Load",ylab="residuals",
     main="constant variance check")

c)

According to the normal probability plot, we can conclude that the data is fairly distributed but it has some points that do not lie along the line in the upper region. This might indicate the potential outliers in the data. Hence we can conclude that variances are fairly constant and assumption is satisfied

Question 3.28

minutes<-c(110,157,194,178,1,2,4,18,880,1256,5276,4355,495,7040,5307,10050,7,5,29,2)
types<-c(rep(1,4),rep(2,4),rep(3,4),rep(4,4),rep(5,4))
readings<-data.frame(minutes,types)
readings$types<-as.factor(readings$types)
str(readings)
## 'data.frame':    20 obs. of  2 variables:
##  $ minutes: num  110 157 194 178 1 ...
##  $ types  : Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 2 2 2 2 3 3 ...
library(agricolae)
aov.model<-aov(minutes~types,data=readings)
summary(aov.model)
##             Df    Sum Sq  Mean Sq F value  Pr(>F)   
## types        4 103191489 25797872   6.191 0.00379 **
## Residuals   15  62505657  4167044                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(aov.model)

Testing Hypothesis:-

Null Hypothesis : \(H_o : \mu_1 = \mu_2 = \mu_3 = .... \mu_i = \mu\)

Alternative Hypothesis : \(H_a\) : At least one of the \(\mu_i\) differs

a)

As the p-value is 0.00379 which is smaller than the 0.05, hence we reject the null hypothesis.

m1<-rnorm(4,mean=159.75,sd=36.46345)
m2<-rnorm(4,mean=6.25,sd=7.9320026)
m3<-rnorm(4,mean=2941.75,sd=2201.40597)
m4<-rnorm(4,mean=5723,sd=3998.43544)
m5<-rnorm(4,mean=10.75,sd=12.338962)
material<-c(m1,m2,m3,m4,m5)
x<-c(rep(1,4),rep(2,4),rep(3,4),rep(4,4),rep(5,4))
meanx<-c(rep(mean(m1),4),rep(mean(m2),4),rep(mean(m3),4),rep(mean(m4),4),rep(mean(m5),4))
residuals<-material-meanx
qqnorm(residuals)
qqline(residuals)

plot(meanx,residuals,xlab="Failure Time (minutes)",ylab="residuals",
     main="constant variance check")

b)

From the plot of residuals versus predicted we can conclude that the variance of the original observations is not constant.

From the residuals plotted in the normal probability plot we can conclude that the normality assumption is invalid as data is not normally distributed and a data transformation is required

library(MASS)
boxplot(minutes~readings$types)

boxcox(minutes~types)

Trans_minutes<-log(minutes)
plot(Trans_minutes~readings$types,xlab="Materials",ylab="Failure Time",main="Variance check")

trans_aov.model<-aov(Trans_minutes~readings$types)
summary(trans_aov.model)
##                Df Sum Sq Mean Sq F value   Pr(>F)    
## readings$types  4 165.06   41.26   37.66 1.18e-07 ***
## Residuals      15  16.44    1.10                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(trans_aov.model)

From boxplot we found that variances were not stable, so we performed the boxcox transformation to stabilize the variances of fluid types.

As value of lambda is almost equal to zero, we will perform the log transformation to stablize the data.

As the p-value is 1.18e-07which is smaller than the 0.05, hence we reject the null hypothesis.

c)

There is nothing unusual about the residual plots when the transformation is applied.

Question 3.29

count<-c(31,10,21,4,1,62,40,24,30,35,53,27,120,97,68)
method<-c(rep(1,5),rep(2,5),rep(3,5))
observations<-data.frame(count,method)
observations$method<-as.factor(observations$method)
str(observations)
## 'data.frame':    15 obs. of  2 variables:
##  $ count : num  31 10 21 4 1 62 40 24 30 35 ...
##  $ method: Factor w/ 3 levels "1","2","3": 1 1 1 1 1 2 2 2 2 2 ...
aov.model<-aov(count~method,data=observations)
summary(aov.model)
##             Df Sum Sq Mean Sq F value  Pr(>F)   
## method       2   8964    4482   7.914 0.00643 **
## Residuals   12   6796     566                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(aov.model)

lsdtest<-LSD.test(aov.model,"method",12,566,console = TRUE)
## 
## Study: aov.model ~ "method"
## 
## LSD t Test for count 
## 
## Mean Square Error:  566.3333 
## 
## method,  means and individual ( 95 %) CI
## 
##   count      std r       LCL      UCL Min Max
## 1  13.4 12.46194 5 -9.788411 36.58841   1  31
## 2  38.2 14.56709 5 15.011589 61.38841  24  62
## 3  73.0 36.48972 5 49.811589 96.18841  27 120
## 
## Alpha: 0.05 ; DF Error: 12
## Critical Value of t: 2.178813 
## 
## least Significant Difference: 32.79336 
## 
## Treatments with the same letter are not significantly different.
## 
##   count groups
## 3  73.0      a
## 2  38.2      b
## 1  13.4      b
plot(lsdtest)

Testing Hypothesis:-

Null Hypothesis : \(H_o : \mu_1 = \mu_2 = \mu_3 = .... \mu_i = \mu\)

Alternative Hypothesis : \(H_a\) : At least one of the \(\mu_i\) differs

a)

As the p-value is 0.00643 which is smaller than the 0.05, hence we reject the null hypothesis.

Using the Fisher LSD method with alpha=0.05 to make comparisons between pairs of means

From the LSD method we can conclude that m3 is significantly different from m1 and m2 as it does not lie in the same group at 5% level of significance and the least Significant Difference: 32.79336

Hence we can conclude that, at least one method has a different effect on mean particle count.

m1<-rnorm(5,mean=13.40,sd=12.46194)
m2<-rnorm(5,mean=38.2,sd=14.567086)
m3<-rnorm(5,mean=73,sd=36.489724)
method<-c(m1,m2,m3)
x<-c(rep(1,5),rep(2,5),rep(3,5))
meanx<-c(rep(mean(m1),5),rep(mean(m2),5),rep(mean(m3),5))
residuals<-method-meanx
qqnorm(residuals)
qqline(residuals)

plot(meanx,residuals,xlab="Failure Time (minutes)",ylab="residuals",
     main="constant variance check")

b)

From the plot of residuals versus predicted plot we can conclude that the variance of the original observations is not constant, which indicates that the variance assumption is not valid and a data transformation is required

library(MASS)
boxplot(count~observations$method)

boxcox(count~method)

lambda<-0.4
Trans_method<-method^(lambda)
boxplot(Trans_method~observations$method)

transdata<-cbind(Trans_method,method)
transdata<-data.frame(transdata)
transdata$method<-as.factor(transdata$method)
str(transdata$method)
##  Factor w/ 15 levels "-1.53216192975142",..: 1 4 3 5 2 11 6 9 10 8 ...
transmodel<-aov(Trans_method~method,data=transdata$method)
summary(transmodel)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## method       1 21.102  21.102   196.2 8.49e-09 ***
## Residuals   12  1.291   0.108                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1 observation deleted due to missingness
plot(transmodel)

As the p-value is 1.35e-08which is smaller than the 0.05, hence we reject the null hypothesis.

Question 3.51

Kruskal–Wallis test for problem no.3.23

Null Hypothesis : \(H_o : \mu_1 = \mu_2 = \mu_3 = .... \mu_i = \mu\)

Alternative Hypothesis : \(H_a\) : At least one of the \(\mu_i\) differs

f1<-c(17.6,18.9,16.3,17.4,20.1,21.6)
f2<-c(16.9,15.3,18.6,17.1,19.5,20.3)
f3<-c(21.4,23.6,19.4,18.5,20.5,22.3)
f4<-c(19.3,21.1,16.9,17.5,18.3,19.8)
readings<-c(f1,f2,f3,f4)
fluidtype<-c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
fluidtype<-as.factor(fluidtype)
d<-cbind(readings,fluidtype)
d<-as.data.frame(d)
kruskal.test(readings~fluidtype,data=d)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  readings by fluidtype
## Kruskal-Wallis chi-squared = 6.2177, df = 3, p-value = 0.1015

From the Kruskal-Wallis Rank Sum Test we get, P value is 0.1015which is higher than 0.05 , hence we fail to reject the Null Hypothesis.