Recipe 4: Example of Descriptive Statistics

This is an R Markdown document. Markdown is a simple formatting syntax for authoring web pages (click the MD toolbar button for help on Markdown).

When you click the Knit HTML button a web page 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:

Recipes for the Design of Experiments: Recipe Outline

as of August 28, 2014, superceding the version of August 24. Always use the most recent version.

Design of Experiments

Trevor Manzanares

Rensselaer Polytechnic Institute

10/10/14

1. Setting

System under test

Dataset under analysis includes data on design factors that contribute to reduced stress and improved vibrational dampening of tennis racquets.

remove(list=ls())
test = read.csv("C:/Users/Trevor/Documents/tennis.csv", header=TRUE) 

#view first few lines
head(test)
##   racquet_number                 material handle_design stiffness_rate
## 1              1             Carbon Fiber   Triple core             61
## 2              2                 Graphite     Dual core             63
## 3              3             Carbon Fiber   Triple core             57
## 4              4                 Graphite     Dual core             64
## 5              5                 Graphite     Dual core             61
## 6              6 Graphite w basalt planks        Hollow             68
#observe the structure of the data, ie. how many variables
str(test)
## 'data.frame':    10 obs. of  4 variables:
##  $ racquet_number: int  1 2 3 4 5 6 7 8 9 10
##  $ material      : Factor w/ 5 levels "Carbon Fiber",..: 1 2 1 2 2 5 3 2 2 4
##  $ handle_design : Factor w/ 3 levels "Dual core","Hollow",..: 3 1 3 1 1 2 2 2 2 2
##  $ stiffness_rate: int  61 63 57 64 61 68 67 70 67 65
#55 observations of 26 variables
attach(test)

Factors of interest and their levels

material (5 levels) and handle_design (3 levels)

#view summary statistics
summary(test)
##  racquet_number                               material     handle_design
##  Min.   : 1.00   Carbon Fiber                     :2   Dual core  :3    
##  1st Qu.: 3.25   Graphite                         :5   Hollow     :5    
##  Median : 5.50   Graphite Tungsten                :1   Triple core:2    
##  Mean   : 5.50   Graphite Tungsten/Copper/Titanium:1                    
##  3rd Qu.: 7.75   Graphite w basalt planks         :1                    
##  Max.   :10.00                                                          
##  stiffness_rate
##  Min.   :57.0  
##  1st Qu.:61.5  
##  Median :64.5  
##  Mean   :64.3  
##  3rd Qu.:67.0  
##  Max.   :70.0

Continuous variables (if any)

the response variable, stiffness_rate, ranged from a rating of 55 to 72 ### The Data: How is it organized and what does it look like? The data are tabluated into 4 columns, with each racquet having a material type, handle design, and stiffness rate ### Randomization The data were collected on ten racquet frame designs from five different manufacturers

2. (Experimental) Design

How will the experiment be organized and conducted to test the hypothesis?

Analysis of Variance will be used to attempt to reproduce the study performed by Ferrara and Cohen by measuring the effects of material and handle design on stiffness rate
### What is the rationale for this design? It is possible that material by itself may have an effect on the stiffness rate, and it is also possible that the handle design may have an effect on the stiffness rate.

Replicate: Are there replicates and/or repeated measures?

There are no replicates or repeated measures.
### Block: Did you use blocking in the design? Yes, one model was performed with blocking to determine if each of the factors had an effect by themselves.

3. (Statistical) Analysis

(Exploratory Data Analysis) Graphics and descriptive summary

par(mfrow=c(1,2))
plot(stiffness_rate~material,las=3)
plot(stiffness_rate~handle_design,las=3)

plot of chunk unnamed-chunk-3 ### Testing

