160 likes | 170 Views
Aimed at epidemiology, Stata offers many methods and growing graphics. Structured and programmable, it's coming soon to a course near you.
E N D
Why Stata • Pro • Aimed at epidemiology • Many methods, growing • Graphics • Structured, Programable • Comming soon to a course near you • Con • Memory>file size • Copy table H.S.
Use • Import data • DBMS-Copy • Do files • Highlight commands, Ctrl-D • Full syntax [by varlist:] command [varlist] [if exp] [in range] [, opts] • list if age<50 • list in 1/10 • regress y x1 x2 if deltabeta<0.3 H.S.
Data check describe describe dataset summarize means ++ list x1 x2 in 1/10 list first 10 obs gen id=_n generate id numlabel x1 x2, add add value to label tab x1 x2, mis x1 by x2 including missing list id x1 if (x2==.)+(x3==.)==1 list if x1 or x2 is missing egen miss=rowmiss(x1 x2 x3) number missing tab miss from 0-3 missing drop x1 if x1<0 drop negative drop x1 if x1>100 & x1<. drop large H.S.
Graphics • Explore data kdensity y distribution scatter y x scatter twoway (scatter y x)(lfit y x) scatter+line • Plot means graph bar (mean) y1 y2 mean of y1 and y2 graph bar (mean) y, over(c) mean y for values of c • Plot means using aggregate and twoway preserve collapse (mean) ym=y, by(c) one line pr c value line ym c lineplot mean(y) by c restore H.S.
Help • General • help command • search keyword • findit keyword • Examples • help table • search GAM • findit GAM H.S.
Continuous symetrical data • Univariate kdensity y distribution summarize y means ++ • Bivariate sdtest y, by(sex) equal variance? ttest y, by(sex) equal means? oneway y parity3, tabulate equal means? • Multivariable regress y x1 x2 linear regression dfbeta H.S.
Some options • mean y mean+ci • mean y, cluster(region) • mean y, standardize • mean y, bootstrap H.S.
Continuous skewed data • Univariate kdensity y distribution summarize y, detail medians ++ • Bivariate • table sex, c(median y) medians • ranksum y, by(sex) equal medians? • table sex, c(median y) medians • kwallis y, by(age3) equal medians? • Multivariable regress y x1 x2 linear regression dfbeta H.S.
Categorical data • Univariate tabulate y freq table proportion y prop with ci • Bivariate tabulate y sex, col chi2 column %, chisquare • Multivariable logistic y x1 x2 logistic regression binreg y x1 x2, rd risk difference H.S.
Survival data • Set stset time, failure(status==1) • Univariate sts graph, fail gwood KM failure+ci • Bivariate sts graph, fail by(x1) KM failure sts test x1 log rank test • Multivariable stcox x1 x2 cox regression H.S.
Model building • Estimate regress y exp exposure only est store m1 store regress y exp x1 x2 exposure +conf. est store m2 store • Compare est table m1 m2 confounding? est stat m1 m2 model fit • Interaction regress y exp x1 x1exp with interaction term lincom exp+2*x1exp effect of exp for x1=2 H.S.
Model testing • Assumptions Independent errors discuss Linear effects categorize, plot coefs Constant error plot resid (linear mod) • Influence Influential points plot delta-beta H.S.
Regression with simple error structure • regress linear regression (also heteroschedastic errors) • nl non linear least squares • GLM • logistic logistic regression • poisson Poisson regression • binreg binary outcome, OR, RR, or RD effect measures • Conditional logistc • clogit for matched case-control data • Multiple outcome • mlogit multinomial logit (not ordered) • ologit ordered logit • Regression with complex error structure • xtmixed linear mixed models • xtlogit random effect logistic H.S.
GLLAMM • Generalized Linear Latent And Mixed Models • Response types • continuous • ordered and unordered categories • counts • survival • Model types • Generalized Linear Models (GLM) • Structural Equation Models (SEM) • Mixed Models • Measurement Error models H.S.