*! 1.0.1 NJC 7 Jan 1999 STB-48 gr35 * 1.0.0 NJC 2 Feb 1998 program define qsm version 5.0 local varlist "req ex max(1)" local if "opt" local in "opt" local options "Symbol(string) Connect(string) GRid noBorder *" parse "`*'" capture assert "$S_a" != "" & "$S_b" != "" & "$S_q" != "" if _rc { di in r "needs macros S_a, S_b and S_q" exit 198 } if "`symbol'" == "" { local symbol "oi" } else { local symbol "`symbol'`i" } if "`connect'" == "" { local connect ".l" } else { local connect "`connect'`l" } tempvar y touse x Psubi quietly { gen `y' = `varlist' local yl: variable label `varlist' if "`yl'" == "" { label var `y' "`varlist'" } else { label var `y' "`yl'" } gen byte `touse' = cond(`varlist' == .,.,1) `if' `in' sort `varlist' gen float `Psubi' = sum(`touse') replace `Psubi' = cond(`touse' == .,.,(`Psubi'-.5)/`Psubi'[_N]) gen float `x' = /* */ $S_b * (( 1 / (1 - `Psubi'))^(1 / $S_q) - 1)^(1 / $S_a) label var `x' "inverse Singh-Maddala" local fmt : format `varlist' format `y' `x' `fmt' if "`grid'" != "" { parse "5 10 25 50 75 90 95", parse(" ") while "`1'" != "" { local smq`1' : di %4.3f /* */ $S_b * (( 1 / (1 - `1' / 100))^(1 / $S_q) - 1)^(1 / $S_a) mac shift } su `y' if `touse', detail local xtl = "`smq50',`smq95',`smq5'" local xn = "`xtl',`smq25',`smq75',`smq90',`smq10'" #delimit ; local ytl = string(_result(7)) + "," + string(_result(10)) + "," + string(_result(13)) ; local yn = "`ytl'" + "," + string(_result(8)) + "," + string(_result(9)) + "," + string(_result(11)) + "," + string(_result(12)) ; noisily graph `y' `x' `x', c(`connect') s(`symbol') ylin(`yn') rtic(`yn') rlab(`ytl') xlin(`xn') ttic(`xn') tlab(`xtl') `options' t1("(Grid lines are 5, 10, 25, 50, 75, 90, and 95 percentiles)") ; #delimit cr } else { if "`border'"=="" { local bo "border" } noisily graph `y' `x' `x', c(`connect') /* */ s(`symbol') `bo' `options' } } end