Math 558 Lecture #24-25
Continued from last lecture
etch<- c(t(etch.rate))
Copyright By PowCoder代写 加微信 powcoder
Af <- rep(as.factor(A),rep(2,8))
Bf <- rep(as.factor(B),rep(2,8))
Cf <- rep(as.factor(C),rep(2,8)) options(contrasts=c("contr.sum","contr.poly"))
model.etch <- lm(etch Af*Bf*Cf)
summary(model.etch)
Note: function as.factor is a wrapper for the function factor.
Example Continued
lm(formula = etch Af * Bf * Cf) Residuals:
Min 1Q Median 3Q Max
-65.50 -11.12 0.00 11.12 65.50
Estimate (Intercept) 776.062 Af1 -50.812
Cf1 153.062 Af1:Bf1 -12.438 Af1:Cf1 -76.812 Bf1:Cf1 -1.062
Af1:Bf1:Cf1 2.813
Std. Error 11.865 11.865 11.865 11.865 11.865 11.865 11.865 11.865
t value 65.406 -4.282 0.311 12.900 -1.048 -6.474 -0.090 0.237
Pr(>|t|) 3.32e-12 *** 0.002679 ** 0.763911 1.23e-06 *** 0.325168 0.000193 *** 0.930849 0.818586
Residual standard error: 47.46 on 8 degrees of freedom Multiple R-squared: 0.9661, Adjusted R-squared: 0.9364 F-statistic: 32.56 on 7 and 8 DF, p-value: 2.896e-05
Cf Af:Bf Af:Cf Bf:Cf Af:Bf:Cf Residuals
Df Sum Sq 1 41311 1 218
1 374850 1 2475 1 94403 1 18
1 127 8 18020
Mean Sq 41311 218 374850 2475 94403 18 127 2253
F value 18.3394 0.0966 166.4105 1.0988 41.9090 0.0080 0.0562
Pr(>F) 0.0026786 ** 0.7639107 1.233e-06 *** 0.3251679 0.0001934 *** 0.9308486 0.8185861
Same question: Why are the parameter estimates one half of the “effect estimates”?
Improve the model by removing the factors which are not significant
Model parameter estimates after removing the factor B
Estimate (Intercept) 776.06 Af1 -50.81 Cf1 153.06 Af1:Cf1 -76.81
Std. Error t value 10.42 74.458 10.42 – 4.875 10.42 14.685 10.42 -7.370
< 2e-16 *** 0.000382 *** 4.95e-09 *** 8.62e-06 ***
Residual standard error: 41.69 on 12 degrees of freedom Multiple R-squared: 0.9608, Adjusted R-squared: 0.9509 F-statistic: 97.91 on 3 and 12 DF, p-value: 1.054e-08
Anova for the reduced model
1 Cf 1 Af:Cf 1
Residuals 12
Sum Sq 41311 374850 94403 20858
Mean Sq 41311 374850 94403 1738
F value 23.767 215.661 54.312
Pr(>F) 0.0003816 *** 4.951e-09 *** 8.621e-06 **
Full Model and the hypotheses
The full regression model is
Y = β0 +β1X1 +β2X2 +β12X12 +β3X3 +β13X13+
β23X23 + β123X123 + ε
H0 : Allβ′s = 0 Ha : at least oneβ ̸= 0
T test this hypoyhesis we compute
SSModel = SSA +SSB +SSAB +SSC +SSAC +SSBC +SSABC
MSModel = SSModel 7
F0 = 32.56
As F0 is large we reject the null hypothesis and conclude that at least one of the variables has a non zero effect.
R2 and Adjusted R2
The total variability in the response explained by the model is
R2 = SSModel/SST. From the R-out put of values or computing directly we have R2 = 0.9661. However, R2 always increases when new variables are added in the model even if they are not significant. The better statistic is R2 adjusted as it takes into account the number of variables (degrees of freedom).
R2(Adjusted) = 1 − SSE/dfError = 0.9364 SST /dfT
This value is decreased if non significant terms are added in the Model.
Reduced Model Hypotheses
The reduced model is
Y = β0 +β1X1 +β3X3 +β13X13 ++ε
The reduced model only contains the main effects A and C and their interaction. The error component now includes the sum of the squares for the dropped terms. The value of R2 now is 0.9608 < R2Full. However R2adjusted = 0.9509 > R2adjusted ( full model)
Confidence Intervals
The 95% confidence interval for each regression coefficient can be computed as
βˆ ± t0.025,N−pse(βˆ) The 95% confidence interval for the effects is
ˆˆ effect ± t0.025,N−pse(effect)
Standard Error of an Effect 23 factorial experiment: ongoing example
We have n = 2 for each 23 runs. Let yi1 and yi2 are the observations at ith run. Then the estimate of the variance at the ith run is
12 S=n−1 (y−y ̄)
i2 ∑iji2 j=1
The overall variance estimate is
S =23(n−1) (y −y ̄) 2 ∑∑ij i2
This estimate is given by error mean square in the anova table.
Standard Error of an Effect 23 factorial experiment: ongoing example
The variance of each effect estimate is given by
(Contrast) V(effect) =V n.4
(Contrast) =V 2×4
= 1 V(Contrast) (2×4)2
= 1 2×23σ2 (2×4)2
Each contrast is a linear combination of 2k treatment totals, and each total consists of n observations.
Standard Error of an Effect 23 factorial experiment: ongoing example
The estimated standard error can be found by replacing σ2 by its
estimate S2.
We can show that
se(eˆffect) = √ = √ 4
se(effect) = √
= √ n.2k−2 n.2k
2S se(effect)=n2k =
2 × 2252.56 2×23
estimated regression coefficient in the regression model for the 2k design 13/21
Note that the standard error of an effect is twice the standard error of an
General 2k design
Now let us consider 2k design which is a factorial design with k factors at two levels each. There will be k main effects, (2k) 2 factor interactions, (3k) 3 factor interactions…….. one k factor interaction.
Standard order of writing 2k treatment combinations for k = 4 is
a, b, ab, c, ac, bc, abc, d, ad, bd, abd, cd, acd, bcd, abcd
Anova for 2k design
Sources of Sum of variation Squares
A SSA B SSB K SSK
1 2k(n − 1) n2k − 1
. ABC..K Error Total
SSABC..k SSE SST
Contrasts for 2k design
ContrastAB….K =(a±1)(b±1)…..(k±1)
If the factor is included in the effect, the sign in the parenthesis is
negative, otherwise, its positive. For example, for a 23 design
ContrastA =(a−1)(b+1)(c+1) ContrastAB =(a−1)(b−1)(c+1) ContrastABC =(a−1)(b−1)(c−1)
Main effects and sum of squares
AB….K = 2 (ContrastAB…K ) n2k
SSAB….K = 1 (ContrastAB…K )2 n2k
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com