stata introduction short v2 n.
Download
Skip this Video
Download Presentation
Stata Introduction, Short v2

Loading in 2 Seconds...

play fullscreen
1 / 32

Stata Introduction, Short v2 - PowerPoint PPT Presentation


  • 187 Views
  • Uploaded on

Stata Introduction, Short v2. Hein Stigum Presentation, data and programs at: http://folk.uio.no/heins/ courses. Nov-14. H.S. 1. Stata introduction. General use Interface and menu Do-files and syntax Data handling Analysis Descriptive Graphs Bivariate. Why Stata. Pro

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Stata Introduction, Short v2' - amos-baker


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
stata introduction short v2

Stata Introduction, Shortv2

Hein Stigum

Presentation, data and programs at:

http://folk.uio.no/heins/

courses

Nov-14

H.S.

H.S.

1

stata introduction
Stata introduction
  • General use
    • Interface and menu
    • Do-files and syntax
    • Data handling
  • Analysis
    • Descriptive
    • Graphs
    • Bivariate

H.S.

why stata
Why Stata
  • Pro
    • Aimed at epidemiology
    • Many methods, growing
    • Graphics
    • Structured, Programmable
    • Coming soon to a course near you
  • Con
    • Memory>file size

Nov-14

H.S.

H.S.

3

interface stata 9
Interface Stata 9

Nov-14

H.S.

H.S.

5

interface stata 12
Interface Stata 12

Do

file

Data

edit

H.S.

slide7
Menu

Nov-14

H.S.

H.S.

7

do file example
Do-file example

New do-file: icon or Ctrl-9

Run: Mark, Ctrl-D

Nov-14

H.S.

H.S.

8

syntax
Syntax
  • Syntax

[bysort varlist:] command [varlist] [if exp] [in range][, opts]

  • Examples
    • meanage
    • meanageif sex==1
    • bysort sex: summarizeage
    • summarizeage,detail

Nov-14

H.S.

H.S.

9

import data
Import data
  • Using SPSS 14.0-17.0
    • Save as, Stata Version 8 SE

Nov-14

H.S.

H.S.

11

use and save data
Use and save data
  • Open data
    • use “C:\Course\Myfile.dta”, clear
  • Describe
    • describe describe all variables
    • listx1 x2 in 1/20 list obs nr 1 to 20
  • Save data
    • save “C:\Course\Myfile.dta” ,replace

Nov-14

H.S.

H.S.

12

use data from web
Use data from web
  • webuse “file” use data from Stata homepage
  • webuse set “http://www.med.uio.no/forskning/doktorgrad-karriere/forskerutdanning/kurs/biostatistikk/mf9510-logistisk-regresjon-overlevelsesanalyse-cox/”

set homepage

  • webuse “birth1” data for exercise 1

Nov-14

H.S.

H.S.

13

generate replace
Index

generate index=0

replaceindex=1 if sex==1 & age<30

Young/Old

generate old=(age>50)

Serial numbers, lags

generate id=_n

generate age1=age[ _n-1]

Generate, replace

if age<.

Nov-14

H.S.

H.S.

14

dates
Dates
  • From numeric to date

ex: m=12, d=2, y=1987

generatebirth=mdy(m,d,y)

formatbirth %td

  • From string to date

ex: bstr=“01.12.1987”

generatebirth=date(bstr,”DMY”)

formatbirth %td

Nov-14

H.S.

H.S.

15

missing
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

Nov-14

H.S.

H.S.

16

describe missing
Summarize variables

Missing in tables

Describe missing

summarize id bullied sex

tab bullied sex, missing

misstable summarize bullied sex new command

Nov-14

H.S.

H.S.

17

slide18
Help
  • General
    • helpcommand
    • finditkeyword search Stata+net
  • Examples
    • help table
    • findit aflogit

Nov-14

H.S.

H.S.

18

summing up
Summing up
  • Use do files
    • Run: Mark, Ctrl-D
  • Syntax
    • command [varlist] [if exp] [in range] [, options]
  • Missing
    • age>30 if age<.
    • generateold=(age>50) if age<.
  • Help
    • help describe

Nov-14

H.S.

H.S.

19

descriptive1
Descriptive
  • Continuous

summarize weight

summarize weight, details fractiles ++

  • Categorical

tabulate bullied

tabulate bullied,nolab show coding

H.S.

other descriptives
Other descriptives

tabstatmAge, stat( N min p50 mean max) by(parity)

Nov-14

H.S.

H.S.

22

twoway plots
Twoway plots
  • Syntax
    • twoway (plot1, opts) (plot2, opts), opts
  • One plot
    • kdensity bw
    • scatter bw gest

Nov-14

H.S.

H.S.

24

slide25

twoway ( kdensitybwif sex==1, lcolor(blue) ) ///

  • ( kdensitybwif sex==2, lcolor(red ) )

Nov-14

H.S.

H.S.

25

slide26

line fit

scatter

twoway(scatterbw gest) (fpfitcibw gest) (lfitbw gest)

smooth with CI

Nov-14

H.S.

H.S.

26

titles
Titles

scatterbw gest, title("title") subtitle("subtitle") ///

xtitle("xtitle") ytitle("ytitle") note("note")

Nov-14

H.S.

H.S.

27

2 independent samples
2 independent samples

Do boys and girls have the same mean birth weight?

  • twoway ( kdensity weight if sex==1, lcolor(blue) ) ///
  • ( kdensity weight if sex==2, lcolor(red) )

Equal means?

Equal variance?

Nov-14

H.S.

H.S.

29

2 independent samples test
2 independent samples test

ttest weight, by(sex) 2-sample T-test

ttest weight, by(sex) unequal

ttest w1 w2, paired

Nov-14

H.S.

H.S.

30

crosstables

equal proportions?

Crosstables

Are boys bullied as much as girls?

tabulate bullied sex, col chi2 nofreq

Nov-14

H.S.

H.S.

31

summing up1
Summing up

Descriptive

summarizeweight

tabulatesex

Graphs

twoway (plot1, opts) (plot2, opts), opts

Bivariate

ttest weight, by(sex)

tabulatebullied sex, chi2

Nov-14

H.S.

H.S.

32