3.7

tech1 <- c(3129, 3000, 2865, 2890)
tech2 <-  c(3200, 3300, 2975, 3150)
tech3 <-  c(2800 ,2900, 2985, 3050)
tech4 <- c( 2600 ,2700, 2600 ,2765)
technique <- c(tech1[1:length(tech1)],tech2[1:length(tech2)])
dafr <- data.frame(tech1,tech2,tech3,tech4)
dafr2 <- cbind(stack(dafr[1:4]))
atest <- aov(values~ind,dafr2)

(c)

Use the Fisher LSD method with a=0.05 to make comparisons between pairs of means.

library(agricolae)
LSD<- LSD.test(atest,'ind')

According to Our LSD test, our LSD number is 174.47.

These results are also telling us that Technique 2 and Technique 4 are significantly different from the grand mean.

(d)

Give a normal probability plot of the residuals. What conclusion would you draw about the validity of the normality assumption?

 plot(aov(values~ind,dafr2))

The normality assumtion holds, as these data points all fall directly in line on the normal Q-Q plot. ### (e) Comment on the plot.

We can also see in the above that our residuals plotted againt the fitted values.This gives us information about the size of difference between and within treatments.

Our data here does not show a discernable pattern, beyond having 4 vertical sections. This is good as it indicates our data is sufficiantly explained by our current model.

(f )

Give a scatter plot of the results to aid the interpretation of the results of this experiment.

plot(dafr2,ylab="Technique",xlab="Tensile Strength",main="Scatterplot")

We can see from this scatter plot that 2 and 4 are not centered around the same Tensile strength that Technique 1 and 3 are. Technique 4 is roughly centereed around 2700, and Technique 2 around 3150. This supports our conclusion that 2 and 4 do have significantly different means to indicate that the tensile strength is affected by these techniques.

3.10

cwp15 <-  c(7 ,7 ,15 ,11, 9)
cwp20 <-  c(12 ,17 ,12 ,18,18)
cwp25 <-  c(14 ,19 ,19 ,18, 18)
cwp30 <-  c(19 ,25 ,22, 19 ,23)
cwp35 <-  c(7 ,10, 11, 15 ,11)
dafr3 <- data.frame(cwp15,cwp20,cwp25,cwp30,cwp35)

(b)

Use the Fisher LSD method to make comparisons between the pairs of means. What conclusions can you draw?

dafr4 <- cbind(stack(dafr3[1:5]))
atest2 <- aov(values~ind,dafr4)
LSD<- LSD.test(atest2,'ind')
LSD
## $statistics
##   MSerror Df  Mean       CV  t.value      LSD
##      8.06 20 15.04 18.87642 2.085963 3.745452
## 
## $parameters
##         test p.ajusted name.t ntr alpha
##   Fisher-LSD      none    ind   5  0.05
## 
## $means
##       values      std r       LCL      UCL Min Max Q25 Q50 Q75
## cwp15    9.8 3.346640 5  7.151566 12.44843   7  15   7   9  11
## cwp20   15.4 3.130495 5 12.751566 18.04843  12  18  12  17  18
## cwp25   17.6 2.073644 5 14.951566 20.24843  14  19  18  18  19
## cwp30   21.6 2.607681 5 18.951566 24.24843  19  25  19  22  23
## cwp35   10.8 2.863564 5  8.151566 13.44843   7  15  10  11  11
## 
## $comparison
## NULL
## 
## $groups
##       values groups
## cwp30   21.6      a
## cwp25   17.6      b
## cwp20   15.4      b
## cwp35   10.8      c
## cwp15    9.8      c
## 
## attr(,"class")
## [1] "group"

We can see fromthese results that our LSD value is 3.745. We can also see that a CWP of 30% has a different mean from all the rest, while 35% & 20% have a seperate mean from 35% & 15%

(c)

Analyze the residuals from this experiment and comment on model adequacy.

plot(aov(values~ind,dafr4))

