際際滷

際際滷Share a Scribd company logo
SAS tutorial 0524
proc anova;
class A B S;
model y=S|A|B;
test h=A e= S*A;
run;

The same as glm ┻頁曳^]喘...
Example
title 'Unbalanced Two-Way   2 1 28 . 23 34 42 13
Analysis of Variance';      2 2 . 34 33 31 . 36
data a;                     2 3 3 26 28 32 4 16
  input drug disease @;     3 1 . . 1 29 . 19
   do i=1 to 6;             3 2 . 11 9 7 1 -6
     input y @;             3 3 21 1 . 9 3 .
     output;                4 1 24 . 9 22 -2 15
   end;                     4 2 27 12 12 -5 16 15
   datalines;               4 3 22 7 25 5 12 .
   1 1 42 44 36 13 19 22    ;
   1 2 33 . 26 . 33 21
   1 3 31 -3 . 25 25 24
4x3 2-way
code
ods graphics on;
 proc glm;
   class drug disease;
   model y=drug disease drug*disease /ss3;
      contrast 'drug 1 vs 2' drug 1 -1 0 0;
      contrast 'drug 1 vs 3' drug 1 0 -1 0;
      contrast 'drug 1 vs 4' drug 1 0 0 -1;
   lsmeans drug/ pdiff=all adjust=tukey;
 run;
ods graphics off;
Result
Interaction plot
Sas tutorial 0524
Sas tutorial 0524
Dummy variable
? Category variable
? Set reference group
? Set N-1 d.variables:
  C 1 if xij belongs to the group specified
  C 0 if xij belongs to other groups

? E.g. variable drug in the example:
   C   0 0 0 => drug=1
   C   1 0 0 => drug=2
   C   0 1 0 => drug=3
   C   0 0 1 => drug=4
Data
Result (is the same)
Why use d.v. coding?




     http://www.sas.com/offices/NA/canada/downloads/presen
     tations/VancouverMay11/Variable.pdf
Sas tutorial 0524
If you cannot run contrast
          analysisぉ
? Check coefficients
? Separate main effects and interactions into
  different models.
? e.g. 2-way ANOVA with interaction:
  C model y = A B;
    (contrasts for main effects)
  C model y = A*B;
    (contrasts for interaction)

More Related Content

Sas tutorial 0524

  • 2. proc anova; class A B S; model y=S|A|B; test h=A e= S*A; run; The same as glm ┻頁曳^]喘...
  • 3. Example title 'Unbalanced Two-Way 2 1 28 . 23 34 42 13 Analysis of Variance'; 2 2 . 34 33 31 . 36 data a; 2 3 3 26 28 32 4 16 input drug disease @; 3 1 . . 1 29 . 19 do i=1 to 6; 3 2 . 11 9 7 1 -6 input y @; 3 3 21 1 . 9 3 . output; 4 1 24 . 9 22 -2 15 end; 4 2 27 12 12 -5 16 15 datalines; 4 3 22 7 25 5 12 . 1 1 42 44 36 13 19 22 ; 1 2 33 . 26 . 33 21 1 3 31 -3 . 25 25 24
  • 5. code ods graphics on; proc glm; class drug disease; model y=drug disease drug*disease /ss3; contrast 'drug 1 vs 2' drug 1 -1 0 0; contrast 'drug 1 vs 3' drug 1 0 -1 0; contrast 'drug 1 vs 4' drug 1 0 0 -1; lsmeans drug/ pdiff=all adjust=tukey; run; ods graphics off;
  • 10. Dummy variable ? Category variable ? Set reference group ? Set N-1 d.variables: C 1 if xij belongs to the group specified C 0 if xij belongs to other groups ? E.g. variable drug in the example: C 0 0 0 => drug=1 C 1 0 0 => drug=2 C 0 1 0 => drug=3 C 0 0 1 => drug=4
  • 11. Data
  • 12. Result (is the same)
  • 13. Why use d.v. coding? http://www.sas.com/offices/NA/canada/downloads/presen tations/VancouverMay11/Variable.pdf
  • 15. If you cannot run contrast analysisぉ ? Check coefficients ? Separate main effects and interactions into different models. ? e.g. 2-way ANOVA with interaction: C model y = A B; (contrasts for main effects) C model y = A*B; (contrasts for interaction)