Title: Biostat 201: Winter 11
1Biostat 201 Winter 11
2SAS/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
3Assignment 3
4What 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
5Wide vs long data
Wide
Long
6How to change data from wide form to long form.
- SAS (one method)
- data leadlong (drop time0 time1 time4 time6)
- set lab.lead
- leadtime0 time0 output
- leadtime1 time1 output
- leadtime4 time4 output
- leadtime6 time6 output
- label lead "Blood Lead Level" time "time"
group "Treatment" run
7How to change data from wide form to long form.
- SAS (another method)
- data leadlong set lab.lead
- array y4 time0 time1 time4 time6
- i0
- do time0, 1, 4, 6
- i i1
- leadyi output end
- label lead "Blood Lead Level" time "time"
group "Treatment" - drop i time0 time1 time4 time6 run
8How to change data from wide form to long form.
- STATA
- reshape long time, i(id) j(t)
- rename time lead
9SAS Descriptive StatisticsNote Data is in LONG
FORM
- proc means datadataset ltoptionsgt class grpvar1
grpvar2 var var1 var2run - proc means datalead_long mean std stderr class
group time var leadrun
10SAS
11STATA Descriptive StatisticsNote Data is in
LONG FORM
- mean var1 var2, over(grpvar1 grpvar2)
- mean lead, over(group time)
12STATA
13(No Transcript)
14STATA Repeated Measures via Factorial ANOVA
- anova yvar grp / subgrp t grpt,repeated(t)
- anova lead group /idgroup time grouptime,
repeated(t) - models means - version 11 only
- margins groupt, asbalanced emptycells(reweight)
NOTE Data needs to be in the LONG format.
15STATA Repeated Measures via Factorial ANOVA
16STATA Repeated Measures via Factorial ANOVA
17SAS Repeated Measures
NOTE Data needs to be in the LONG format.
- proc mixed datadataset class grp t sub model
yvar grp t grpt / s repeated / subjectsub
typecs lsmeans grpt /diff run quit - proc mixed data leadlong method reml
- class id group time
- model lead group time grouptime / s
- repeated time / typecs subjectid r rcorr
- lsmeans grouptime /diff
- run
18(No Transcript)
19(No Transcript)
20STATA Repeated Measures Regression
NOTE Data needs to be in the LONG format.
- xtreg yvar grp t grpt, i(sub)
- xtreg lead i.group i.time i.groupi.time, i(id)
- xtmixed yvar i.grp t i.grpt id,
- xtmixed lead i.group i.time i.groupi.time id
21Estimates are different from SAS because the
reference groups are different
22Estimating the means(results same as SAS)
23SAS Repeated Measures via factorial ANOVA
Note Data needs to be in the WIDE format.
- proc glm datadataset class grp model yvar1
yvar2 .. yvarp grp repeated
repeated-factor-name of trialsrun quit - proc glm data lead_wide
- class group
- model time0 time1 time4 time6 group
- repeated time 4
- lsmeans group / outmeans run quit
24SAS Repeated Measures via factorial ANOVA