Looking at just he residuals plots, we can see that our data does not appear to have a pattern, indicating that our current model is a good fit.

3.44.

Suppose that four normal populations have means of mu1=50,mu2=2 mu3=60, mu4=3 mu5=50, and mu6=60. How many observations should be taken from each population so that the probability of rejecting the null hypothesis of equal population means is at least 0.90? Assume that a=0.05 and that a reasonable estimate of the error variance is sigma^2=25.

library(pwr)

pwr.anova.test(k=5,n=NULL,f=((10)/sqrt(25)),sig.level=.05,power=.90)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 5
##               n = 2.001787
##               f = 2
##       sig.level = 0.05
##           power = 0.9
## 
## NOTE: n is number in each group

We should have 3 samples of each population.

3.45.

Refer to Problem 3.44.

(a)

How would your answer change if a reasonable estimate of the experimental error variance were sigma^2=36?

pwr.anova.test(k=5,n=NULL,f=((10)/sqrt(36)),sig.level=.05,power=.90)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 5
##               n = 2.30454
##               f = 1.666667
##       sig.level = 0.05
##           power = 0.9
## 
## NOTE: n is number in each group

We should still have 3 samples of each population.

(b)

How would your answer change if a reasonable estimate of the experimental error variance were sigma^2=49?

pwr.anova.test(k=5,n=NULL,f=((10)/sqrt(49)),sig.level=.05,power=.90)
## 
##      Balanced one-way analysis of variance power calculation 
## 
##               k = 5
##               n = 2.670011
##               f = 1.428571
##       sig.level = 0.05
##           power = 0.9
## 
## NOTE: n is number in each group

We should still have 3 samples of each population.

(c)

Can you draw any conclusions about the sensitivity ofyour answer in this particular situation about how your estimate of sigma affects the decision about sample size?

It would seem that our sample size is not very affected by our error standard deviation/variance. It is not very sensitive at all.

(d)

Can you make any recommendations about how we should use this general approach to choosing n in practice?

Choosing n does not seem to heavily depend on standard deviation, therfore, how different our samples are in variance might not change how many samples we need. A high level of variance does not considerably affect the amopunt of samples we need to prove our point.

All code used:

tech1 <- c(3129, 3000, 2865, 2890)
tech2 <-  c(3200, 3300, 2975, 3150)
tech3 <-  c(2800 ,2900, 2985, 3050)
tech4 <- c( 2600 ,2700, 2600 ,2765)
technique <- c(tech1[1:length(tech1)],tech2[1:length(tech2)])
dafr <- data.frame(tech1,tech2,tech3,tech4)
dafr2 <- cbind(stack(dafr[1:4]))
atest <- aov(values~ind,dafr2)


library(agricolae)
LSD<- LSD.test(atest,'ind')


 
 plot(dafr2,ylab="Technique",xlab="Tensile Strength",main="Scatterplot")



cwp15 <-  c(7 ,7 ,15 ,11, 9)
cwp20 <-  c(12 ,17 ,12 ,18,18)
cwp25 <-  c(14 ,19 ,19 ,18, 18)
cwp30 <-  c(19 ,25 ,22, 19 ,23)
cwp35 <-  c(7 ,10, 11, 15 ,11)
dafr3 <- data.frame(cwp15,cwp20,cwp25,cwp30,cwp35)

dafr4 <- cbind(stack(dafr3[1:5]))
atest2 <- aov(values~ind,dafr4)
LSD<- LSD.test(atest2,'ind')
LSD

  

plot(aov(values~ind,dafr4))

  


library(pwr)
pwr.anova.test(k=5,n=NULL,f=((10)/sqrt(25)),sig.level=.05,power=.90)

pwr.anova.test(k=5,n=NULL,f=((10)/sqrt(36)),sig.level=.05,power=.90)


pwr.anova.test(k=5,n=NULL,f=((10)/sqrt(49)),sig.level=.05,power=.90)