set verbose off open mroz87.gdt --quiet series lWW = log(WW) scalar m = mean(lWW) scalar s = sd(lWW) ### ### prepare matrix with data for plot ### # number of valid observations scalar n = nobs(lWW) # discretize log wage scalar k = 4 series disc_lWW = round(lWW*k)/k # get frequencies matrix f = aggregate(null, disc_lWW) # add density phi = dnorm((f[,1] - m)/s) / (s*k) # put columns together and add labels plotmat = f[,2]./n ~ phi ~ f[,1] strings cnames = defarray("frequency", "density", "log wage") cnameset(plotmat, cnames) ### ### create plot ### plot plotmat # move legend literal set key outside rmargin # set line style literal set linetype 2 dashtype 2 linewidth 2 # set histogram color literal set linetype 1 lc rgb "#777777" # set histogram style literal set style fill solid 0.25 border # set histogram width printf "set boxwidth %4.2f\n", 0.5/k options with-lines=2 with-boxes=1 end plot --output=display