SlideShare ist ein Scribd-Unternehmen logo
1 von 17
SAS tutorial: GLM (1)
游如淇
Psy.j.c.yu@gmail.com
Office hour: 星期一 下午4:00-5:00
Example 1
• xx跟yy的關係是什麼?
Generalized Linear Model
Code of example 1
畫圖
ods graphics on;
proc sgscatter data=ex1;
plot yy*xx;
run;
ods graphics off;
PROC GLM
proc glm data=ex1;
model yy=xx;
proc glm data=ex1;
model yy=xx*xx;
run;
Example 1
yy=xx
yy=xx*xx
PROC GLM(功能)
• Simple / multiple regression
• ANOVA / MANOVA
• ANOVA for repeated measures
• ANCOVA
• Weighted regression
• Partial correlation
• Polynomial regression
PROC GLM (syntax)
PROC GLM 選項串 ;
CLASS 變相名稱串;
MODEL 依變項=實驗效果串/選項串 ;
MEANS 實驗效果串/選項串;
CONTRAST “標題” 效果名稱串 各組效果係數/選項串
TEST H=效果項 E=殘差項
RUN;
• 還有ESTIMATE、RANDOM、LSMEAN…等其他
statement,跟 PROC ANOVA 差不多
Nominal or ordinal scale
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之前
Some statements
• ESTIMATE:估計參數的線性組合
– ESTIMATE ‟label‟ effect values <...effect values >
< / options > ;
– 語法跟CONTRAST一樣,功能也差不多
• RANDOM:指定哪些變項是 random effect
– RANDOM effects < / options > ;
– E.g. RANDOM A B;
Some statements
• LSMean 效果串/選項串
– 選項串
• slice = 固定效果名稱串  簡單主要效果
• Pdiff  成對LSMean差異
• Sterror 算std error
Example: unbalanced
ANOVA
data exp;
input A $ B $ Y @@;
datalines;
A1 B1 12 A1 B1 14 A1 B2 11
A1 B2 9 A2 B1 20 A2 B1 18
A2 B2 17
;
proc glm data=exp;
class A B;
model Y=A B A*B;
run;
Result
Example
Result-1
Result-2
Result-3
Result-4means Type / waller regwq;
run;

Weitere ähnliche Inhalte

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

0502 sas實習課

  • 1. SAS tutorial: GLM (1) 游如淇 Psy.j.c.yu@gmail.com Office hour: 星期一 下午4:00-5:00
  • 4. Code of example 1 畫圖 ods graphics on; proc sgscatter data=ex1; plot yy*xx; run; ods graphics off; PROC GLM proc glm data=ex1; model yy=xx; proc glm data=ex1; model yy=xx*xx; run;
  • 6. PROC GLM(功能) • Simple / multiple regression • ANOVA / MANOVA • ANOVA for repeated measures • ANCOVA • Weighted regression • Partial correlation • Polynomial regression
  • 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. 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. Some statements • ESTIMATE:估計參數的線性組合 – ESTIMATE ‟label‟ effect values <...effect values > < / options > ; – 語法跟CONTRAST一樣,功能也差不多 • RANDOM:指定哪些變項是 random effect – RANDOM effects < / options > ; – E.g. RANDOM A B;
  • 10. Some statements • LSMean 效果串/選項串 – 選項串 • slice = 固定效果名稱串  簡單主要效果 • Pdiff  成對LSMean差異 • Sterror 算std error
  • 11. Example: unbalanced ANOVA data exp; input A $ B $ Y @@; datalines; A1 B1 12 A1 B1 14 A1 B2 11 A1 B2 9 A2 B1 20 A2 B1 18 A2 B2 17 ; proc glm data=exp; class A B; model Y=A B A*B; run;
  • 17. Result-4means Type / waller regwq; run;