######################################################
# Stat 430 - Assignment 6 (3c)
#
# Sarah Rathwell - 301084687
#
# Objective - Investigate fractional factorial design
# of metal gears.
######################################################
rm(list=ls())
options(width=200)
library(DoE.base)
## 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
## The following object is masked from 'package:base':
##
## lengths
######################################################
cat(" Investigate the effects of Temp, Time, Carbon,",
"and interactions on Pitch in a 2^(6-2) design.
\n\n", "Last modification:",date(),'\n')
## Investigate the effects of Temp, Time, Carbon, and interactions on Pitch in a 2^(6-2) design.
##
##
## Last modification: Fri Sep 9 11:45:19 2016
######################################################
#
# Create datat set and check
#
A <-rep(c(-1,1),8)
B <-rep(c(rep(-1,2),rep(1,2)),4)
C <-rep(c(rep(-1,4),rep(1,4)),2)
D <-c(rep(-1,8),rep(1,8))
E <-A*B*C
G <-B*C*D # Note original data set uses "F"
Pi <-c(74,190,133,127,115,101,54,144,121,188,125,170,126,175,126,193)
P.df <-data.frame(A,B,C,D,E,G,Pi)
P.df
## A B C D E G Pi
## 1 -1 -1 -1 -1 -1 -1 74
## 2 1 -1 -1 -1 1 -1 190
## 3 -1 1 -1 -1 1 1 133
## 4 1 1 -1 -1 -1 1 127
## 5 -1 -1 1 -1 1 1 115
## 6 1 -1 1 -1 -1 1 101
## 7 -1 1 1 -1 -1 -1 54
## 8 1 1 1 -1 1 -1 144
## 9 -1 -1 -1 1 -1 1 121
## 10 1 -1 -1 1 1 1 188
## 11 -1 1 -1 1 1 -1 125
## 12 1 1 -1 1 -1 -1 170
## 13 -1 -1 1 1 1 -1 126
## 14 1 -1 1 1 -1 -1 175
## 15 -1 1 1 1 -1 1 126
## 16 1 1 1 1 1 1 193
#
# Create linear model for the 15 unique factors and test effect
# sizes on half normal plot
P.fit <-lm(Pi~A*B+A*C+A*D+A*E+A*G+B*D+B*G+A*B*D+A*B*G, data=P.df)
P.coef <-P.fit$coeff[2:16]
P.ef <-2*P.coef
halfnormal(P.ef, main='Plot for Effects, Alpha=0.05')

######################################################