#set up factorial design
library("DoE.base", lib.loc="~/R/win-library/3.1")
## Loading required package: grid
## Loading required package: conf.design
## 
## Attaching package: 'DoE.base'
## 
## The following objects are masked from 'package:stats':
## 
##     aov, lm
## 
## The following object is masked from 'package:graphics':
## 
##     plot.design
fac.design(nlevels=3, nfactors=2)
## creating full factorial with  9  runs ...
##   A B
## 1 1 1
## 2 2 1
## 3 2 2
## 4 3 1
## 5 2 3
## 6 3 2
## 7 1 3
## 8 3 3
## 9 1 2
## class=design, type= full factorial
#run analysis of variance for individual factor effects
model1=(aov(stiffness_rate~material,data=test))
anova(model1)
## Analysis of Variance Table
## 
## Response: stiffness_rate
##           Df Sum Sq Mean Sq F value Pr(>F)
## material   4   80.1    20.0    1.73   0.28
## Residuals  5   58.0    11.6
#based on material alone, we fail to reject the H0 that material type has no effect on the stiffness rate. Thus, variation in the stiffness rate can be attributed to randomization alone. 

model2=(aov(stiffness_rate~handle_design, data=test))
anova(model2)
## Analysis of Variance Table
## 
## Response: stiffness_rate
##               Df Sum Sq Mean Sq F value Pr(>F)   
## handle_design  2  112.2    56.1    15.2 0.0028 **
## Residuals      7   25.9     3.7                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#based on handle design alone, we reject the H0 that handle design has no effect on the stiffness rate. Thus, variation in the stiffness rate can be attributed to something other than randomization, namely handle design.

#run analysis of variance using interaction
interaction=aov(stiffness_rate~material*handle_design, data=test)
anova(interaction)
## Analysis of Variance Table
## 
## Response: stiffness_rate
##               Df Sum Sq Mean Sq F value Pr(>F)  
## material       4   80.1    20.0    4.67  0.082 .
## handle_design  1   40.8    40.8    9.51  0.037 *
## Residuals      4   17.2     4.3                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#in this particular model, we fail to reject the H0 that material type has no effect on stiffness rate, but reject the H0 that handle design has no effect on stiffness rate. 

#run analysis of variance with blocking
blocking=aov(stiffness_rate~material+handle_design, data=test)
anova(blocking)
## Analysis of Variance Table
## 
## Response: stiffness_rate
##               Df Sum Sq Mean Sq F value Pr(>F)  
## material       4   80.1    20.0    4.67  0.082 .
## handle_design  1   40.8    40.8    9.51  0.037 *
## Residuals      4   17.2     4.3                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#when considering blocking, the result is the same as the interaction effect.

Estimation (of Parameters)

# Shapiro-Wilk test of normality.  Adequate if p < 0.1
shapiro.test(stiffness_rate)
## 
##  Shapiro-Wilk normality test
## 
## data:  stiffness_rate
## W = 0.9707, p-value = 0.8977
qqnorm(stiffness_rate)
qqline(stiffness_rate)

plot of chunk unnamed-chunk-5 One of the primary assumptions of the analysis of variance is that the data are normally distributed, and since they are, the results from the analysis of variance are valid. ### Diagnostics/Model Adequacy Checking Describe

qqnorm(residuals(interaction))
qqline(residuals(interaction))

plot of chunk unnamed-chunk-6

plot(fitted(interaction),residuals(interaction))

plot of chunk unnamed-chunk-6

par(mfrow=c(1,1))
tukey1 = TukeyHSD(blocking, which="material", ordered = FALSE)
tukey2 = TukeyHSD(blocking, which="handle_design",ordered = FALSE)
plot(tukey1)

plot of chunk unnamed-chunk-6

#based on this test, there is no significant difference between the mean stiffness rate of any of the materials
plot(tukey2)

plot of chunk unnamed-chunk-6

#based on this test, there is no significant difference between the mean stiffness rate of any of the handle designs

4. References to the literature

This data were originally analyzed by Lisa Ferrara and Anders Cohen in “A mechanical study on tennis racquets to investigate design factors that contribute to reduced stress and improved vibrational dampening”

http://ac.els-cdn.com.libproxy.rpi.edu/S1877705813010667/1-s2.0-S1877705813010667-main.pdf?_tid=c82c3132-5076-11e4-a8a3-00000aab0f6b&acdnat=1412943362_153b3e50b33cd7648821e962c1ec1ec7

5. Appendices

A summary of, or pointer to, the raw data

Based on these data, the results were reproducible. There were statistically significant differences in mean stiffness_rate for the handle design. Further, material alone did not have an effect on stiffness, but handle design had an effect on stiffness rate. ### complete and documented R code

Please see above.