knitr::opts_chunk$set(echo = TRUE)
Meghan Cephus
09/29/2024
The variability determines the the effect size. For each variability the effect size, f, will change.
f = \[ d\sqrt{\frac{1}{2k}}\]
sigma <- 3.5
range <- 2
d <- range/sigma
library(pwr)
pwr.anova.test(k=4,n=NULL,f=d*sqrt(1/(2*4)),sig.level=0.05,power=0.8)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 67.76303
## f = 0.2020305
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
f = \[ \frac{d}{2}\sqrt{\frac{k+1}{3(k-1)}}\]
pwr.anova.test(k=4,n=NULL,f=(d/2)*sqrt(5/(3*3)),sig.level=0.05,power=0.8)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 61.08609
## f = 0.2129589
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
f = even\[ \frac{d}{2}\]
pwr.anova.test(k=4,n=NULL,f=d/2,sig.level=0.05,power=0.8)
##
## Balanced one-way analysis of variance power calculation
##
## k = 4
## n = 34.38178
## f = 0.2857143
## sig.level = 0.05
## power = 0.8
##
## NOTE: n is number in each group
I believe there might be an error in my calculations since as the variability increases the sample size decreases. The sample sizes are also quite large. I suspect there is a problem with the effect size, f, calculation. Either with the formula or the calculation of d.
The experimenter decided to collect six observations for each type of fluid, resulting in the following test data.
a. Test the hypothesis that the life of fluids is the same against the alternative that they differ at an α=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)
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)
dat <- data.frame(F1,F2,F3,F4)
library(tidyr)
dat <- pivot_longer(dat,c(F1,F2,F3,F4))
aov <- aov(value~name, data=dat)
summary(aov)
## 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
qf(0.9, 3, 20)
## [1] 2.380087
Conclusion:
F = 3.047 and F critical = 2.38 for α=0.10. F > F critical 3.047 > 2.38. We CAN reject the Null Hypothesis. We can conclude that the fluid type DOES make a difference in life hours.
b. Is the model adequate? (show plots and comment)
plot(aov)
Conclusion:
The residuals vs. fitted graph shows the variance is reasonably consistent. The Q-Q residuals show that the model is reasonably normal.
c. Assuming the null hypothesis in question 1 is rejected, which fluids significantly differ using a family-wise error rate of α=0.10 (use Tukey’s test). Include the plot of confidence intervals.
TukeyHSD(aov,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
## F2-F1 -0.7000000 -3.2670196 1.8670196 0.9080815
## F3-F1 2.3000000 -0.2670196 4.8670196 0.1593262
## F4-F1 0.1666667 -2.4003529 2.7336862 0.9985213
## F3-F2 3.0000000 0.4329804 5.5670196 0.0440578
## F4-F2 0.8666667 -1.7003529 3.4336862 0.8413288
## F4-F3 -2.1333333 -4.7003529 0.4336862 0.2090635
plot(TukeyHSD(aov,conf.level = 0.90))
Conclusion:
Only the means of Fluid 2 and Fluid 3 significantly differed. This is because their range of differences does not include the number 0 unlike the rest of the comparisons. This is also seen in the graph where the graph of Fluid 2 vs Fluid 3 is the only one that does not cross the 0 line.