Sas tutorial glm2

14
SAS tutorial: GLM (2)

description

repeated measure

Transcript of Sas tutorial glm2

Page 1: Sas tutorial glm2

SAS tutorial: GLM (2)

Page 2: Sas tutorial glm2

Repeated measures

• 如果每個參與者都作了某些作業/回答某些題目。

• 那麼這些題目/作業便稱為重複量數( repeated measures)。–或受試者內( within subject)設計。

• 可以去除來自個體差異的 variance。

Page 3: Sas tutorial glm2

Example: 2-way repeated ANOVA

Source SS df MS FA A / (S*A)

B B / (S*B)

A*B A*B / (S*A*B)

S

S*A

S*B

S*A*B

Error

Page 4: Sas tutorial glm2

data aaa;

do S= 1 to 3;

do A=1 to 2;

do B=1 to 2;

input x @@;

output;

end;

end;

end;

datalines;

5 10 20 10

6 11 22 13

4 12 24 9

;

GLM for repeated measures

Page 5: Sas tutorial glm2

GLM for repeated measures: code

Between

ods graphics on;

proc glm data=AAA plots=intplot;

class A B;

model x=A|B;

run;

ods graphics off;

Between

proc glm data=AAA;

class A B S;

model x=A|B|S;

test h=A e=A*S;

test h=B e=B*S;

test h=A*B e=A*B*S;

run;

Page 6: Sas tutorial glm2

Result (between) : Interaction plot

Page 7: Sas tutorial glm2

Result (between)

Page 8: Sas tutorial glm2

Result (within)

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

Page 9: Sas tutorial glm2

Result

Between

Page 10: Sas tutorial glm2

Mix models

• 有些變項是受試者內設計,有些變項是受試者間設計。

Page 11: Sas tutorial glm2

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)

Page 12: Sas tutorial glm2

Codedata dogs;

input Drug $ Depleted $ Histamine0 Histamine1

Histamine3 Histamine5;

LogHistamine0=log(Histamine0);

LogHistamine1=log(Histamine1);

LogHistamine3=log(Histamine3);

LogHistamine5=log(Histamine5);

datalines;

Morphine N .04 .20 .10 .08

Morphine N .02 .06 .02 .02

Morphine N .07 1.40 .48 .24

Morphine N .17 .57 .35 .24

Morphine Y .10 .09 .13 .14

Morphine Y .12 .11 .10 .

Morphine Y .07 .07 .06 .07

Morphine Y .05 .07 .06 .07

Trimethaphan N .03 .62 .31 .22

Trimethaphan N .03 1.05 .73 .60

Trimethaphan N .07 .83 1.07 .80

Trimethaphan N .09 3.13 2.06 1.23

Trimethaphan Y .10 .09 .09 .08

Trimethaphan Y .08 .09 .09 .10

Trimethaphan Y .13 .10 .12 .12

Trimethaphan Y .06 .05 .05 .05

;

proc glm;

class Drug Depleted;

model LogHistamine0--LogHistamine5 =

Drug Depleted Drug*Depleted / nouni;

repeated Time 4 (0 1 3 5) polynomial / summary printe;

run;

先寫 betwwen,再寫 within

Missing data 不用

Page 13: Sas tutorial glm2

Result

Page 14: Sas tutorial glm2

Result

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