Stata Introduction , Short - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Stata Introduction , Short

Description:

Coming soon to a course near you. Con. Memory file size. Copy ... webuse 'birth1' data for exercise 1. 11/10/09. H.S. 13. H.S. 13. Generate, replace. Index ... – PowerPoint PPT presentation

Number of Views:112
Avg rating:3.0/5.0
Slides: 31
Provided by: heins1
Category:

less

Transcript and Presenter's Notes

Title: Stata Introduction , Short


1
Stata Introduction , Short
  • Hein Stigum
  • Presentation, data and programs at
  • http//folk.uio.no/heins/

Dec-09
H.S.
1
2
Why Stata
  • Pro
  • Aimed at epidemiology
  • Many methods, growing
  • Graphics
  • Structured, Programmable
  • Coming soon to a course near you
  • Con
  • Memorygtfile size
  • Copy tables

Dec-09
H.S.
2
3
Interface
4
Interface
Dec-09
H.S.
4
5
Menu
Dec-09
H.S.
5
6
Do Editor
  • New
  • Ctrl-8, doedit or
  • Run
  • Mark commands, Ctrl-D to do (execute)

Dec-09
H.S.
6
7
Do-file example
Dec-09
H.S.
7
8
Syntax
  • Syntax
  • bysort varlist command varlist if exp in
    range, opts
  • Examples
  • mean age
  • mean age if sex1
  • bysort sex summarize age
  • summarize age ,detail

Dec-09
H.S.
8
9
Data handling
10
Import data
  • Using SPSS 14.0
  • Save as, Stata Version 8 SE

Dec-09
H.S.
10
11
Use and save data
  • Open data
  • set memory 200m
  • use C\Course\Myfile.dta, clear
  • Describe
  • describe describe all variables
  • list x1 x2 in 1/20 list obs nr 1 to 20
  • Save data
  • save C\Course\Myfile.dta ,replace

Dec-09
H.S.
11
12
Use data from web
  • webuse file use data from Stata homepage
  • webuse set http//www.med.uio.no/imb/stat/kursfil
    er/
  • set homepage
  • webuse birth1 data for exercise 1

Dec-09
H.S.
12
13
Generate, replace
  • Index
  • generate index0
  • replace index1 if sex1 agegt30
  • Young/Old
  • generate old(agegt50)
  • Serial numbers, lags
  • gen id_n
  • gen lagage _n-1

if agelt.
Dec-09
H.S.
13
14
Dates
  • From numeric to date
  • ex m12, d2, y1987
  • generate bdatemdy(m,d,y)
  • format bdate td
  • From string to date
  • ex bstr01.12.1987
  • generate bdatedate(bstr,DMY)
  • format bdate td

Dec-09
H.S.
14
15
Missing
  • Obs!!!
  • Missing values are large numbers
  • agegt30 will include missing.
  • agegt30 if agelt. will not.
  • Test
  • replace x0 if (x.)
  • Remove
  • drop if age.
  • Change
  • replace educ. if educ99

Dec-09
H.S.
15
16
Describe missing
  • Summarize variables
  • Missing in tables

Dec-09
H.S.
16
17
Help
  • General
  • help command
  • findit keyword search Statanet
  • Examples
  • help table
  • findit aflogit

Dec-09
H.S.
17
18
Summing up
  • Use do files
  • Mark, Ctrl-D to do (execute)
  • Syntax
  • command varlist if exp in range , options
  • Missing
  • agegt30 if agelt.
  • generate old(agegt50) if agelt.
  • Help
  • help describe

Dec-09
H.S.
18
19
Descriptive
20
Descriptive
  • Continuous

summarize weight, det details
  • Categorical

tabulate bullied, nolab show coding
21
Other descriptives
tabstat mAge, stat( N min p50 mean max)
by(parity)
Dec-09
H.S.
21
22
Graphics
23
Twoway plots
  • Syntax
  • twoway (plot1, opts) (plot2, opts), opts
  • One plot
  • kdensity x Distribution plot
  • scatter y x Scatter plot
  • Overlaid plots
  • twoway (kdensity y if x1) (kdensity y if x2)
  • twoway (scatter y x) (fpfitci y x) (lfit y x)

Dec-09
H.S.
23
24
twoway ( kdensity weight if sex1, lcolor(blue)
) /// ( kdensity weight if sex2, lcolor(red
) )
Dec-09
H.S.
24
25
twoway (scatter y x) (fpfitci y x) (lfit y x)
Dec-09
H.S.
25
26
Titles
scatter weight gest, title("title")
subtitle("subtitle") /// xtitle("xtitle")
ytitle("ytitle") note("note")
Dec-09
H.S.
26
27
Bivariate analysis
28
2 independent samples
Do boys and girls have the same mean birth weight?
twoway ( kdensity weight if sex1, lcolor(blue)
) /// ( kdensity weight if sex2,
lcolor(red) )
Equal means? Equal variance?
Dec-09
H.S.
28
29
2 independent samples test
ttest weight, by(sex) unequal ttest w1 w2, paired
Dec-09
H.S.
29
30
Crosstables
Are boys bullied as much as girls?
Dec-09
H.S.
30
Write a Comment
User Comments (0)
About PowerShow.com