Presentation is loading. Please wait.

Presentation is loading. Please wait.

Apr-15H.S.1Apr-15H.S.1 Stata Introduction, Short v2 Hein Stigum Presentation, data and programs at: courses.

Similar presentations


Presentation on theme: "Apr-15H.S.1Apr-15H.S.1 Stata Introduction, Short v2 Hein Stigum Presentation, data and programs at: courses."— Presentation transcript:

1 Apr-15H.S.1Apr-15H.S.1 Stata Introduction, Short v2 Hein Stigum Presentation, data and programs at: courses

2 Stata introduction General use –Interface and menu –Do-files and syntax –Data handling Analysis –Descriptive –Graphs –Bivariate Apr-15H.S.2

3 Apr-15H.S.3Apr-15H.S.3 Why Stata Pro –Aimed at epidemiology –Many methods, growing –Graphics –Structured, Programmable –Coming soon to a course near you Con –Memory>file size

4 Interface

5 Apr-15H.S.5Apr-15H.S.5 Interface Stata 9

6 Interface Stata 12 Apr-15H.S.6 Do file Data edit

7 Apr-15H.S.7Apr-15H.S.7 Menu

8 Apr-15H.S.8Apr-15H.S.8 Do-file example New do-file:icon or Ctrl-9 Run:Mark, Ctrl-D

9 Apr-15H.S.9Apr-15H.S.9 Syntax [bysort varlist:] command [varlist] [if exp] [in range][, opts] Examples –mean age –mean age if sex==1 –bysort sex: summarize age –summarize age,detail

10 Data handling

11 Apr-15H.S.11Apr-15H.S.11 Import data Using SPSS –Save as, Stata Version 8 SE

12 Apr-15H.S.12Apr-15H.S.12 Use and save data Open data –use “C:\Course\Myfile.dta”, clear Describe –describedescribe all variables –list x1 x2 in 1/20list obs nr 1 to 20 Save data –save “C:\Course\Myfile.dta”,replace

13 Apr-15H.S.13Apr-15H.S.13 Use data from web webuse“file”use data from Stata homepage 1.webuse set “http://www.med.uio.no/forskning/doktorgrad- karriere/forskerutdanning/kurs/biostatistikk/mf 9510-logistisk-regresjon-overlevelsesanalyse- cox/ ” set homepage 2.webuse “birth1”data for exercise 1

14 Apr-15H.S.14Apr-15H.S.14 Generate, replace Index –generate index=0 –replace index=1 if sex==1 & age<30 Young/Old –generate old=(age>50) Serial numbers, lags –generate id=_n –generate age1=age[ _n-1] if age<.

15 Apr-15H.S.15Apr-15H.S.15 Dates From numeric to date ex: m=12, d=2, y=1987 generate birth=mdy(m,d,y) format birth %td From string to date ex: bstr=“ ” generate birth=date(bstr,”DMY”) format birth %td

16 Apr-15H.S.16Apr-15H.S.16 Missing Obs!!! –Represented as ”.” –Missing values are large numbers –age>30 will include missing. –age>30 if age<.will not. Test –replace age=0 if (age==.) Remove –drop if age==. Change –replace educ=. if educ==99

17 Apr-15H.S.17Apr-15H.S.17 Describe missing Summarize variables Missing in tables misstable summarize bullied sexnew command summarize id bullied sex tab bullied sex, missing

18 Apr-15H.S.18Apr-15H.S.18 Help General –help command –findit keywordsearch Stata+net Examples –help table –findit aflogit

19 Apr-15H.S.19Apr-15H.S.19 Summing up Use do files –Run:Mark, Ctrl-D Syntax –command [varlist] [if exp] [in range] [, options] Missing –age>30 if age<. –generate old=(age>50) if age<. Help –help describe

20 Descriptive

21 Apr-15H.S.21 Descriptive Continuous Categorical summarize weight summarize weight, detailsfractiles ++ tabulate bullied tabulate bullied, nolabshow coding

22 Apr-15H.S.22Apr-15H.S.22 Other descriptives tabstat mAge, stat( N min p50 mean max) by(parity)

23 Apr-15H.S.23 Graphics

24 Apr-15H.S.24Apr-15H.S.24 Twoway plots Syntax –twoway (plot1, opts) (plot2, opts), opts One plot –kdensity bw –scatter bw gest

25 Apr-15H.S.25Apr-15H.S.25 twoway ( kdensity bw if sex==1, lcolor(blue) ) /// ( kdensity bw if sex==2, lcolor(red ) )

26 Apr-15H.S.26Apr-15H.S.26 twoway (scatter bw gest) (fpfitci bw gest) (lfit bw gest) scatter smooth with CI line fit

27 Apr-15H.S.27Apr-15H.S.27 Titles scatter bw gest, title("title") subtitle("subtitle") /// xtitle("xtitle") ytitle("ytitle") note("note")

28 Bivariate analysis

29 Apr-15H.S.29Apr-15H.S.29 2 independent samples twoway ( kdensity weight if sex==1, lcolor(blue) ) /// ( kdensity weight if sex==2, lcolor(red) ) Equal means? Equal variance? Do boys and girls have the same mean birth weight?

30 Apr-15H.S.30Apr-15H.S.30 2 independent samples test ttest weight, by(sex) unequal ttest w1 w2, paired ttest weight, by(sex)2-sample T-test

31 Apr-15H.S.31Apr-15H.S.31 Crosstables equal proportions? Are boys bullied as much as girls? tabulate bullied sex, col chi2 nofreq

32 Apr-15H.S.32Apr-15H.S.32 Summing up Descriptive summarize weight tabulate sex Graphs twoway (plot1, opts) (plot2, opts), opts Bivariate ttest weight, by(sex) tabulate bullied sex, chi2


Download ppt "Apr-15H.S.1Apr-15H.S.1 Stata Introduction, Short v2 Hein Stigum Presentation, data and programs at: courses."

Similar presentations


Ads by Google