************************************ ************************************ ***THE NORMAL CURVE (chapter 5) ************************************ ************************************ ************************************ ***OPENING COMMANDS ************************************ ***Clear memory clear all ***Start saving results window log using "C:\course\progs\Stata03.log", replace text // Windows log using "/course/progs/Stata03.log", replace text // Macintosh ************************************ ***GRAPH COMMAND TO GENERATE NORMAL DISTRIBUTION ************************************ ***#delimit resets the character that marks the end of a command #delimit ; ***Plot two normal distributions ***IQ scores for females and males graph twoway (function y=normalden(x,100,10), range(40 160) lcolor(maroon) lw(medthick)) (function y=normalden(x,100,20), range(40 160) lcolor(navy) lw(medthick)), title("Normal density of IQ scores for females and males", color(black)) xtitle("IQ Units", size(medlarge)) ytitle("") xlabel(40(10)160) xscale(lw(medthick)) yscale(lw(medthick)) legend(order(1 "Females" 2 "Males")) graphregion(fcolor(white)); ***#delimit resets the character that marks the end of a command #delimit cr ************************************ ***AREA UNDER THE NORMAL CURVE ***"normal" shows area below Z ************************************ ***Area below Z=0.85 display normal(0.85) di normal(0.85) ***Area above Z=0.40 di 1-normal(0.4) ***Area below Z=-1.35 di normal(-1.35) ***Area between Z=-0.35 and Z=0.60 di normal(0.6)-normal(-0.35) ***Area between Z=0.65 and Z=1.05 di normal(1.05)-normal(0.65) ***Area above Z=1.5 di 1-normal(1.5) ************************************ ***DISTRIBUTION OF INCOME ***GENERAL SOCIAL SURVEY ************************************ ***Open 2016 GSS use "C:\course\data\GSS2016.dta", clear // Windows use "/course/data/GSS2016.dta", clear // Macintosh ***Histogram of income hist conrinc, norm percent ***Boxplot of income graph hbox conrinc ***Quantile-normal plot of income qnorm conrinc ***Power transformation ***q<1 (reduce positive skew) ***log(y): q=0 gen lnconrinc = ln(conrinc) ***Histogram of log of income hist lnconrinc, norm percent ***Boxplot of log of income graph hbox lnconrinc ***Quantile-normal plot of log income qnorm lnconrinc ************************************ ***CLOSING COMMANDS ************************************ ***Save log log close