SlideShare a Scribd company logo
1 of 14
SAS tutorial: GLM (2)
Repeated measures
• 如果每個參與者都作了某些作業/回答某
  些題目。
• 那麼這些題目/作業便稱為重複量數
  (repeated measures)。
 – 或受試者內(within subject)設計。


• 可以去除來自個體差異的variance。
Example:
   2-way repeated ANOVA
Source   SS df   MS   F
A                     A / (S*A)
B                     B / (S*B)
A*B                   A*B / (S*A*B)
S
S*A
            Error
S*B
S*A*B
GLM for repeated measures
data aaa;       datalines;
do S= 1 to 3;   5 10 20 10
do A=1 to 2;    6 11 22 13
do B=1 to 2;    4 12 24 9
input x @@;     ;
output;
end;
end;
end;
GLM for repeated measures:
           code
Between             Between
ods graphics on;    proc glm data=AAA;
proc glm data=AAA   class A B S;
plots=intplot;      model x=A|B|S;
class A B;          test h=A e=A*S;
model x=A|B;        test h=B e=B*S;
run;                test h=A*B e=A*B*S;
ods graphics off;   run;
Result (between) :
 Interaction plot
Result (between)
Result (within)



          DF 被model用完了,
          沒有error可以除?
Result




Between
Mix models
• 有些變項是受試者內設計,有些變項是受
  試者間設計。
Example
• 16 dogs
• Dependent variable:
  – log-histamine concentration
• Independent variables:
  – Drug: morphine or trimethaphan (between)
  – Depleted: Y or N (between)
  – Time: measured after 0, 1, 3, or 5 min (within)
Code
data dogs;                                           Morphine    Y .07 .07 .06 .07
   input Drug $ Depleted $ Histamine0 Histamine1     Morphine    Y .05 .07 .06 .07
       Histamine3 Histamine5;                        Trimethaphan N .03 .62 .31 .22
   LogHistamine0=log(Histamine0);                    Trimethaphan N .03 1.05 .73 .60
   LogHistamine1=log(Histamine1);                    Trimethaphan N .07 .83 1.07 .80
   LogHistamine3=log(Histamine3);                    Trimethaphan N .09 3.13 2.06 1.23
   LogHistamine5=log(Histamine5);                    Trimethaphan Y .10 .09 .09 .08
   datalines;                                        Trimethaphan Y .08 .09 .09 .10
 Morphine     N .04 .20 .10 .08                      Trimethaphan Y .13 .10 .12 .12
 Morphine     N .02 .06 .02 .02                      Trimethaphan Y .06 .05 .05 .05
 Morphine     N .07 1.40 .48 .24                     ;
 Morphine     N .17 .57 .35 .24
 Morphine     Y .10 .09 .13 .14
 Morphine     Y .12 .11 .10 .           Missing    data 不用
proc glm;                          先寫betwwen,再寫within
    class Drug Depleted;
    model LogHistamine0--LogHistamine5 =
        Drug Depleted Drug*Depleted / nouni;
    repeated Time 4 (0 1 3 5) polynomial / summary printe;
  run;
Result
Result




         檢驗Y在獨變項不同水準下
         的差異值變異數是否相同。

More Related Content

Viewers also liked

Preso smc030 guerilla small
Preso smc030 guerilla smallPreso smc030 guerilla small
Preso smc030 guerilla smallMartijn Arets
 
Op zoek naar het erg kleine: zien van atomen
Op zoek naar het erg kleine: zien van atomenOp zoek naar het erg kleine: zien van atomen
Op zoek naar het erg kleine: zien van atomenUnescoCentrum
 
Presentatie olivier marktplaats media event 2010
Presentatie olivier marktplaats media event 2010Presentatie olivier marktplaats media event 2010
Presentatie olivier marktplaats media event 2010Marketingfacts
 
