16
MATH 4220 Dr. Zeng Student Activity 8: Factorial Designs and the 2 k Factorial Design This activity includes the following three parts: using SAS in two-way and three-way analysis, using contrast in factorial designs, and using SAS graphs to plot two-way and three-way means. Using SAS in Two-Way Analysis In the balanced case, you may PROC GLM. First compute data with treatment A levels coded as 1,2,..., a in a variable (say, named A ) and levels of treatment B coded as 1,2,..., b in another variable (say, B ). The responses are entered in a 3 rd variable (say Y ). e.g. let a 2, b 3 . Note that the solution option in the MODEL statement gives estimators of , 1 , 2 , 1 , 2 3 , 11 ..., 23 proc glm; class A B; model Y=A B A*B/solution; run; Example 1: A Two-Way Analysis The SAS program given below analyzes data from a two-way experiment carried out in a completely randomized design. The experiment involves the two factors, Pressure and temperature. The pressure variable has three levels, 200, 215, and 230. The temperature variable has three levels, “low”, “medium” and “high”. Each of the nine treatment combinations were replicated twice. Note that the first GLM procedure fits an additive model and the second fits an interactive model. Also, the first GLM procedure does comparisons of main effect means. options ls=72 nodate; data chem; input press temp $ yield; datalines; 200 low 90.4 200 low 90.2 200 med 90.1 200 med 90.3 200 high 90.5 200 high 90.7 215 low 90.7 215 low 90.6 215 med 90.5 215 med 90.6 215 high 90.8 215 high 90.9

MATH 4220 Dr. Zengbzeng/4220/documents/activities/SA... · 2018. 1. 11. · MATH 4220 Dr. Zeng Using SAS in Three-Way Analysis Example 2: A 23 Factorial Design A 23 factorial design

  • Upload
    others

  • View
    9

  • Download
    1

Embed Size (px)

