Null hypothesis: All the mean strengths are the same and Alternative hypothesis: At least one mean strength is different
r1 <- c(1530,1530,1440)
r2 <- c(1610,1650,1500)
r3 <- c(1560,1730,1530)
r4 <- c(1500,1490,1510)
df <- rbind(r1,r2,r3,r4)
sam <- c(r1,r2,r3,r4) # Samples
pop <- c(10,15,20,25) # Populations
SSt <- 0 # Sum of Squares total
SStr <- 0 # Sum of Squares treatment
for(i in 1:length(sam))
{
SSt <- SSt + sam[i]^2
}
SSt <- SSt-(sum(sam)^2/length(sam))
for(i in 1:length(pop))
{
SStr <- SStr + sum(df[i,])^2
}
SStr <- (1/length(df[1,]))*SStr-(sum(sam)^2/length(sam))
SSE <- SSt-SStr
DOFbtr <- length(pop)-1 # Degrees of freedom between treatments
DOFe <- length(sam)-length(pop) # Degrees of freedom within treatment
DOFt <- length(sam)-1 # Degrees of freedom Total
MStr <- SStr/DOFbtr # Mean of squares of treatments
MSE <- SSE/DOFe # Mean of squares of error
MStr/MSE # F statistic
## [1] 1.865364
p = 0.2138 # P-value
Fo = 1.8653637, and the upper-tail percentage point of the F distribution is 4.07. Because 1.8653637 < 4.07, we cannot reject the null hypothesis and conclude that the means are equal, and that the cotton content does not affect the tensile strength. This is supported by the P-value, which is greater than 0.05, implying that it is unlikely that the cotton content affects the tensile strength.
r1 <- c(3129,3000,2865,2890)
r2 <- c(3200,3300,2975,3150)
r3 <- c(2800,2900,2985,3050)
r4 <- c(2600,2700,2600,2765)
df <- rbind(r1,r2,r3,r4)
sam <- c(r1,r2,r3,r4) # Samples
pop <- c(1,2,3,4) # Populations
SSt <- 0 # Sum of Squares total
SStr <- 0 # Sum of Squares treatment
for(i in 1:length(sam))
{
SSt <- SSt + sam[i]^2
}
SSt <- SSt-(sum(sam)^2/length(sam))
for(i in 1:length(pop))
{
SStr <- SStr + sum(df[i,])^2
}
SStr <- (1/length(df[1,]))*SStr-(sum(sam)^2/length(sam))
SSE <- SSt-SStr
DOFbtr <- length(pop)-1 # Degrees of freedom between treatments
DOFe <- length(sam)-length(pop) # Degrees of freedom within treatment
DOFt <- length(sam)-1 # Degrees of freedom Total
MStr <- SStr/DOFbtr # Mean squares of treatments
MSE <- SSE/DOFe # Mean of squares of error
MStr/MSE # F statistic
r1 <- c(7,7,15,11,9)
r2 <- c(12,17,12,18,18)
r3 <- c(14,19,19,18,18)
r4 <- c(19,25,22,19,23)
r5 <- c(7,10,11,15,11)
df <- rbind(r1,r2,r3,r4,r5)
sam <- c(r1,r2,r3,r4,r5) # Samples
pop <- c(15,20,25,30,35) # Populations
SSt <- 0 # Sum of Squares total
SStr <- 0 # Sum of Squares treatment
for(i in 1:length(sam))
{
SSt <- SSt + sam[i]^2
}
SSt <- SSt-(sum(sam)^2/length(sam))
for(i in 1:length(pop))
{
SStr <- SStr + sum(df[i,])^2
}
SStr <- (1/length(df[1,]))*SStr-(sum(sam)^2/length(sam))
SSE <- SSt-SStr
DOFbtr <- length(pop)-1 # Degrees of freedom between treatments
DOFe <- length(sam)-length(pop) # Degrees of freedom within treatment
DOFt <- length(sam)-1 # Degrees of freedom Total
MStr <- SStr/DOFbtr # Mean squares of treatments
MSE <- SSE/DOFe # Mean of squares of error
MStr/MSE # F statistic
r1 <- c(1530,1530,1440)
r2 <- c(1610,1650,1500)
r3 <- c(1560,1730,1530)
r4 <- c(1500,1490,1510)
df <- rbind(r1,r2,r3,r4)
sam <- c(r1,r2,r3,r4) # Samples
pop <- c(10,15,20,25) # Populations
SSt <- 0 # Sum of Squares total
SStr <- 0 # Sum of Squares treatment
for(i in 1:length(sam))
{
SSt <- SSt + sam[i]^2
}
SSt <- SSt-(sum(sam)^2/length(sam))
for(i in 1:length(pop))
{
SStr <- SStr + sum(df[i,])^2
}
SStr <- (1/length(df[1,]))*SStr-(sum(sam)^2/length(sam))
SSE <- SSt-SStr
DOFbtr <- length(pop)-1 # Degrees of freedom between treatments
DOFe <- length(sam)-length(pop) # Degrees of freedom within treatment
DOFt <- length(sam)-1 # Degrees of freedom Total
MStr <- SStr/DOFbtr # Mean of squares of treatments
MSE <- SSE/DOFe # Mean of squares of error
MStr/MSE # F statistic
p = 0.2138 # P-value