1 / 24

Biostat 201: Winter 11

Biostat 201: Winter 11. Lab Session 3. SAS/STATA code key. I will use the following convention in these slides: statements : bold keywords : italics options : underlined Variables, or something you specify yourself : courier font . Assignment 3. What do we need to do?.

Samuel
Download Presentation

Biostat 201: Winter 11

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Biostat 201: Winter 11 Lab Session 3

  2. SAS/STATA code key • I will use the following convention in these slides: • statements: bold • keywords: italics • options: underlined • Variables, or something you specify yourself: courier font

  3. Assignment 3

  4. What do we need to do? • Please refer to the Section XII notes! • Wide versus Long Data • Import data • Descriptive statistics • Repeated Measures • VIA Factorial ANOVA • VIA regression

  5. Wide vs long data Wide Long

  6. How to change data from wide form to long form. SAS (one method) dataleadlong (drop = time0 time1 time4 time6); set lab.lead; lead=time0; time=0; output; lead=time1; time=1; output; lead=time4; time=4; output; lead=time6; time=6; output; label lead = "Blood Lead Level" time = "time" group= "Treatment"; run;

  7. How to change data from wide form to long form. • SAS (another method) dataleadlong; set lab.lead; array y{4} time0 time1 time4 time6; i=0; do time=0, 1, 4, 6; i = i+1; lead=y{i}; output; end; label lead = "Blood Lead Level" time = "time" group= "Treatment"; drop i time0 time1 time4 time6; run;

  8. How to change data from wide form to long form. • STATA reshape long time, i(id) j(t) rename time lead

  9. SAS: Descriptive StatisticsNote: Data is in LONG FORM • proc meansdata=dataset<options>; class grpvar1grpvar2…; var var1var2…;run; • proc meansdata=lead_longmeanstdstderr; class group time; var lead;run;

  10. SAS

  11. STATA: Descriptive StatisticsNote: Data is in LONG FORM meanvar1var2…, over(grpvar1grpvar2…) meanlead, over(grouptime)

  12. STATA

  13. STATA: Repeated Measures via Factorial ANOVA anova yvargrp / sub|grptgrp#t,repeated(t) anova lead group /id|group time group#time, repeated(t) ** models means - version 11 only ** margins group#t, asbalanced emptycells(reweight) NOTE: Data needs to be in the LONG format.

  14. STATA: Repeated Measures via Factorial ANOVA

  15. STATA: Repeated Measures via Factorial ANOVA

  16. SAS: Repeated Measures proc mixeddata=dataset;classgrptsub;modelyvar = grptgrp*t / s; repeated / subject=subtype=cs;lsmeans grp*t /diff; run; quit; proc mixed data = leadlong method = reml; class id group time; model lead = group time group*time / s ; repeated time / type=cs subject=id r rcorr ; lsmeans group*time /diff; run; NOTE: Data needs to be in the LONG format.

  17. STATA: Repeated Measures Regression NOTE: Data needs to be in the LONG format. xtregyvargrptgrp#t, i(sub) • xtreg lead i.group i.time i.group#i.time, i(id) xtmixedyvar i.grpt i.grp#t || id:, • xtmixed lead i.group i.time i.group#i.time || id:

  18. Estimates are different from SAS because the reference groups are different

  19. Estimating the means(results same as SAS) • margins i.group#i.t

  20. SAS: Repeated Measures via factorial ANOVA Note: Data needs to be in the WIDE format. • proc glmdata=dataset;classgrp ;modelyvar1 yvar2 .. yvarp =grp; repeated repeated-factor-name #of trials;run; quit; • procglm data =lead_wide; class group; model time0 time1 time4 time6 =group; repeated time 4; lsmeans group / out=means; run; quit

  21. SAS: Repeated Measures via factorial ANOVA

More Related