Descriptive Statistics and Visualizing Data in STATA, Lecture notes of Descriptive statistics

Descriptive Statistics. Basic commands detailed in this week's lecture notes: • summarize. • means. • centile. • tabstat. • tabulate ...

Typology: Lecture notes

2021/2022

Uploaded on 09/12/2022

leyllin
leyllin 🇬🇧

4.3

(15)

241 documents

1 / 37

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Descriptive Statistics and Visualizing Data
in STATA
BIOS 514/517
R. Y. Coley
Week of October 7, 2013
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25

Partial preview of the text

Download Descriptive Statistics and Visualizing Data in STATA and more Lecture notes Descriptive statistics in PDF only on Docsity!

Descriptive Statistics and Visualizing Data

in STATA

BIOS 514/

R. Y. Coley

Week of October 7, 2013

Log Files, Getting Data in STATA

Log files save your commands cd /home/students/rycoley/bios514-

  • (^) To change directory

log using stata-section-oct7, replace text

  • To name log file (change stata-section-oct7)
  • (^) capture log close to close log file

insheet using http://courses.washington.edu/b517/Datasets/FEVdata.csv

  • (^) To get FEV data in

Labeling Variables

label variable age "Age (years)"

label variable fev "FEV (L/s)"

label variable height "Height (in)"

Descriptive Statistics

Basic commands detailed in this week’s lecture notes:

  • summarize
  • means
  • (^) centile
  • tabstat
  • (^) tabulate

Defining New Variables

A few ways:

  • (^) gen age9over = age>=
  • gen age9over = 0 replace age9over=1 if age>=
  • (^) gen age9over = age==9 | age==10 | age==11... |age==

Measures of Spread

  • (^) Range: tabstat fev, stat(min max range)
  • Variance: tabstat fev, stat(var)
  • Standard Deviation: tabstat fev, stat(sd)
  • (^) Interquartile Range: tabstat fev, stat(p25, p75, iqr) - (^) IQR is the distance between the 25th and 75th percentiles of the data

Visualizing Data- Histograms

histogram fev, kdensity by (sex)

kdensity adds smooth line estimating density

Visualizing Data- Dotplots

dotplot fev

Each dot represents an observations

Visualizing Data- Box Plots

graph box fev

Visualizing Data- Box Plots

graph box fev, over(sex)

Visualizing Data- Bar Charts

gen one= graph bar (count) one, over(smoke) ytitle("frequency")

Another Example

log using cause-of-death, text replace set obs 10 input float deaths str30 cause 700142 "Heart Disease" 553768 "Cancer" 163538 "Cerebrovascular Disease" 123013 "Chronic respiratory disease" 101537 "Accidental Death" 71372 "Diabetes" 62034 "Flu and pneumonia" 53852 "Alzheimer’s disease" 39480 "Kidney disorder" 32238 "Septicemia"

Visualizing Data- Bar Charts

gen dthou=deaths/ graph hbar dthou, over(cause, sort(1) descending) ytitle("Annual deaths (thousands)")

Visualizing Data- Pie Charts

graph pie deaths, over(cause) sort descending