I would like to know how can I calculate AUC after I run a logit model using runmlwin command through STATA.
Kind regards
Kind regards
twoway scatter x y || lfit x y
* Example generated by -dataex-. To install: ssc install dataex clear input double(permno shares date smi1 smi2) float(lsmi1 lsmi2) 10001 119324 18628 -69.55078125 -1260000 -736.769 -2210000 10001 117181 18628 0 0 -51.88709 -940000 10001 16900 18628 0 0 -126.95777 -2300000 10001 6150 18628 87.21446990966797 1580000 0 0 10001 12366 18628 0 0 998.0674 5500000 10001 24315 18628 240.66776084899902 4360000 635.3408 11510000 10001 750 18628 165.04510498046875 2990000 -165.0451 -2990000 10001 19986 18628 51.33509826660156 930000 103.22218 1870000 10001 190860 18628 35.87936782836914 650000 0 0 10001 58062 18628 -160.0771942138672 -2900000 -204.2364 -3700000 10001 24315 18629 -2143.792381286621 -9550000 807.5618 14630000 10001 58062 18629 1033.946834564209 4500000 -364.3136 -6600000 10001 190860 18629 -792.1060791015625 -2800000 35.879368 650000 10001 6150 18629 -87.21446990966797 -1580000 0 0 10001 16900 18629 -750.0168380737305 -800000 0 0 10001 117181 18629 620.0230731964111 2570000 -51.88709 -940000 10001 750 18629 -1810.5282592773437 -6400000 165.0451 2990000 10001 19986 18629 -1314.4269104003906 -6900000 205.8924 3730000 10001 119324 18629 736.769063949585 2210000 -763.8166 -2700000 10001 12366 18629 818.6706085205078 2250000 906.9891 3850000 10001 117181 18630 0 0 594.0795 2100000 10001 19986 18630 -205.8923797607422 -3730000 -902.6422 560000 10001 190860 18630 0 0 -720.3474 -1500000 10001 16900 18630 126.95777130126953 2300000 -750.0168 -800000 10001 24315 18630 -24.287572860717773 -440000 -1557.0267 1080000 10001 58062 18630 -57.958980560302734 -1050000 771.7514 -250000 10001 6150 18630 0 0 -87.21447 -1580000 10001 119324 18630 69.55078125 1260000 736.769 2210000 10001 750 18630 221.34811401367187 4010000 -1645.483 -3410000 10001 12366 18630 91.07839965820313 1650000 818.6706 2250000 10001 19986 18631 0 0 -205.8924 -3730000 10001 24315 18631 -195.40457344055176 -3540000 -24.28757 -440000 10001 16900 18631 0 0 126.95777 2300000 10001 6150 18631 87.21446990966797 1580000 0 0 10001 12366 18631 0 0 91.0784 1650000 10001 750 18631 0 0 221.3481 4010000 10001 117181 18631 0 0 0 0 10001 119324 18631 -27.04752540588379 -490000 69.55078 1260000 10001 58062 18631 -160.0771942138672 -2900000 -57.95898 -1050000 10001 190860 18631 0 0 0 0 10001 117181 18632 0 0 0 0 10001 58062 18632 218.03617477416992 3950000 -160.0772 -2900000 10001 12366 18632 -91.07839965820313 -1650000 0 0 10001 190860 18632 -35.87936782836914 -650000 0 0 10001 750 18632 -193.1966094970703 -3500000 0 0 10001 6150 18632 0 0 87.21447 1580000 10001 24315 18632 -215.27620697021484 -3900000 -195.40457 -3540000 10001 16900 18632 126.95777130126953 2300000 0 0 10001 19986 18632 -154.55728149414062 -2800000 0 0 10001 119324 18632 69.55078125 1260000 -27.047525 -490000 10001 119324 18633 -27.04752540588379 -490000 69.55078 1260000 10001 117181 18633 25.943544387817383 470000 0 0 10001 16900 18633 0 0 126.95777 2300000 10001 24315 18633 49.67912673950195 900000 -215.2762 -3900000 10001 190860 18633 35.87936782836914 650000 -35.879368 -650000 10001 19986 18633 51.33509826660156 930000 -154.5573 -2800000 10001 6150 18633 -87.21446990966797 -1580000 0 0 10001 750 18633 28.151504516601563 510000 -193.1966 -3500000 10001 12366 18633 -44.15922546386719 -800000 -91.0784 -1650000 10001 58062 18633 0 0 218.0362 3950000 10001 16900 18634 126.95777130126953 2300000 0 0 10001 19986 18634 -154.55728149414062 -2800000 51.3351 930000 10001 12366 18634 -91.07839965820313 -1650000 -44.15923 -800000 10001 119324 18634 69.55078125 1260000 -27.047525 -490000 10001 58062 18634 102.11821365356445 1850000 0 0 10001 24315 18634 -176.63690948486328 -3200000 49.67913 900000 10001 190860 18634 0 0 35.879368 650000 10001 6150 18634 0 0 -87.21447 -1580000 10001 117181 18634 0 0 25.943544 470000 10001 750 18634 -193.1966094970703 -3500000 28.151505 510000 48486 157100 18630 0 0 -179.94884 -3260000 48486 114744 18630 0 0 828.6754 6020000 48486 30 18630 0 0 -875.7326 -4480000 48486 206461 18630 126.95777130126953 2300000 -750.0168 -800000 48486 735988 18630 44.71121597290039 810000 121.98987 2210000 48486 141006 18630 0 0 -74.51869 -1350000 48486 6032435 18630 68.99878692626953 1250000 678.9481 2400000 48486 93037 18630 70.10276794433594 1270000 -508.5901 -1170000 48486 134071 18630 0 0 560.7532 1290000 48486 224297 18630 69.55078125 1260000 736.769 2210000 48486 96331 18630 0 0 1007.1063 4220000 48486 340026 18630 0 0 -176.6369 -3200000 48486 2843432 18630 91.07839965820313 1650000 818.6706 2250000 48486 8832 18630 0 0 565.79004 2000000 48486 1996036 18630 0 0 -720.3474 -1500000 48486 471167 18630 0 0 -17.663689 -320000 48486 107866 18630 0 0 594.0795 2100000 48486 341814 18630 0 0 -786.4482 -2780000 48486 37259331 18630 -24.287572860717773 -440000 -1557.0267 1080000 48486 205836 18630 0 0 -704.4086 -2490000 48486 2538329 18630 221.34811401367187 4010000 -1645.483 -3410000 48486 494176 18630 0 0 -87.21447 -1580000 48486 21538876 18630 -205.8923797607422 -3730000 -902.6422 560000 48486 603629 18630 0 0 -672.0482 -3100000 48486 13728 18630 0 0 -1402.4695 -2720000 48486 78400 18630 0 0 0 0 48486 1629980 18630 0 0 -777.9614 -2750000 48486 667007 18630 80.0385971069336 1450000 185.46873 3360000 48486 2407336 18630 -57.958980560302734 -1050000 771.7514 -250000 48486 6905562 18630 0 0 0 0 48486 341814 18631 0 0 0 0 48486 96331 18631 40.295291900634766 730000 0 0 48486 37259331 18631 -195.40457344055176 -3540000 -24.28757 -440000 48486 21538876 18631 0 0 -205.8924 -3730000 48486 30 18631 -71.75873565673828 -1300000 0 0 48486 93037 18631 27.047523498535156 490000 70.10277 1270000 48486 2843432 18631 0 0 91.0784 1650000 end format %td date
ssc install fre sysuse nlsw88, clear keep if industry>8 fre industry return list mat M = r(valid) forval i = 1/`=rowsof(M)' { local counts `counts' `=M[`i',1]' } display "`counts'" local n : word count `counts' forvalues i = 1/`n' { local part1 : word `i' of `r(lab_valid)' local part2 : word `i' of `counts' if `i'!= `n' { local summary `summary' `"`part1' (`part2'); "' } else { local summary `summary' `"`part1' (`part2')"' } } macro list _summary
. sysuse nlsw88, clear (NLSW, 1988 extract) . . keep if industry>8 (1,118 observations deleted) . . fre industry industry -- industry ------------------------------------------------------------------------------ | Freq. Percent Valid Cum. ---------------------------------+-------------------------------------------- Valid 9 Personal Services | 97 8.60 8.71 8.71 10 Entertainment/Rec Svc | 17 1.51 1.53 10.23 11 Professional Services | 824 73.05 73.97 84.20 12 Public Administration | 176 15.60 15.80 100.00 Total | 1114 98.76 100.00 Missing . | 14 1.24 Total | 1128 100.00 ------------------------------------------------------------------------------ . . return list scalars: r(N) = 1128 r(N_valid) = 1114 r(N_missing) = 14 r(r) = 5 r(r_valid) = 4 r(r_missing) = 1 macros: r(depvar) : "industry" r(label) : "industry" r(lab_valid) : "`"9 Personal Services"' `"10 Entertainment/Rec Svc"' `"11 Professional Services"' `"12 Public Administration"'" r(lab_missing) : "`"."'" matrices: r(valid) : 4 x 1 r(missing) : 1 x 1 . . mat M = r(valid) . forval i = 1/`=rowsof(M)' { 2. local counts `counts' `=M[`i',1]' 3. } . display "`counts'" 97 17 824 176 . . local n : word count `counts' . . forvalues i = 1/`n' { 2. local part1 : word `i' of `r(lab_valid)' 3. local part2 : word `i' of `counts' 4. if `i'!= `n' { 5. local summary `summary' `"`part1' (`part2'); "' 6. } 7. else { 8. local summary `summary' `"`part1' (`part2')"' 9. } 10. } . . macro list _summary _summary: 9 Personal Services (97); `"10 Entertainment/Rec Svc (17); "' `"11 Professional Services (824); "' `"12 Public Administration (176)"'
_summary: 9 Personal Services (97); 10 Entertainment/Rec Svc (17); 11 Professional Services (824); 12 Public Administration (176)
* Example generated by -dataex-. To install: ssc install dataex clear input byte(id visit) int(date_of_surgery date_postop) byte(iop fail) float td byte(_st _d) int _origin byte(_t _t0) 1 1 21640 21642 15 . 2 1 0 21640 2 0 1 2 21640 21643 19 0 3 1 0 21640 3 2 1 3 21640 21644 17 . 4 1 0 21640 4 3 1 4 21640 21645 19 0 5 1 0 21640 5 4 2 1 21645 21646 16 . 1 1 0 21645 1 0 2 2 21645 21647 20 . 2 1 0 21645 2 1 2 3 21645 21648 20 1 3 1 1 21645 3 2 2 4 21645 21649 12 . . 0 . 21645 . . 3 1 21640 21650 13 . 10 1 0 21640 10 0 3 2 21640 21651 13 . 11 1 0 21640 11 10 3 3 21640 21652 15 . 12 1 0 21640 12 11 end format %tdnn/dd/CCYY date_of_surgery format %tdnn/dd/CCYY date_postop
bysort id (year) : replace Birth = Birth[_n-1] if Birth == -8|-5