Basic Biostatistics, Spring 2015:
Stata day by day
This page list the Stata commands day by day. Text in Courrier new is Stata commands and in bold like var, var1 and group are variables in Stata.
Day Topics Statistics General / Graphs
1 One sample from normal distribution ci var
ttest var=hypothesis
centile var, c(2.5 97.5) meansd
log close
log using file
sum var
graph box var
histogram var, norm
qnorm var
2 Two samples from normal distribution
Nonparametric test
Samplesize
ttest var, by(group)
sdtest var, by(group)
ranksum var, by(group)
db sampsi
dotplot var,over(group)
For graphs: Naming, combining and saving
3 Paried data
Nonparametric test
Samplesize
ttest var1=var2
signrank var1=var2
db sampsi
For graphs: More data in the same plot using
twoway
4 Binary data
One and two samples
Risk difference, risk ratio, odds ratio
Chi-square test
Paired
Spearmans test
Samplesize
ci var,bin
prtest var=hypothesis
bitest var=hypothesis
cs var group,or woolf
cc var group
tab2 var1 var2, chi2 exact
mcc var1 var2
spearman var1 var2
db sampsi

5 Linear regression
Comparing two lines
Analysis of covariance
regres var var1
predict newvar1,xb
predict newvar2,res
regres var i.var1##var2
regres var i.var1 var2
lincom .....
pwcorr var1 var2
twoway ///
(scatter var var1) ///
(lfit var var1) ///
(lfit var var1,stdf)
6 One way analysis of variance
Bartlett test
Kruskal-Wallis test
oneway var group,tabu
regres var i.group
adjust, by(group) ci
kwallis var, by(group)

7 Odds ratios
Simple Logistic regression
logit var var1
logit var var1,or
logit var i.group
logit var i.group##var1
lincom ....,or

8 Survival data
Kaplan-Meier curves


Median survival
Proportinal hazard (Cox) regression
stset eventtime ///
,fail(status) ///
enter(startdate) ///
origin(startdate) ///
scale(365.25)
stci,p(25) by(group)
stcox i.group,nohr
stcox i.group
st graph,gw
st graph,by(group)
stcoxkm graph,by(group)
stphplot,by(group) nolntime