Munira Shahir
Rensselaer Polytechnic Institute
The data set tested comes from the Ecdat package in R and the data set is named Males. The data set consists of 4360 observations from 1980 to 1987
## Loading required package: Ecfun
##
## Attaching package: 'Ecfun'
## The following object is masked from 'package:base':
##
## sign
##
## Attaching package: 'Ecdat'
## The following object is masked from 'package:datasets':
##
## Orange
The data set contains the following factors: union: levels “no”" and “yes”
ethn: levels “black”,“hisp”, and “other”
maried: levels “no” and “yes”
health: levels “no” and “yes”
industry: levels “Agricultural”, “Mining”, “Construction”,“Trade”, “Transportation,”Finance“,”Business and Repair Service“,”Personal_Service“,”Entertainment“,”Manufacturing“,”Professional and Related Service“,”Public Administration"
occupation: levels “Professional, Technicaland kindred”, “Managers, Officials_and_Proprietors”, “Sales_Workers”,“Clerical_and_kindred”, “Craftsmen, Foremen_and_kindred”,“Operatives_and_kindred”,“Laborers_and_farmers”,“Farm_Laborers_and_Foreman”,“Service_Workers”
residence: levels rural area,north east, northern central, south
Note the residence factor will be grouped as a three-level factor by merging together south and rural area in to rural-south
The data set contains the following continous variables: nr: identifiant
year: years
school: years of schooling
exper: years of experience
wage: log of hourly wages
The response is the log of hourly wages wage.
Below are the first 6 observations of the Males data set with “rural” and “south” merged. Where 1 represents either “rural” or “south”, 2 represents “northeast”, and 3 represents “northerncentral”
## wage maried health ethn residence RES
## 1 1.197540 no no other north_east 2
## 2 1.853060 no no other north_east 2
## 3 1.344462 no no other north_east 2
## 4 1.433213 no no other north_east 2
## 5 1.568125 no no other north_east 2
## 6 1.699891 no no other north_east 2
Below is the structure of the data set
## 'data.frame': 4360 obs. of 6 variables:
## $ wage : num 1.2 1.85 1.34 1.43 1.57 ...
## $ maried : Factor w/ 2 levels "no","yes": 1 1 1 1 1 1 1 1 1 1 ...
## $ health : Factor w/ 2 levels "no","yes": 1 1 1 1 1 1 1 1 1 1 ...
## $ ethn : Factor w/ 3 levels "other","black",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ residence: Factor w/ 4 levels "rural_area","north_east",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ RES : num 2 2 2 2 2 2 2 2 2 2 ...
The purpose of this experiment is to observe the impact of a multitude factors on the log of hourly wage. A Taguchi experimntal design will be used.
The Taguchi design will be examined with both a 2^6 factorial design and a 2^2 * 3^2 design. The Taguchi experimental design with the least number of experimental runs will be chosen for further analysis.
Upon examining a Taguchi experimental design for a 2^6 experiment, the first table below shows that 8 experimental runs are needed. However, for a 2^2 * 3^2 experiment, 36 experimental runs are required. As a result, the 2^6 experimental design will be analyzed which is the same as in the fractional factorial design project. This is because there are fewer experimental runs which will same time.
library("qualityTools")
## Warning: package 'qualityTools' was built under R version 3.3.2
## Loading required package: Rsolnp
## Warning: package 'Rsolnp' was built under R version 3.3.2
## Loading required package: MASS
##
## Attaching package: 'MASS'
## The following object is masked from 'package:Ecdat':
##
## SP500
##
## Attaching package: 'qualityTools'
## The following object is masked from 'package:stats':
##
## sigma
taguchiChoose(factors1=6,level1=2)
## 6 factors on 2 levels and 0 factors on 0 levels with 0 desired interactions to be estimated
##
## Possible Designs:
##
## L8_2 L12_2 L16_2 L32_2
##
## Use taguchiDesign("L8_2") or different to create a taguchi design object
taguchiDesign("L8_2")
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## StandOrder RunOrder Replicate A B C D E F G y
## 1 1 1 1 1 1 1 1 1 1 1 NA
## 2 8 2 1 2 2 1 2 1 1 2 NA
## 3 6 3 1 2 1 2 2 1 2 1 NA
## 4 5 4 1 2 1 2 1 2 1 2 NA
## 5 3 5 1 1 2 2 1 1 2 2 NA
## 6 2 6 1 1 1 1 2 2 2 2 NA
## 7 4 7 1 1 2 2 2 2 1 1 NA
## 8 7 8 1 2 2 1 1 2 2 1 NA
taguchiChoose(factors1=2,level1=3,factors2=2,level2=2)
## 2 factors on 3 levels and 2 factors on 2 levels with 0 desired interactions to be estimated
##
## Possible Designs:
##
## L36_2_3_a L36_2_3_b
##
## Use taguchiDesign("L36_2_3_a") or different to create a taguchi design object
taguchiDesign("L36_2_3_a")
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## StandOrder RunOrder Replicate A B C D E F G H J K L M N O P Q R S T U V
## 1 20 1 1 2 1 2 2 1 1 2 2 1 2 1 2 3 2 1 1 1 2 3 3 2
## 2 15 2 1 1 2 2 1 2 2 1 2 1 2 1 3 1 2 3 2 1 3 2 2 1
## 3 8 3 1 1 1 2 2 2 1 1 1 2 2 2 2 2 3 1 2 3 1 1 2 3
## 4 23 4 1 2 1 2 1 2 2 2 1 1 1 2 2 3 3 1 1 2 3 2 2 1
## 5 5 5 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 1 1
## 6 26 6 1 2 1 1 2 2 2 1 2 2 1 1 2 1 3 2 3 1 1 2 1 2
## 7 14 7 1 1 2 2 1 2 2 1 2 1 2 1 2 3 1 2 1 3 2 1 1 3
## 8 17 8 1 1 2 2 2 1 2 2 1 2 1 1 2 3 1 3 2 2 1 3 1 1
## 9 2 9 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2
## 10 7 10 1 1 1 2 2 2 1 1 1 2 2 2 1 1 2 3 1 2 3 3 1 2
## 11 34 11 1 2 2 1 1 2 1 2 1 2 2 1 1 3 1 2 3 2 3 1 2 2
## 12 31 12 1 2 2 1 2 1 2 1 1 1 2 2 1 3 3 3 2 3 2 2 1 2
## 13 4 13 1 1 1 1 1 1 2 2 2 2 2 2 1 1 1 1 2 2 2 2 3 3
## 14 6 14 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 1 1 1 1 2 2
## 15 32 15 1 2 2 1 2 1 2 1 1 1 2 2 2 1 1 1 3 1 3 3 2 3
## 16 27 16 1 2 1 1 2 2 2 1 2 2 1 1 3 2 1 3 1 2 2 3 2 3
## 17 3 17 1 1 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3
## 18 16 18 1 1 2 2 2 1 2 2 1 2 1 1 1 2 3 2 1 1 3 2 3 3
## 19 25 19 1 2 1 1 2 2 2 1 2 2 1 1 1 3 2 1 2 3 3 1 3 1
## 20 19 20 1 2 1 2 2 1 1 2 2 1 2 1 1 2 1 3 3 3 1 2 2 1
## 21 30 21 1 2 2 2 1 1 1 1 2 2 1 2 3 2 1 1 1 3 3 2 1 2
## 22 1 22 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## 23 18 23 1 1 2 2 2 1 2 2 1 2 1 1 3 1 2 1 3 3 2 1 2 2
## 24 22 24 1 2 1 2 1 2 2 2 1 1 1 2 1 2 2 3 3 1 2 1 1 3
## 25 36 25 1 2 2 1 1 2 1 2 1 2 2 1 3 2 3 1 2 1 2 3 1 1
## 26 12 26 1 1 2 1 2 2 1 2 2 1 1 2 3 3 2 1 3 2 1 2 1 3
## 27 28 27 1 2 2 2 1 1 1 1 2 2 1 2 1 3 2 2 2 1 1 3 2 3
## 28 35 28 1 2 2 1 1 2 1 2 1 2 2 1 2 1 2 3 1 3 1 2 3 3
## 29 24 29 1 2 1 2 1 2 2 2 1 1 1 2 3 1 1 2 2 3 1 3 3 2
## 30 11 30 1 1 2 1 2 2 1 2 2 1 1 2 2 2 1 3 2 1 3 1 3 2
## 31 29 31 1 2 2 2 1 1 1 1 2 2 1 2 2 1 3 3 3 2 2 1 3 1
## 32 9 32 1 1 1 2 2 2 1 1 1 2 2 2 3 3 1 2 3 1 2 2 3 1
## 33 33 33 1 2 2 1 2 1 2 1 1 1 2 2 3 2 2 2 1 2 1 1 3 1
## 34 21 34 1 2 1 2 2 1 1 2 2 1 2 1 3 1 3 2 2 2 3 1 1 3
## 35 10 35 1 1 2 1 2 2 1 2 2 1 1 2 1 1 3 2 1 3 2 3 2 1
## 36 13 36 1 1 2 2 1 2 2 1 2 1 2 1 1 2 3 1 3 2 1 3 3 2
## W X y
## 1 3 1 NA
## 2 3 1 NA
## 3 3 1 NA
## 4 1 3 NA
## 5 1 1 NA
## 6 3 3 NA
## 7 2 3 NA
## 8 3 2 NA
## 9 2 2 NA
## 10 2 3 NA
## 11 3 1 NA
## 12 1 1 NA
## 13 3 3 NA
## 14 2 2 NA
## 15 2 2 NA
## 16 1 1 NA
## 17 3 3 NA
## 18 2 1 NA
## 19 2 2 NA
## 20 2 3 NA
## 21 3 2 NA
## 22 1 1 NA
## 23 1 3 NA
## 24 3 2 NA
## 25 2 3 NA
## 26 2 1 NA
## 27 1 3 NA
## 28 1 2 NA
## 29 2 1 NA
## 30 1 3 NA
## 31 2 1 NA
## 32 1 2 NA
## 33 3 3 NA
## 34 1 2 NA
## 35 3 2 NA
## 36 1 2 NA
There is no randomization in the data set.
There are no replicates in the original dataset.
Blocking is not used in this design. However, it is possible to block if necessary.
Before decomposing the 3-level factors into 2-level factors, exploratory data analysis will be conducted via boxplots.
After conducting exploratory data analysis, the Taguchi design is formed. A seed is set to reproduce results.
## 6 factors on 2 levels and 0 factors on 0 levels with 0 desired interactions to be estimated
##
## Possible Designs:
##
## L8_2 L12_2 L16_2 L32_2
##
## Use taguchiDesign("L8_2") or different to create a taguchi design object
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Warning in `[<-`(`*tmp*`, i, value = <S4 object of class
## structure("taguchiFactor", package = "qualityTools")>): implicit list
## embedding of S4 objects is deprecated
## Taguchi SINGLE Design
## Information about the factors:
##
## A B C D E
## value 1 1 1 1 1 1
## value 2 2 2 2 2 2
## name Factor RS Factor NEC Factor Hisp Factor Black Factor Marry
## unit
## type numeric numeric numeric numeric numeric
## F G
## value 1 1 1
## value 2 2 2
## name Factor Health <NA>
## unit
## type numeric numeric
##
## -----------
##
## StandOrder RunOrder Replicate A B C D E F G wage
## 1 1 1 1 1 1 1 1 1 1 1 1.588373
## 2 6 2 1 2 1 2 2 1 2 1 1.791286
## 3 8 3 1 2 2 1 2 1 1 2 1.253672
## 4 3 4 1 1 2 2 1 1 2 2 1.517771
## 5 2 5 1 1 1 1 2 2 2 2 1.701063
## 6 4 6 1 1 2 2 2 2 1 1 1.466543
## 7 5 7 1 2 1 2 1 2 1 2 1.349393
## 8 7 8 1 2 2 1 1 2 2 1 1.296499
##
## -----------
Now an effect plot is created by utilizing the qualityTools package and the Taguchi design.
effectPlot(tdesign,ppoints=TRUE,col=2,lty=3,main="Taguchi Design Main Effect Plot")
## Warning in plot.window(...): "ppoints" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "ppoints" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in box(...): "ppoints" is not a graphical parameter
## Warning in title(...): "ppoints" is not a graphical parameter
## Warning in axis(1, x, ...): "ppoints" is not a graphical parameter
## Warning in plot.window(...): "ppoints" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "ppoints" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in box(...): "ppoints" is not a graphical parameter
## Warning in title(...): "ppoints" is not a graphical parameter
## Warning in axis(1, x, ...): "ppoints" is not a graphical parameter
## Warning in plot.window(...): "ppoints" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "ppoints" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in box(...): "ppoints" is not a graphical parameter
## Warning in title(...): "ppoints" is not a graphical parameter
## Warning in axis(1, x, ...): "ppoints" is not a graphical parameter
## Warning in plot.window(...): "ppoints" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "ppoints" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in box(...): "ppoints" is not a graphical parameter
## Warning in title(...): "ppoints" is not a graphical parameter
## Warning in axis(1, x, ...): "ppoints" is not a graphical parameter
## Warning in plot.window(...): "ppoints" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "ppoints" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in box(...): "ppoints" is not a graphical parameter
## Warning in title(...): "ppoints" is not a graphical parameter
## Warning in axis(1, x, ...): "ppoints" is not a graphical parameter
## Warning in plot.window(...): "ppoints" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "ppoints" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in box(...): "ppoints" is not a graphical parameter
## Warning in title(...): "ppoints" is not a graphical parameter
## Warning in axis(1, x, ...): "ppoints" is not a graphical parameter
## Warning in plot.window(...): "ppoints" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "ppoints" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "ppoints" is
## not a graphical parameter
## Warning in box(...): "ppoints" is not a graphical parameter
## Warning in title(...): "ppoints" is not a graphical parameter
## Warning in axis(1, x, ...): "ppoints" is not a graphical parameter
Now the main effects of the model from utilizing the data for the taguchi design can be estimated
fit <-lm(wage~rs+nec+hisp+black+marry+health,data=mytaguchidesign)
anova(fit)
## Analysis of Variance Table
##
## Response: wage
## Df Sum Sq Mean Sq F value Pr(>F)
## rs 1 0.042471 0.042471 3.3015 0.3203
## nec 1 0.100269 0.100269 7.7944 0.2190
## hisp 1 0.010181 0.010181 0.7914 0.5372
## black 1 0.026511 0.026511 2.0608 0.3873
## marry 1 0.014247 0.014247 1.1075 0.4838
## health 1 0.052591 0.052591 4.0882 0.2924
## Residuals 1 0.012864 0.012864
It’s apparent that the 8 experimental runs aren’t enough to estimate the main effects of the model. Upon looking back at the results of project 3, it’s apparent that fractional factiorial design is a better fit for thsi data.
qqnorm(residuals(fit))
qqline(residuals(fit))
plot(fitted(fit),residuals(fit))
From the Q-Q plot, it’s apparent that the data doesn’t follow a normal distribution. As a result, additonal analysis could be performed.
[1]https://cran.r-project.org/web/packages/Ecdat/Ecdat.pdf
[2]https://cran.r-project.org/web/packages/qualityTools/vignettes/qualityTools.pdf
library(Ecdat)
data("Males")
colnames <-c("wage","maried","health","ethn","residence")
project <-data.frame(Males$wage,Males$maried,Males$health,Males$ethn,Males$residence)
colnames(project)<- colnames
RES <- matrix(0,nrow = 4360, ncol = 1)
project3<-data.frame(project,RES)
colnames <-c("wage","maried","health","ethn","residence","RES")
colnames(project3) <- colnames
project3$RES[project3$residence=="rural_area"]<-1
project3$RES[project3$residence=="south"]<-1
project3$RES[project3$residence=="north_east"]<-2
project3$RES[project3$residence=="northern_central"]<-3
head(project3,6)
str(project3)
library("qualityTools")
taguchiChoose(factors1=6,level1=2)
taguchiDesign("L8_2")
taguchiChoose(factors1=2,level1=3,factors2=2,level2=2)
taguchiDesign("L36_2_3_a")
Married <- as.factor(project3$maried)
Health <- as.factor(project3$health)
Ethn <- as.factor(project3$ethn)
Resi <- as.numeric(project3$RES)
Wage <- as.numeric(project3$wage)
boxplot(Wage~Married,xlab="Maritial Status",ylab="Log of hourly wages")
boxplot(Wage~Health,xlab="Health Status",ylab="Log of hourly wages")
boxplot(Wage~Ethn,xlab="Ethnicity",ylab="Log of hourly wages")
boxplot(Wage~Resi,xlab="Residencial Location",ylab="Log of hourly wages")
colnames <-c("wage","maried","health","ethn","residence")
project <-data.frame(Males$wage,Males$maried,Males$health,Males$ethn,Males$residence)
colnames(project)<- colnames
RuralSouth <- matrix(0,nrow = 4360, ncol = 1)
NorthEC <- matrix(0,nrow = 4360, ncol = 1)
Hisp <- matrix(0,nrow = 4360, ncol = 1)
Black <- matrix(0,nrow = 4360, ncol = 1)
Marry <- matrix(0,nrow=4360,ncol=1)
Health <- matrix(0,nrow=4360,ncol=1)
project33<-data.frame(project,RuralSouth,NorthEC,Hisp,Black,Marry,Health)
colnames <-c("wage","maried","health","ethn","residence","RS","NEC","Hisp","Black","Marry","Health")
colnames(project33) <- colnames
project33$RS[project33$residence=="rural_area"]<-2
project33$RS[project33$residence=="south"]<-2
project33$RS[project33$residence=="north_east"]<-1
project3$RS[project33$residence=="northern_central"]<-1
project33$NEC[project33$residence=="rural_area"]<-1
project33$NEC[project33$residence=="south"]<-1
project33$NEC[project33$residence=="north_east"]<-2
project33$NEC[project33$residence=="northern_central"]<-2
project33$Hisp[project33$ethn=="black"]<-1
project33$Hisp[project33$ethn=="other"]<-1
project33$Hisp[project33$ethn=="hisp"]<-2
project33$Black[project33$ethn=="black"]<-2
project33$Black[project33$ethn=="other"]<-1
project33$Black[project33$ethn=="hisp"]<-1
project33$Marry[project33$maried=="no"]<-1
project33$Marry[project33$maried=="yes"]<-2
project33$Health[project33$health=="no"]<-1
project33$Health[project33$health=="yes"]???2
taguchiChoose(factors1 = 6,level1 = 2)
project4<- data.frame(project33$RS,project33$NEC,project33$Hisp,project33$Black,project33$Marry,project33$Health,project33$wage)
colnames <-c("RS","NEC","Hisp","Black","Marry","Health","Wage")
colnames(project4) <- colnames
set.seed(1234)
tdesign <- taguchiDesign("L8_2")
values(tdesign) = list(project4$RS,project4$NEC,project4$Hisp,project4$Black,project4$Marry,project4$Health)
names(tdesign)=c("Factor RS", "Factor NEC","Factor Hisp","Factor Black","Factor Marry","Factor Health")
#pulled values out by hand
wage <- project4$Wage[c(3941,2817,2832,2852,2864,4360,2913,3309)]
response(tdesign)<-wage
summary(tdesign)
effectPlot(tdesign,ppoints=TRUE,col=2,lty=3,main="Taguchi Design Main Effect Plot")
rs<-matrix(nrow=8,ncol=1)
nec<-matrix(nrow=8,ncol=1)
hisp<-matrix(nrow=8,ncol=1)
black<-matrix(nrow=8,ncol=1)
marry<-matrix(nrow=8,ncol=1)
health<-matrix(nrow=8,ncol=1)
wage<-matrix(nrow=8,ncol=1)
mytaguchidesign<-data.frame(rs,nec,hisp,black,marry,health,wage)
mytaguchidesign$rs<-c(1,2,2,1,1,1,2,2)
mytaguchidesign$nec<-c(1,1,2,2,1,2,1,2)
mytaguchidesign$hisp<-c(1,2,1,2,1,2,2,1)
mytaguchidesign$black<-c(1,2,2,1,2,2,1,1)
mytaguchidesign$marry<-c(1,1,1,1,2,2,2,2)
mytaguchidesign$health<-c(1,2,1,2,2,1,1,2)
mytaguchidesign$wage<- project4$Wage[c(3941,2817,2832,2852,2864,4360,2913,3309)]
fit <-lm(wage~rs+nec+hisp+black+marry+health,data=mytaguchidesign)
anova(fit)
qqnorm(residuals(fit))
qqline(residuals(fit))
plot(fitted(fit),residuals(fit))