install_tinytex()

title: “ST516_HW2_Problem_3” output: pdf_document date: “2026-02-06” —

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

#Input Data
strength <- c(7,7,15,11,9,12,17,12,18,18,14,18,18,19,19,19,25,22,19,23,7,10,11,15,11) 
#Assign data to factors
content <- factor(rep(c("15%","20%","25%","30%","35%"), each=5))
#Put Data into data frame
ts_data <- data.frame(strength, content)
#We will run an ANOVA model on this data
model1=aov(strength~content)
#create summary of model
summary(model1)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## content      4  475.8  118.94   14.76 9.13e-06 ***
## Residuals   20  161.2    8.06                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Mean for each factor (point estimates)
tapply(strength,content, mean)
##  15%  20%  25%  30%  35% 
##  9.8 15.4 17.6 21.6 10.8
#SD estimates for each factor
tapply(strength,content, sd)
##      15%      20%      25%      30%      35% 
## 3.346640 3.130495 2.073644 2.607681 2.863564
#Tukey Method
TukeyHSD(model1)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = strength ~ content)
## 
## $content
##          diff         lwr        upr     p adj
## 20%-15%   5.6   0.2270417 10.9729583 0.0385024
## 25%-15%   7.8   2.4270417 13.1729583 0.0025948
## 30%-15%  11.8   6.4270417 17.1729583 0.0000190
## 35%-15%   1.0  -4.3729583  6.3729583 0.9797709
## 25%-20%   2.2  -3.1729583  7.5729583 0.7372438
## 30%-20%   6.2   0.8270417 11.5729583 0.0188936
## 35%-20%  -4.6  -9.9729583  0.7729583 0.1162970
## 30%-25%   4.0  -1.3729583  9.3729583 0.2101089
## 35%-25%  -6.8 -12.1729583 -1.4270417 0.0090646
## 35%-30% -10.8 -16.1729583 -5.4270417 0.0000624
#Plot Tukey Method for fun
plot(TukeyHSD(model1))

#Bonferroni method
pairwise.t.test(strength, content, p.adj = "bonferroni")
## 
##  Pairwise comparisons using t tests with pooled SD 
## 
## data:  strength and content 
## 
##     15%     20%    25%    30%    
## 20% 0.0541  -      -      -      
## 25% 0.0031  1.0000 -      -      
## 30% 2.1e-05 0.0251 0.3754 -      
## 35% 1.0000  0.1859 0.0116 7.0e-05
## 
## P value adjustment method: bonferroni
#Part F, analyze residuals with histogram and boxplot
res<-residuals(model1)
hist(res)

boxplot(res)

#Part G, normal probability plot of residuals
qqnorm(residuals(model1))

#Part H, plot the residuals vs. the predicted tensile strength
plot(fitted.values(model1),residuals(model1),xlab="Fitted Values",ylab="Residuals"); abline(h=0)