input x y
--> enter data --> end
infile
command to import data file
list
, codebook
, describe
, summarize
set memory
by group: egen avg = mean(dbp)
label data "The method of delivery recoreded for 600 births in a hospital"
notes: "Data from EMS Table. 3.1"
; second notes notes: edited on Jan. 15, 2007"
label define deliverylab 1 "Normal" 2 "Forceps" 3 "Caesarean section"
label values delivery deliverylab
tabulate delivery
input Normal Forceps Caesarean
, 478 65 57
, end
, graph hbar Normal Forceps Caesarean
or gen y = 1
, then graph hbar (count) y, over(delivery)
graph pie y, over(delivery)
infile id hemo using "C:\Teaching\IGP\data\haemoglobin.txt", clear
egen hemocat = cut(hemo), at(8, 9, 10, 11, 12, 13, 14, 15, 16)
, or egen hemocat = cut(hemo), at(8(1)16)
tabulate hemocat
stem hemo, lines(1)
histogram hemo, width(1) start(8) frequency xtitle("Haemoglobin level (g/100ml)")
need to know
graph box hemo
codebook hemo
, and summarize hemo
tabulate village source [weight=freq]
, use option row, col
twoway (scatter fev1 age), ylabel(0(1)3) ytick(0 1 2 3) ymtick(0(0.5)3) ytitle("FEV1 (litres)")
twoway (scatter fev1 respsymptoms)
twoway (scatter fev1 respsymptoms, jitter(10))
graph box fev1, over(respsymptoms)
dotplot fev1, over(respsymptoms) median center
egen meanvol = mean(volume) display meanvol gen dev = volume - meanvol gen dev2 = dev^2 gen vol2 = volume^2 egen volsum= total(volume) egen vol2sum= total(vol2) display vol2sum - volsum^2/8 egen dev2sum = total(dev2) di _N di dev2sum di sqrt(dev2sum/(_N-1)) summarize volume collapse (mean) mean_vol=volume (sd) sd_volume=volume list mean_vol sd_volume
help density functions * AUC of normal density function *find probability % below the specified z-score di normal(1.31) * AUC in upper tail of distribution di 1-normal(1.31) * AUC in lower tail of distribution di 1-normal(1.77) * AUC between two z values di normal(0.54) - normal(-1) * value corresponding to specified tail area input mu sigma z 171.5 6.5 1.64 end di mu + z*sigma drop mu sigma z * percentage points of normal density function (find z value corresponding %) di invnormal(.95) di invnormal(.975)
input mu sd n 24.2 5.9 100 end *find 5% percent point gen z = invnormal(.975) gen se = sd/sqrt(n) gen l_ci = mu - z*se gen u_ci = mu + z*se list cii n mu sd drop mu-u_ci *find 10%, 1% percent point: invnormal(.95); invnormal(.995)
* n is d.f. in Stata invttail(n, p) command drop n gen n=7 gen t = invttail(n, .025) gen se = sd/sqrt(n) gen l_ci = mu - t*se gen u_ci = mu + t*se list