--------------------------------------------------------------------------------- log: c:\Imbook\bwebpage\Section4\mma16p2mills.txt log type: text opened on: 7 Nov 2006, 17:31:05 . . ********** OVERVIEW OF MMA16P2MILLS.DO ********** . . * STATA Program . * copyright C 2005 by A. Colin Cameron and Pravin K. Trivedi . * used for "Microeconometrics: Methods and Applications" . * by A. Colin Cameron and Pravin K. Trivedi (2005) . * Cambridge University Press . . * Chapter 16.3.4 page 540 . * Presentation of Mills ratio . * It provides A CORRECTED VERSION (see explanation below) of . * (1) Figure 16.1 (ch16millsratio.wmf) . * This program requires no data . . ********** SETUP *********** . . set more off . version 8 . set scheme s1mono /* Used for graphs */ . . ********** GENERATE DATA AND FUNCTIONS . . * Create density cdf Mills ratio for N[0,1] . set obs 100 obs was 0, now 100 . gen c = 4*(50-_n)/100 . gen PHIc = norm(c) . gen phic = normden(c) . gen lamdac = phic/PHIc . . /* EXPLANATION - > The book in equation (16.22) defines the inverse Mills ratio as > E[z | z > -c] = lamda(c) = phi(c)/PHI(c) given in equation (16.22) > Others instead define the Mills ratio as > E[z | z > c] = lamda(c) = phi(c)/[1-PHI(c)] > By mistake this latter alternative was given as Figure 16.2. > The current correction instead uses phi(c)/PHI(c) > The text at the bottom of page 540 also needs to change. */ . . * Descriptive statistics . summarize Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- c | 100 -.02 1.16046 -2 1.96 PHIc | 100 .4952275 .338039 .0227501 .9750021 phic | 100 .2386177 .1157086 .053991 .3989423 lamdac | 100 .9516584 .711416 .0599393 2.373216 . . *********** FIGURE 16.2 page 540 *********** . . * This graph shows Mills ratio and cdf and density . graph twoway (scatter lamdac c, c(l) msize(vtiny) clstyle(p1) clwidth(medthic > k)) /* > */ (scatter PHIc c, c(l) msize(vtiny) clstyle(p3) clwidth(medthick)) /* > */ (scatter phic c, c(l) msize(vtiny) clstyle(p2) clwidth(medthick)), /* > */ scale (1.2) plotregion(style(none)) /* > */ title("Inverse Mills Ratio E[z|z>-c] as Cutoff Varies") /* > */ xtitle("c", size(medlarge)) xscale(titlegap(*5)) /* > */ ytitle("Inverse Mills, pdf and cdf", size(medlarge)) yscale(titlegap(*5) > ) /* > */ legend(pos(11) ring(0) col(1)) legend(size(small)) /* > */ legend( label(1 "Inverse Mills ratio") label(2 "N[0,1] Cdf") label(3 "N[ > 0,1] Density")) . graph export ch16millsratio.wmf, replace (file c:\Imbook\bwebpage\Section4\ch16millsratio.wmf written in Windows Metafil > e format) . . ********** CLOSE OUTPUT *********** . log close log: c:\Imbook\bwebpage\Section4\mma16p2mills.txt log type: text closed on: 7 Nov 2006, 17:31:08 -------------------------------------------------------------------------------