lec9

Post on 20-Nov-2015

216 Views

Category:

Documents

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

Two way Analysis of Variance

TRANSCRIPT

  • STAT3010: Lecture 9

    1

    TWO-WAY ANALYSIS OF VARIANCE Recall: Last class we set up the complete Two-Way ANOVA table for the Poplar Tree example: ANOVA TABLE: Source of Sum of Mean Variation df Squares Square F Treatments 3 7.547 2.51566 7.5049 Site 1 0.27225 0.27225 0.812201 Interaction 3 0.17163 0.05721 0.17067 Error 32 10.72668 0.3352 Total 39 18.7176 Step 1: Interaction Effect hypothesis Test Statistic: Decision: Conclusion:

  • STAT3010: Lecture 9

    2

    Step 2: Row/Column Effects (main effects): Test Statistic: Decision: Conclusion:

  • STAT3010: Lecture 9

    3

    Code for a two-way ANOVA in SAS: SAS CODE: options ps=62 ls=80; proc format; value trt 1='None' 2='Fertilizer' 3='Irrigation' 4='Fertilizer and Irrigation' ; value site 1='rich and moist' 2='sandy and dry'; TITLE '2-WAY, EQUAL NS, INDEPENDENT SAMPLES ANOVA'; data poplar; INPUT TREATMENT SITE; DO I=1 TO 5; INPUT WEIGHT @@; OUTPUT; END; format treatment trt. site site.; cards; 1 1 0.15 0.02 0.16 0.37 0.22 1 2 0.60 1.11 0.07 0.07 0.44 2 1 1.34 0.14 0.02 0.08 0.08 2 2 1.16 0.93 0.30 0.59 0.17 3 1 0.23 0.04 0.34 0.16 0.05 3 2 0.65 0.08 0.62 0.01 0.03 4 1 2.03 0.27 0.92 1.07 2.38 4 2 0.22 2.13 2.33 1.74 0.12 run; proc means NWAY noprint; class site treatment; var weight; output out=poplar2 mean= ; proc plot; plot weight*treatment=site; PROC GLM data=poplar; CLASS SITE TREATMENT; MODEL WEIGHT=SITE|TREATMENT / SS1; run;

  • STAT3010: Lecture 9

    4

    SAS OUTPUT: 2-WAY, EQUAL NS, INDEPENDENT SAMPLES ANOVA Plot of WEIGHT*TREATMENT. Symbol is value of SITE. WEIGHT 1.4 r s 1.2 1.0 0.8 s 0.6 s 0.4 r s 0.2 r r 0.0 0 5 TREATMENT

  • STAT3010: Lecture 9

    5

    2-WAY, EQUAL NS, INDEPENDENT SAMPLES ANOVA The GLM Procedure Class Level Information Class Levels Values SITE 2 rich and moist sandy and dry TREATMENT 4 Fertilizer Fertilizer and Irrigation Irrigation None Number of Observations Read 40 Number of Observations Used 40 2-WAY, EQUAL NS, INDEPENDENT SAMPLES ANOVA The GLM Procedure Dependent Variable: WEIGHT Sum of Source DF Squares Mean Square F Value Pr > F Model 7 7.99088000 1.14155429 3.41 0.0078 Error 32 10.72668000 0.33520875 Corrected Total 39 18.71756000 R-Square Coeff Var Root MSE WEIGHT Mean 0.426919 98.80071 0.578972 0.586000 Source DF Type I SS Mean Square F Value Pr > F SITE 1 0.27225000 0.27225000 0.81 0.3742 TREATMENT 3 7.54700000 2.51566667 7.50 0.0006 SITE*TREATMENT 3 0.17163000 0.05721000 0.17 0.9154

  • STAT3010: Lecture 9

    6

    Example: Suppose a teacher wants to discover whether Ritalin, Child Therapy, or both can change a group of hyperactive boys out-of-seat behavior in his class. He proceeds with appropriate consent from both parents and physicians to randomly assign these children to six different groups. There are three different levels of Ritalin dosage, and two different types of Child Therapy. The collected data is shown below. The Data indicates the number of out-of-seat behaviors recorded for each child over the week evaluation period. The letter "B" indicates a behavioral therapy while the letter "C" indicates the child was exposed to a cognitive therapy. Conduct a test to determine whether the number of out-of-seat behaviors is affected by Ritalin and Child Therapy. Number of out-of-seat behaviors per week

    Ritalin Dosage Low Medium High 54 51 53 B 56 56 55 (Behavioral) 53 53 56 57 55 52 Child 55 55 54 Therapy 52 54 58 C 50 57 57 (Cognitive) 53 58 55

    51 56 61 54 53 59

  • STAT3010: Lecture 9

    7

    The first thing we should obtain is the means and create a rough plot to see if there is an interaction: Means Low Medium High B (Behavioral) Child Therapy C (Cognitive) What do you notice? Lets plot them:

  • STAT3010: Lecture 9

    8

    SAS CODE: options ps=62 ls=80; proc format; value dose 1='Low Dose' 2='Medium Dose' 3='High Dose' ; value therapy 1='behavioral' 2='cognitive'; TITLE '2-WAY, EQUAL NS, INDEPENDENT SAMPLES ANOVA'; data retalin; INPUT THERAPY DOSE; DO I=1 TO 5; INPUT DATA @@; OUTPUT; END; format dose dose. therapy therapy.; cards; 1 1 54 56 53 57 55 1 2 51 56 53 55 55 1 3 53 55 56 52 54 2 1 52 50 53 51 54 2 2 54 57 58 56 53 2 3 58 57 55 61 59 run; proc means NWAY noprint; class therapy dose; var data; output out=retalin2 mean= ; proc plot; plot data*dose=therapy; PROC GLM data=retalin; CLASS THERAPY DOSE; MODEL DATA=THERAPY|DOSE / SS1; run;

  • STAT3010: Lecture 9

    9

    SAS OUTPUT: 2-WAY, EQUAL NS, INDEPENDENT SAMPLES ANOVA Plot of DATA*DOSE. Symbol is value of THERAPY. DATA 58 c 57 56 c 55 b 54 b b 53 52 c Low Dose Medium Dose High Dose DOSE

  • STAT3010: Lecture 9

    10

    2-WAY, EQUAL NS, INDEPENDENT SAMPLES ANOVA The GLM Procedure Class Level Information Class Levels Values THERAPY 2 behavioral cognitive DOSE 3 High Dose Low Dose Medium Dose Number of Observations Read 30 Number of Observations Used 30 2-WAY, EQUAL NS, INDEPENDENT SAMPLES ANOVA The GLM Procedure Dependent Variable: DATA Sum of Source DF Squares Mean Square F Value Pr > F Model 5 100.1666667 20.0333333 5.78 0.0012 Error ** ********** ********* Corrected Total 29 ********** R-Square Coeff Var Root MSE DATA Mean 0.546264 3.399693 1.861899 54.76667 Source DF Type I SS Mean Square F Value Pr > F THERAPY 1 5.63333333 5.63333333 1.62 0.2146 DOSE 2 31.26666667 15.63333333 4.51 0.0217 THERAPY*DOSE ** ********** ********** **** ******

    Step 1: Interaction Effect hypothesis:

    Test Statistic:

    450409,90165: 22

    i jij

    i j kijk XXnote

  • STAT3010: Lecture 9

    11

    Decision: Conclusion: Next class well look at unequal sample sized two-way ANOVA.

top related