Prijsvraagontwerp cultureel centrum pius x volendam april 2000
Prijsvraagontwerp cultureel centrum pius x volendam   april 2000Prijsvraagontwerp cultureel centrum pius x volendam   april 2000
Prijsvraagontwerp cultureel centrum pius x volendam april 2000edwin I van der waal
 
Results for questionnaire
Results for questionnaireResults for questionnaire
Results for questionnairejacquesASmedia
 
Supercharging Your Social Capital by Dr. Derek Ambrose, Australian Reinsuranc...
Supercharging Your Social Capital by Dr. Derek Ambrose, Australian Reinsuranc...Supercharging Your Social Capital by Dr. Derek Ambrose, Australian Reinsuranc...
Supercharging Your Social Capital by Dr. Derek Ambrose, Australian Reinsuranc...Finance Network marcus evans
 
Open vlacc UGent20110929
Open vlacc UGent20110929Open vlacc UGent20110929
Open vlacc UGent20110929Rosa Matthys
 
Smart Architect 7steps to Transform
Smart Architect 7steps to TransformSmart Architect 7steps to Transform
Smart Architect 7steps to TransformUBM_Design_Central
 
Manoj Gangwar Brief Insight
Manoj Gangwar Brief InsightManoj Gangwar Brief Insight
Manoj Gangwar Brief Insightmanojkgangwar
 
Developing Product & Services
Developing Product & ServicesDeveloping Product & Services
Developing Product & ServicesJoe Kinsella
 

Viewers also liked (14)

Preso smc030 guerilla small
Preso smc030 guerilla smallPreso smc030 guerilla small
Preso smc030 guerilla small
 
Op zoek naar het erg kleine: zien van atomen
Op zoek naar het erg kleine: zien van atomenOp zoek naar het erg kleine: zien van atomen
Op zoek naar het erg kleine: zien van atomen
 
Presentatie olivier marktplaats media event 2010
Presentatie olivier marktplaats media event 2010Presentatie olivier marktplaats media event 2010
Presentatie olivier marktplaats media event 2010
 
Prijsvraagontwerp cultureel centrum pius x volendam april 2000
Prijsvraagontwerp cultureel centrum pius x volendam   april 2000Prijsvraagontwerp cultureel centrum pius x volendam   april 2000
Prijsvraagontwerp cultureel centrum pius x volendam april 2000
 
C2B2
C2B2C2B2
C2B2
 
CS I.4 - H.G. van Liempd
CS I.4 - H.G. van LiempdCS I.4 - H.G. van Liempd
CS I.4 - H.G. van Liempd
 
Results for questionnaire
Results for questionnaireResults for questionnaire
Results for questionnaire
 
Supercharging Your Social Capital by Dr. Derek Ambrose, Australian Reinsuranc...
Supercharging Your Social Capital by Dr. Derek Ambrose, Australian Reinsuranc...Supercharging Your Social Capital by Dr. Derek Ambrose, Australian Reinsuranc...
Supercharging Your Social Capital by Dr. Derek Ambrose, Australian Reinsuranc...
 
Open vlacc UGent20110929
Open vlacc UGent20110929Open vlacc UGent20110929
Open vlacc UGent20110929
 
Smart Architect 7steps to Transform
Smart Architect 7steps to TransformSmart Architect 7steps to Transform
Smart Architect 7steps to Transform
 
Guia de o..
Guia de o..Guia de o..
Guia de o..
 
Practica 10 (1)
Practica 10 (1)Practica 10 (1)
Practica 10 (1)
 
Manoj Gangwar Brief Insight
Manoj Gangwar Brief InsightManoj Gangwar Brief Insight
Manoj Gangwar Brief Insight
 
Developing Product & Services
Developing Product & ServicesDeveloping Product & Services
Developing Product & Services
 

More from WenSheng Chang (15)

futureNo52
futureNo52futureNo52
futureNo52
 
Sas plot
Sas plotSas plot
Sas plot
 
Sas reg multi
Sas reg multiSas reg multi
Sas reg multi
 
