10 W10INSE6220 Fall 2023
10 W10INSE6220 Fall 2023
• Experimental Design
• Design of Experiments in Process Improvement
• Factorial Experiments
• Factorial Design
Concordia University
2
Experimental Design
➢ Objectives of an experiment
may include:
Statistical Analysis
• A factorial experiment is one that investigates the effects of two or more independent variables
(factors) on a single dependent variable (response).
• By a factor, we mean a discrete variable used to classify experimental units, such as
temperature, time, or pressure that may be varied from trial to trial.
• Modeling real world phenomena often requires more than just one factor. ANOVA can be
extended to handle the two-factor factorial experiment. Let the two factors be denoted A and B,
with a levels of factor A and b levels of factor B. The experiment is replicated n times.
i = 1, 2,..., a
yijk = + i + j + ( )ij + ijk j = 1, 2,..., b
k = 1, 2,..., n
5
Statistical Analysis
Let yi .. denote the total of the observations at the i-th level of factor A, y. j . denote
the total of the observations at the j-th level of factor B, yij . denote the total of the
observations in the ij-th cell of Table in previous slide, and y... denote the grand
total of all the observations.
Define yi.. , y. j . , yij . , and y... as the corresponding row, column, cell, and grand
averages. That is,
b n
yi..
yi.. = yijk yi.. = i = 1, 2,..., a
j =1 k =1 bn
a n y. j .
y. j . = yijk y. j . = j = 1, 2,..., b
i =1 k =1 an
n yij .
yij . = yijk yij . =
k =1 n
a b n
y...
y... = yijk y... =
i =1 j =1 k =1 abn
6
as follows
a b n a b
( y
i =1 j =1 k =1
ijk − y... ) = bn ( yi.. − y... ) + an ( y. j . − y... ) 2
2
i =1
2
j =1
a b
+ n ( yij . − yi.. − y. j . + y... )2
i =1 j =1
a b n
+ ( yijk − yij . )2
i =1 j =1 k =1
Or symbolically
SST = SS A + SS B + SS AB + SS E
8
Statistical Analysis
The corresponding degree of freedom decomposition is
Statistical Analysis
The ANOVA is usually performed with computer software, although simple computing
formulas for the sums of squares may be obtained easily. The computing formulas for
these sums of squares follow.
a b
y...2n
SST = y − 2
ijk
i =1 j =1 k =1 abn
• Main effects
yi2.. y...2
a
SS A = −
i =1 bn abn
b y.2j .
y...2
SS B = −
j =1 an abn
• Interaction a b yij2.
y...2
SS AB = − − SS A − SS B
i =1 j =1 n abn
• Error SS E = SST − SS A − SS B − SS AB
10
Example
Aircraft primer paints are applied to aluminum surfaces by two methods: dipping and
spraying. The purpose of the primer is to improve paint adhesion; some parts can be primed
using either application method. An engineer interested in learning whether three different
primers differ in their adhesion properties performed a factorial experiment to investigate the
effect of paint primer type and application method on paint adhesion. Three specimens were
painted with each primer using each application method, a finish paint was applied, and the
adhesion force was measured. The 18 runs from this experiment were run in random order.
The resulting data are shown in Table 12-1. The circled numbers in the cells are the cell
totals. The objective of the experiment was to determine which combination of primer paint
and application method produced the highest adhesion force. It would be desirable if at least
one of the primers produced high adhesion force regardless of application method, as this
method add some flexibility to the manufacturing process.
11
Example (cont.)
The ANOVA described above may be applied to the aircraft primer
paint experiment. The sums of squares required are:
a b n
y...2
SST = y − 2
ijk
i =1 j =1 k =1 abn
(89.8) 2
= (4.0) + (4.5) + ... + (5.0) −
2 2 2
= 10.72
18
a
yi2.. y...2
SSprimers = −
i =1 bn abn
(28.7) 2 + (34.1) 2 + (27.0) 2 (89.8) 2
= − = 4.58
6 18
b y2
y...2
SSmethods = −
. j.
j =1 an abn
2
(40.2) 2 + (49.6) 2 (89.8) 2
= − = 4.91
9 18
12
a b yij2.
y...2
SSinteration = − − SSprimers − SSmethods
i =1 j =1 n abn
(12.8) 2 + (15.9) 2 + (11.5) 2 + (15.9)2 + (18.2)2 + (15.5) 2 (89.8)2
= − − 4.58 − 4.91
3 18
= 0.24
and
Sum of Degrees of
Source of Variation Squares Freedom Mean Square F0
Primer types 4.58 2 2.29 28.63
Application methods 4.91 1 4.91 61.38
Interaction 0.24 2 0.12 1.5
Error 0.99 12 0.08
Total 10.72 17
13
14
Python code
#data from the adhesion force experiment
#FactorA = 3levels and FactorB = 2levels -> 3^2 = 9
df = pd.DataFrame({'AM': np.repeat(['Dipping', 'Spraying'], 9),
'PT': np.tile(np.repeat(['1', '2', '3'], 3), 2),
'force': [4.0, 4.5, 4.3,
5.6, 4.9, 5.4,
3.8, 3.7, 4.0,
5.4, 4.9, 5.6,
5.8, 6.1, 6.3,
5.5, 5.0, 5.0]})
import statsmodels.api as sm
from statsmodels.formula.api import ols
model = ols('force ~ C(PT) + C(AM) + C(PT):C(AM)', data=df).fit()
sm.stats.anova_lm(model, typ=2)
15
Residual Analysis
Just as in the single-factor experiments, the residuals from a factorial experiment
play an important role in assessing model adequacy. The residuals from a two-
factor factorial are
eijk = yijk − yˆijk
= yijk − yij .
That is, the residuals are simply the difference between the observations and the
corresponding cell averages.
Dipping Spraying
1 -0.26, 0.23, 0.03 0.10, -0.40, 0.30
2 0.30, -0.40, 0.10 -0.26, 0.03, 0.23
3 -0.03, -0.13, 0.16 0.34, -0.17, -0.17
16
Residual Analysis
17
The 22 Design
The geometry of the 2 design is shown in Fig. 12-17a. Note that the design can be
2
represented geometrically as a square with the 2 = 4 runs forming the corners of the
2
square. Fig. 12-17b shows the 4 runs in a tabular format often called the test matrix.
In these equations, the contrast coefficients are always either +1 or -1. A table of plus
and minus signs, can be used to determine the sign of each run for a particular contrast.
Let k be the number of factors. Then the effects and the sums of squares for
A, B, and AB are obtained as follows:
Contrast (Contrast) 2 2 k −2
Effect = SS = = n (Effect) 2
n2k −1 n2 k
[a + ab − b − (1)]2
SS A =
4n
[b + ab − a − (1)]2
Therefore the sums of squares for A, B, and AB are: SS B =
4n
[ab + (1) − a − b]2
SS AB =
4n
21
Example (cont.)
Python code
% two-level experiment
n = 4; k = 2;
% data from the router experiment
data = np.array([[18.2, 18.9, 12.9, 14.4], [27.2, 24.0, 22.4, 22.5], [15.9, 14.5, 15.1, 14.2], [41.0, 43.9, 36.3, 39.9]])
M = np.array([[-1., -1., 1.], [ 1., -1., -1.], [-1., 1., -1.], [ 1., 1., 1.]]) #design matrix
R = np.tile(M, (n, 1)) #replicate of design matrix
g1 = R[:,0]; g2 = R[:,1] #factors A and B
y = data.flatten(order='F')
# Fit the model
formula = 'y ~ C(g1) + C(g2) + C(g1):C(g2)'
df = pd.DataFrame(np.stack((y, g1, g2),-1), columns=['y', 'g1', 'g2'])
model = ols(formula, df).fit()
# Peform analysis of variance on fitted linear model
table = anova_lm(model, typ=2)
print(table)
A B AB
= 0.05 f ,1,2 k
( n −1)
= f0.05,1,12 = 4.7472 yˆ = y + x1 + x2 + x1 x2
2 2 2
26
Interaction Plot
27
Residual Analysis
The data of normal probability plot appear fairly linear, suggesting that no reason to doubt the
normality assumption. Also, the residual plots against the fitted values as well as against the
factor levels of A and B exhibit random scatter around 0. Thus, the model assumptions are valid.
There is nothing unusual about the residual plots.
Factorial Experiments: 2k Design
28
A = y A+ − y A−
B = yB + − yB −
C = yC + − yC −
etc, etc, ...
Analysis done
via computer
30
2k Design for k=3 factors
Contrast
Effect =
n2k −1
(Contrast) 2 2 k −2
SS = k
= n (Effect) 2
n2
• Except for column the identity I, every column has an equal number of + and – signs
• The sum of the product of signs in any two columns is zero
• Multiplying any column by column I leaves that column unchanged (identity element)
• The product of any two columns yields a column in the table: A B = AB
AB BC = AB 2C = AC
31
1
A = y A+ − y A− = [a + ab + ac + abc − b − c − bc − (1)]
4n
1
B = yB + − yB − = [b + ab + bc + abc − a − c − ac − (1)]
4n
1
C = yC + − yC − = [c + ac + bc + abc − a − b − ab − (1)]
4n
1
AB = [ab + (1) + abc + c − b − a − bc − ac]
4n
1
AC = [ac + (1) + abc + b − a − c − ab − bc]
4n
1
BC = [bc + (1) + abc + a − b − c − ab − ac]
4n
1
ABC = [abc − bc − ac + c − ab + b + a − (1)]
4n
32
Contrast A
A=
n 2k −1
1
= a + ab + ac + abc − b − c − bc − (1)
(2)(23−1 )
1
= 22 + 27 + 23 + 30 − 20 − 21 − 18 − 16
(2)(4)
1
= 27 = 3.375
8
33
The main effect may be estimated using the corresponding equations. The effect
of A, for example is 1
A = a + ab + ac + abc − b − c − bc − (1)
4n
1
= 22 + 27 + 23 + 30 − 20 − 21 − 18 − 16
4(2)
1
= 27 = 3.375
8
ANOVA Table
From examining the magnitude of the effects, feed rate (A) is clearly dominant, followed by
depth of cut (B) and the AB interaction, although the interaction effect is relatively. Based
on the P-values in the Table below, it is clear that the feed rate (A) is highly significant.
A B AB
y
abc
bc
b
ab
ac
c
(1) a