Part 1:
Goal: Potential differences nozzle designs have on stability and Performance.
Factors: Nozzle Design (1:5)
Blocks: Diffent Jet Efflux Velocity (11.73, 14.37, 16.59, 20.43, 23.46, 28.74)
values <- matrix(c( 0.78, 0.80, 0.81, 0.75, 0.77, 0.78,
0.85, 0.85, 0.92, 0.86, 0.81,0.83,
0.93, 0.92, 0.95, 0.89, 0.89, 0.83,
1.14, 0.97, 0.98, 0.88, 0.86, 0.83,
0.97, 0.86, 0.78, 0.76, 0.76, 0.75), ncol=6, byrow = T)
y <- as.numeric(values)
#treatment is Nozzle type
x <- factor(rep(1:5,6))
#block is the six levels of efflux velocity
b <- factor(c(rep(11.73,5),rep(14.37,5),rep(16.59,5),rep(20.43,5),rep(23.46,5),rep(28.74,5)))
# fit the model
model <- aov(y~x+b)
anova(model)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## x 4 0.102180 0.025545 8.9162 0.0002655 ***
## b 5 0.062867 0.012573 4.3886 0.0073642 **
## Residuals 20 0.057300 0.002865
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Based on the result, we reject the null hypothesis and conclude that at least one of the treatment effect is not equal to zero. This means the nozzle type is a determinant for stability and performance.Note that the nusiance variability from different velocity is controlled for by adding a blocking factor
# normality and Equality variance test
qqnorm(model$residuals)
qqline(model$residuals)
shapiro.test(model$residuals)
##
## Shapiro-Wilk normality test
##
## data: model$residuals
## W = 0.96992, p-value = 0.5369
# Data seems to be fairly normal. The shapiro wilk test confirms this observation since the p-value > 0.05 (Null hypothesis: data is normally distributed.)
model2<- aov(y~x)
plot(model2$fitted.values,model2$residuals)
abline(h=0)
#Since no unique shape to plot, We can conlclude that equal variance across groups exist.
#Part 2
Entering Data
data= c(5.34,6.65,4.76,5.98,7.25,
6.00,7.55,5.54,5.62,6.21,
5.97,7.35,5.44,4.39,4.98,
5.25,6.35,4.61,6.00,5.32)
#a
library(DescTools)
alpha= 0.05
lower_bound= (length(data) - 1) * var(data)/ qchisq(1-alpha/2, df=19)
upper_bound= (length(data) - 1) * var(data)/ qchisq(alpha/2, df=19)
bounds = c(lower_bound,upper_bound)
print(paste("The 95% confidence interval estimate for the variance is","(",lower_bound,",",upper_bound,")"))
## [1] "The 95% confidence interval estimate for the variance is ( 0.457152397856341 , 1.68623951130305 )"
# Use var test to confirm results
VarTest(data,conf.level = 0.95)
##
## One Sample Chi-Square test on variance
##
## data: data
## X-squared = 15.019, df = 19, p-value = 0.5572
## alternative hypothesis: true variance is not equal to 1
## 95 percent confidence interval:
## 0.4571524 1.6862395
## sample estimates:
## variance of x
## 0.7904484
#Results confirmed
#b - Test the hypothesis that σ squared = 1.0. Use α = 0.05. What are your conclusions?
tcrit_lower=qchisq(alpha/2, df=19)
tcrit_upper=qchisq(1-alpha/2, df=19)
criticial_region= c(tcrit_lower,tcrit_upper)
#The critical region is (8.906516, 32.852327)
#Null Hypthesis : Ho: population variance = 1
#Alternative hypothesis : Ha: population variance != 1
X_squared= (length(data)-1)* (sd(data)/1)^2
#Test statistics is X_squared
#Reject Ho if Test statistic isn't within the critical region ( 8.906516 to 32.852327). Since Ho is within critical region, we fail to reject the null hypthesis and conclude that the true variance is equal to 1.
VarTest(data,conf.level = 0.95)
##
## One Sample Chi-Square test on variance
##
## data: data
## X-squared = 15.019, df = 19, p-value = 0.5572
## alternative hypothesis: true variance is not equal to 1
## 95 percent confidence interval:
## 0.4571524 1.6862395
## sample estimates:
## variance of x
## 0.7904484
# The var test to confirms results, since the p-value > 0.05.
c
# Assumption of normality means that our data approximately fits a bell curve shape, The statistical test(f-test) required for this question relies on this assumption.
qqnorm(data)
qqline(data)
shapiro.test(data)
##
## Shapiro-Wilk normality test
##
## data: data
## W = 0.95981, p-value = 0.5401
#Based on the plot above, it appears normality is observed. The shapiro wilk test confirms result.