Sas reg simple
Sas reg simpleSas reg simple
Sas reg simple
 
Sas corr
Sas corrSas corr
Sas corr
 
1129 sas實習課
1129 sas實習課1129 sas實習課
1129 sas實習課
 
Sas tutorial 1018
Sas tutorial 1018Sas tutorial 1018
Sas tutorial 1018
 
Sas tutorial 0524
Sas tutorial 0524Sas tutorial 0524
Sas tutorial 0524
 
Sas tutorial glm1
Sas tutorial glm1Sas tutorial glm1
Sas tutorial glm1
 
Regression ci
Regression ciRegression ci
Regression ci
 
SAS 0412
SAS 0412SAS 0412
SAS 0412
 
Sas tutorial 0308
Sas tutorial 0308Sas tutorial 0308
Sas tutorial 0308
 
Sas tutorial 0308
Sas tutorial 0308Sas tutorial 0308
Sas tutorial 0308
 
0925 sas實習課
0925 sas實習課0925 sas實習課
0925 sas實習課
 
Science p79 -- polished
Science p79 -- polishedScience p79 -- polished
Science p79 -- polished
 

Sas tutorial glm2

  • 2. Repeated measures • 如果每個參與者都作了某些作業/回答某 些題目。 • 那麼這些題目/作業便稱為重複量數 (repeated measures)。 – 或受試者內(within subject)設計。 • 可以去除來自個體差異的variance。
  • 3. Example: 2-way repeated ANOVA Source SS df MS F A A / (S*A) B B / (S*B) A*B A*B / (S*A*B) S S*A Error S*B S*A*B
  • 4. GLM for repeated measures data aaa; datalines; do S= 1 to 3; 5 10 20 10 do A=1 to 2; 6 11 22 13 do B=1 to 2; 4 12 24 9 input x @@; ; output; end; end; end;
  • 5. GLM for repeated measures: code Between Between ods graphics on; proc glm data=AAA; proc glm data=AAA class A B S; plots=intplot; model x=A|B|S; class A B; test h=A e=A*S; model x=A|B; test h=B e=B*S; run; test h=A*B e=A*B*S; ods graphics off; run;
  • 6. Result (between) : Interaction plot
  • 8. Result (within) DF 被model用完了, 沒有error可以除?
  • 11. Example • 16 dogs • Dependent variable: – log-histamine concentration • Independent variables: – Drug: morphine or trimethaphan (between) – Depleted: Y or N (between) – Time: measured after 0, 1, 3, or 5 min (within)
  • 12. Code data dogs; Morphine Y .07 .07 .06 .07 input Drug $ Depleted $ Histamine0 Histamine1 Morphine Y .05 .07 .06 .07 Histamine3 Histamine5; Trimethaphan N .03 .62 .31 .22 LogHistamine0=log(Histamine0); Trimethaphan N .03 1.05 .73 .60 LogHistamine1=log(Histamine1); Trimethaphan N .07 .83 1.07 .80 LogHistamine3=log(Histamine3); Trimethaphan N .09 3.13 2.06 1.23 LogHistamine5=log(Histamine5); Trimethaphan Y .10 .09 .09 .08 datalines; Trimethaphan Y .08 .09 .09 .10 Morphine N .04 .20 .10 .08 Trimethaphan Y .13 .10 .12 .12 Morphine N .02 .06 .02 .02 Trimethaphan Y .06 .05 .05 .05 Morphine N .07 1.40 .48 .24 ; Morphine N .17 .57 .35 .24 Morphine Y .10 .09 .13 .14 Morphine Y .12 .11 .10 . Missing data 不用 proc glm; 先寫betwwen,再寫within class Drug Depleted; model LogHistamine0--LogHistamine5 = Drug Depleted Drug*Depleted / nouni; repeated Time 4 (0 1 3 5) polynomial / summary printe; run;
  • 14. Result 檢驗Y在獨變項不同水準下 的差異值變異數是否相同。