Chapter 13: Factorial Experimentation

Example, Page-394

In [1]:
# Variable declaration
A1 = [3.5,3.0,2.7]
A2 = [2.2,2.3,2.4]
B1 = [7.1,6.9,7.5]
B2 = [5.2,4.6,6.8]
C1 = [10.8,10.6,11.0]
C2 = [7.6,7.1,7.3]
a = 3
b = 2
r = 3
alpha = 0.01

# Calculation
from scipy import *
from pylab import *

FR_thr = 7.56   # for replications
FA_thr = 7.56   # for A
FB_thr = 10.04  # for B
FI_thr = 7.56   # Interaction effect

A_sum = sum(A1)+sum(A2)
B_sum = sum(B1)+sum(B2)
C_sum = sum(C1)+sum(C2)

T1 = sum(A1)+sum(B1)+sum(C1)
T2 = sum(A2)+sum(B2)+sum(C2)

T = A_sum+B_sum+C_sum

c = (T**2)/18
SST = 0

for i in range(0,3):
    SST = SST + A1[i]**2 + A2[i]**2 + B1[i]**2 + B2[i]**2 + C1[i]**2 + C2[i]**2

SST = SST - c

SSTR = (sum(A1)**2 + sum(A2)**2 + sum(B1)**2 + sum(B2)**2 + sum(C1)**2 + sum(C2)**2)/3 - c
SSR = 0.86
SSE = SST - SSTR - SSR

SSA = (1.0/6)*(A_sum**2 + B_sum**2 + C_sum**2) - c
SSB = (1.0/9)*(T1**2 + T2**2) - c

SSAB = SSTR - SSA - SSB

fr_prt = 1.72
fa_prt = 246
fb_prt = 68.8
fi_prt = 11.4

# Result
print "SST:",round(SST,2)," SSTR:",round(SSTR,2)," SSE:",round(SSE,2)," SSAB:",round(SSAB,2)

print "For replications: f =",fr_prt
print "fr_prt does not exceed 7.56, so we can not reject null hypothesis"
print "For main effect of factor A: f =",fa_prt
print "fb_prt exceeds 7.56, so we reject null hypothesis"
print "For main effect of factor B: f =",fb_prt
print "fb_prt exceeds 10.04, so we reject null hypothesis"
print "For interaction: f =",fi_prt
print "fi_prt exceeds 7.56, so we reject null hypothesis"
SST: 149.38  SSTR: 146.05  SSE: 2.47  SSAB: 5.7
For replications: f = 1.72
fr_prt does not exceed 7.56, so we can not reject null hypothesis
For main effect of factor A: f = 246
fb_prt exceeds 7.56, so we reject null hypothesis
For main effect of factor B: f = 68.8
fb_prt exceeds 10.04, so we reject null hypothesis
For interaction: f = 11.4
fi_prt exceeds 7.56, so we reject null hypothesis

Example, page-398

In [2]:
# Variable declaration
s_square = 0.25     # mean square error
v = 10      # degree of freedom
t_thr = 2.228       # theoritical value of t at 0.025
b = 2
r = 3

# Calculation
from scipy import *
from pylab import *

l = array([[3.07, 2.30],[7.17, 5.53],[10.80, 7.33]])
a = l[:,0]
b = l[:,1]

l1 = [a[0],b[0]]
l2 = [a[1],b[1]]
l3 = [a[2],b[2]]

# Result
# first confidence interval
y1 = mean(l1)-mean(l2) - 2.228*( sqrt(0.25 * (2.0/6)) )
y2 = mean(l1)-mean(l2) + 2.228*( sqrt(0.25 * (2.0/6)) )
print "first confidence interval: (",round(y1,2),",",round(y2,2),")"

# second confidence interval
y1 = mean(l1)-mean(l3) - 2.228*( sqrt(0.25 * (2.0/6)) )
y2 = mean(l1)-mean(l3) + 2.228*( sqrt(0.25 * (2.0/6)) )
print "second confidence interval: (",round(y1,2),",",round(y2,2),")"

# third confidence interval
y1 = mean(l2)-mean(l3) - 2.228*( sqrt(0.25 * (2.0/6)) )
y2 = mean(l2)-mean(l3) + 2.228*( sqrt(0.25 * (2.0/6)) )
print "third confidence interval: (",round(y1,2),",",round(y2,2),")"

# confidence interval for single difference in mean
y1 = mean(a)-mean(b) - 2.228*( sqrt(0.25 * (2.0/9)) )
y2 = mean(a)-mean(b) + 2.228*( sqrt(0.25 * (2.0/9)) )
print "interval for single difference in mean(in hours): (",round(y1,2),",",round(y2,2),")"
first confidence interval: ( -4.31 , -3.02 )
second confidence interval: ( -7.02 , -5.74 )
third confidence interval: ( -3.36 , -2.07 )
interval for single difference in mean(in hours): ( 1.43 , 2.49 )