0502 sas實習課

832 views

Published on

proc glm basic

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
832
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

0502 sas實習課

  1. 1. SAS tutorial: GLM (1)游如淇Psy.j.c.yu@gmail.comOffice hour: 星期一 下午4:00-5:00
  2. 2. Example 1• xx跟yy的關係是什麼?
  3. 3. Generalized Linear Model
  4. 4. Code of example 1畫圖ods graphics on;proc sgscatter data=ex1;plot yy*xx;run;ods graphics off;PROC GLMproc glm data=ex1;model yy=xx;proc glm data=ex1;model yy=xx*xx;run;
  5. 5. Example 1yy=xxyy=xx*xx
  6. 6. PROC GLM(功能)• Simple / multiple regression• ANOVA / MANOVA• ANOVA for repeated measures• ANCOVA• Weighted regression• Partial correlation• Polynomial regression
  7. 7. PROC GLM (syntax)PROC GLM 選項串 ;CLASS 變相名稱串;MODEL 依變項=實驗效果串/選項串 ;MEANS 實驗效果串/選項串;CONTRAST “標題” 效果名稱串 各組效果係數/選項串TEST H=效果項 E=殘差項RUN;• 還有ESTIMATE、RANDOM、LSMEAN…等其他statement,跟 PROC ANOVA 差不多Nominal or ordinal scale
  8. 8. Some statements• CONTRAST:作對比分析– CONTRAST “標題” 效果名稱串 各組效果係數/選項串;• “標題”: 20字內,不能有“;”• 效果名稱: 要在model中出現過,界定所要比較的效果• 係數:總合為0 以空格隔開– E.g. CONTRAST „A1B1 vs A2B2‟ A*B 1 0 0 -1;– E.g. CONTRAST „b at a1‟ a*b 3 3 -2 -2 -2 0 0 0 0 0;• 選項串:e, ss3……• TEST:指定效果項與殘差項作F檢定– TEST H=效果項 E=殘差項;– E.g. TEST h=A*B e=S*A*B;• CONTRAST必須擺在MODEL之後,TEST、MANOVA、REPEATED、RANDOM之前• CLASS需擺在MODEL之前
  9. 9. Some statements• ESTIMATE:估計參數的線性組合– ESTIMATE ‟label‟ effect values <...effect values >< / options > ;– 語法跟CONTRAST一樣,功能也差不多• RANDOM:指定哪些變項是 random effect– RANDOM effects < / options > ;– E.g. RANDOM A B;
  10. 10. Some statements• LSMean 效果串/選項串– 選項串• slice = 固定效果名稱串  簡單主要效果• Pdiff  成對LSMean差異• Sterror 算std error
  11. 11. Example: unbalancedANOVAdata exp;input A $ B $ Y @@;datalines;A1 B1 12 A1 B1 14 A1 B2 11A1 B2 9 A2 B1 20 A2 B1 18A2 B2 17;proc glm data=exp;class A B;model Y=A B A*B;run;
  12. 12. Result
  13. 13. Example
  14. 14. Result-1
  15. 15. Result-2
  16. 16. Result-3
  17. 17. Result-4means Type / waller regwq;run;

×