Citation preview

  • MATH 4220 Dr. Zeng

    Student Activity 8: Factorial Designs and the 2k Factorial Design

    This activity includes the following three parts: using SAS in two-way and three-way analysis, using contrast in factorial designs, and using SAS graphs to plot two-way and three-way means. Using SAS in Two-Way Analysis In the balanced case, you may PROC GLM. First compute data with treatment A levels coded as 1,2,...,a in a variable (say, namedA ) and levels of treatment B coded as

    1,2,...,b in another variable (say, B ). The responses are entered in a 3rd variable (say

    Y ). e.g. let a 2,b 3. Note that the solution option in the MODEL statement gives

    estimators of ,1,2,1,23, 11..., 23

    proc glm; class A B; model Y=A B A*B/solution; run;

    Example 1: A Two-Way Analysis The SAS program given below analyzes data from a two-way experiment carried out in a completely randomized design. The experiment involves the two factors, Pressure and temperature. The pressure variable has three levels, 200, 215, and 230. The temperature variable has three levels, “low”, “medium” and “high”. Each of the nine treatment combinations were replicated twice. Note that the first GLM procedure fits an additive model and the second fits an interactive model. Also, the first GLM procedure does comparisons of main effect means. options ls=72 nodate; data chem; input press temp $ yield; datalines; 200 low 90.4 200 low 90.2 200 med 90.1 200 med 90.3 200 high 90.5 200 high 90.7 215 low 90.7 215 low 90.6 215 med 90.5 215 med 90.6 215 high 90.8 215 high 90.9

  • MATH 4220 Dr. Zeng

    230 low 90.2 230 low 90.4 230 med 89.9 230 med 90.1 230 high 90.4 230 high 90.1 ; proc print; title1 'MATH 338: Experimental Design'; title2 'Examples of Two-way Models'; proc glm; class press temp; title3 'Additive Model'; model yield = press temp /solution; means press temp /lsd tukey; proc glm; class press temp; title3 'Interactive Model'; model yield = press temp press*temp / solution; run;

    proc sort; by press temp; proc means noprint; var yield; by press temp; output out=ymeanac mean=mn; symbol1 v=circle i=join; symbol2 v=square i=join; proc gplot data=ymeanac; plot mn*press=temp; run;

  • MATH 4220 Dr. Zeng

  • MATH 4220 Dr. Zeng

  • MATH 4220 Dr. Zeng

  • MATH 4220 Dr. Zeng

    Using SAS in Three-Way Analysis

    Example 2: A 23 Factorial Design

    A 23 factorial design was used to develop a nitride etch process on a single-wafer plasma etching tool. The design factors are the gap between the electrodes, the gas flow and the RF power applied to the cathode. Each factor is run at two levels, and the design is replicated twice. The response variable is the etch rate for silicon nitride.

    options ls=78; data threeway; input a b c etchrate; datalines; -1 -1 -1 550 -1 -1 -1 604 1 -1 1 749 1 -1 1 868 1 1 -1 642 1 1 -1 635 -1 1 1 1075 -1 1 1 1063 1 1 1 729 1 1 1 860 1 -1 -1 669 1 -1 -1 650 -1 1 -1 633 -1 1 -1 601 -1 -1 1 1037 -1 -1 1 1052 ; proc glm data=threeway; class a b c; model etchrate = a|b|c; /* Note: the entry a|b|c ensures that the main effects, the two-way interactions and the three-way interaction are all fitted into the model. Another way to fit this is to use: model etchrate = a b a*b c a*c b*c a*b*c; */ run;

  • MATH 4220 Dr. Zeng

  • MATH 4220 Dr. Zeng

    Using contrasts in two-way designs To write contrast statements in SAS, there are a few steps to follow. First of all, identify the order of factors and the way in which they are coded. In SAS, the factor ordering is specified in the class statement. Next, identify the contrast you are interested in. For example, imagine a 3-way factorial CRD experiment with factors named A, B, and C. Factor A has 2 levels (1,2), and factor B has 3 levels (1,2,3). A simple comparision that can be planned is the difference between the levels of A when B is 2. Then set up a table to hold the coefficients paying close attention to the order of factors and their levels. Factor A is the first here and goes in the row; factor B goes on the column because of their placement in our class statement. The coefficients for the levels of our comparison are entered in the corresponding cells on the left and top margins of the table. They are shown in red italics here. It is clear that the comparision being made is “A1 vs A2 in B2”.

    The table is filled by multiplying the coeffcients along the right and top and entering the value in the proper cell. The new values are shown in red here. These are the values for the A*B interaction. They will be read into the contrast statement by going across each row starting with the top one. So A*B would have 0 1 0 0 -1 0.

    Now add across the rows and down the columns to fill in the left and bottom rows of the table. These values will be used in the conrtrast statement for the main effects of A (on the right) and B (along the bottom). B has all zero coefficients that will not need to be written in the contrast statement. For A, we will have to write 1 -1 in that order.

  • MATH 4220 Dr. Zeng

    Fill in the one remaining cell, which identifies a coefficient for the intercept, by adding across the bottom row and down the right column. No intercept will be specified bevcause it is 0.

    For the SAS glm, one could write, contrast ‘A1 vs A2 in B2’ A 1 -1 A*B 0 1 0 0 -1 0; Example 3: Using contrasts in two-way models In this example, we will revisit example 1 and replace the temperature variables by 1, 2, and 3. Here, we want to compare the ‘230’ with ‘200’ and ‘215’. In addition, we are interested in comparing the ‘High temp’ with ‘median temp’ and ‘low temp’ with the constant setting of low pressure. options ls=78 nodate;

    data chem;

    input press temp yield ;

    datalines;

    200 1 90.4

    200 1 90.2

    200 2 90.1

    200 2 90.3

    200 3 90.5

    200 3 90.7

    215 1 90.7

    215 1 90.6

    215 2 90.5

    215 2 90.6

    215 3 90.8

    215 3 90.9

    230 1 90.2

    230 1 90.4

    230 2 89.9

    230 2 90.1

    230 3 90.4

    230 3 90.1

    ;

    proc print;

    title1 'STAT 338: Experimental Design';

    title2 'Examples of Two-way Models';

    proc glm;

    class press temp;

    title3 'Interactive Model';

    model yield = press temp press*temp;

    contrast '200 and 215 vs. 230' press 1 1 -2;

    contrast '200+high vs. 200+low and 200+med'

    temp -1 -1 2 press*temp -1 -1 2 0 0 0 0 0 0 ;

    run;

  • MATH 4220 Dr. Zeng

    Using contrasts in three-way designs

    The procedure of using contrasts in three-way analysis is similar to the two-way models. First of all, identify the order of factors and the way in which they are coded. In SAS, the factor ordering is specified in the class statement. Next, identify the contrast you are interested in.

    Example 4: Using contrasts in three-way models options ls=78;

    data threeway;

    input nozzle speed pressure y1 y2;

    loss=y1; output;

    /*loss=y2; output;*/

    datalines;

    1 100 10 -35 -25

    1 100 15 110 75

  • MATH 4220 Dr. Zeng

    1 100 20 4 5

    1 120 10 -45 -60

    1 120 15 -10 30

    1 120 20 -40 -30

    1 140 10 -40 15

    1 140 15 80 54

    1 140 20 31 36

    2 100 10 17 24

    2 100 15 55 120

    2 100 20 -23 -5

    2 120 10 -65 -58

    2 120 15 -55 -44

    2 120 20 -64 -62

    2 140 10 20 4

    2 140 15 110 44

    2 140 20 -20 -31

    3 100 10 -39 -35

    3 100 15 90 113

    3 100 20 -30 -55

    3 120 10 -55 -67

    3 120 15 -28 -26

    3 120 20 -61 -52

    3 140 10 15 -30

    3 140 15 110 135

    3 140 20 54 4

    ;

    proc glm data=threeway;

    class nozzle speed pressure;

    model loss = nozzle|speed|pressure;

    Contrast 'nozzle linear' nozzle -1 0 1;

    contrast 'speed linear' speed -1 0 1;

    contrast ' pressure linear' pressure -1 0 1;

    contrast 'nozzle quadratic' nozzle -1 2 -1;

    contrast 'speed quadratic' speed -1 2 -1;

    contrast 'pressure quadratic' pressure -1 2 -1;

    contrast ' nozzle linear * speed linear' nozzle*speed 1 0 -1 0 0 0 -1 0 1;

    contrast ' nozzle linear * speed quadratic' nozzle*speed 1 -2 1 0 0 0 -1 2 -

    1;

    contrast ' nozzle linear * pressure linear' nozzle*pressure 1 0 -1 0 0 0 -1

    0 1;

    contrast ' nozzle linear * pressure quadratic' nozzle*pressure 1 -2 1 0 0 0

    -1 2 -1;

    contrast ' speed linear * pressure linear' speed*pressure 1 0 -1 0 0 0 -1 0

    1;

    contrast ' speed linear * pressure quadratic' speed*pressure 1 -2 1 0 0 0 -1

    2 -1;

    contrast ' nozzle quadratic * speed quadratic' nozzle*speed 1 -2 1 -2 4 -2 1

    -2 1;

    contrast ' nozzle quadratic * pressure quadratic' nozzle*pressure 1 -2 1 -2

    4 -2 1 -2 1;

    contrast ' speed quadratic * pressure quadratic' speed*pressure 1 -2 1 -2 4

    -2 1 -2 1;

    run;

  • MATH 4220 Dr. Zeng

  • MATH 4220 Dr. Zeng

    Plots of a response surface with a simple optimum

    To plot the response surface with respect to two of the factor variables, fix the third

    factor, the least significant factor variable, as its estimated optimum value. The following

    example use ods graphics to display the surface:

    Example 5: referring to the data in example 4, plot the response surface with respect to

    speed and pressure when nozzle level is 1.

    options ls=78; data threeway; input nozzle speed pressure y1 y2; loss=y1; output; loss=y2; output; datalines; 1 100 10 -35 -25 1 100 15 110 75 1 100 20 4 5 1 120 10 -45 -60 1 120 15 -10 30 1 120 20 -40 -30 1 140 10 -40 15 1 140 15 80 54 1 140 20 31 36 2 100 10 17 24 2 100 15 55 120 2 100 20 -23 -5 2 120 10 -65 -58 2 120 15 -55 -44 2 120 20 -64 -62 2 140 10 20 4 2 140 15 110 44 2 140 20 -20 -31 3 100 10 -39 -35 3 100 15 90 113 3 100 20 -30 -55 3 120 10 -55 -67 3 120 15 -28 -26 3 120 20 -61 -52 3 140 10 15 -30 3 140 15 110 135 3 140 20 54 4 ; ods graphics on; proc rsreg data=threeway plots(only unpack)=surface(3d at(nozzle=1)); model y1 = nozzle speed pressure; ods select 'speed * pressure = Pred';

  • MATH 4220 Dr. Zeng

    run; ods graphics off;

  • MATH 4220 Dr. Zeng

    Assignment:

    1. An experiment is conducted to study the influence of operating temperature and three types of faceplate glass in the light output of an oscilloscope tube. The following data are collected:

    (1) Is there a significant interaction effect? Does glass type or temperature affect the response? What conclusions can you draw?

    (2) Fit an appropraite model relating light output to glass tyoe and temperature. (3) Plot the response surface. What conclusion can you draw from the plot? (4) Analyze the residual from this experiment. Comment on the adequacy of the models

    you have considered. (5) Compare the effect of glass type 3 versus type 1 and 2 simultaneously when the

    temperature setting is 150. (6) Carry out the hypothesis testing simultaneously to compare the effect of glass type 3

    versus type 1 and 2, the effect of temperature 150 with temperature 100 and 125. (7) Consider another model with factor A, B, B*B, A*B, and A*B*B. Does glass has an

    quadratic effect? What is your conclusion about this model?

  • MATH 4220 Dr. Zeng

    2. Bone anchors are used by orthopedic surgeons in repairing torn rotator cuffs (a common shoulder tendon injury among baseball players). The bone anchor is a threaded insert that is screwed into a hole that has been drilled into the shoulder bone near the site of the torn tendon. The torn tendon is then sutured to the anchor. In a successful operation, the tendon is stabilized and reattaches itself to the bone. However, bone anchors can pull out if they are subjected to high loads. An experiment was performed to study the force required to pull out the anchor for three anchor types and two different foam densities. Two replicates of the experiment were performed. The experimental design and the pullout forced response data are as follows.

    (1) Please complete the ANOVA table WITHOUT SAS. Is there any indication that either factor influences the response? Do the two factors interact?

    (2) Compare anchor type A with B and C for the low foam density. (3) Estimate the main effect and interaction effect. (4) Estimate the treatment effect.