This is going to be a long shot but i'll try anyway. I want to build a centile (100 groups) or decile (10 groups) based on the data.frame available. In this example, I have a data frame with 891 records. In this data.frame, I have the following variables.
- Unique_ID (numerical). i.e. unique member number
- xbeta (numerical) Given credit score. (which allows ranking to be performed)
- Good (numerical). Binary Flag (0 or 1). An indicator if member is delinquent
- Bad (numerical). Binary Flag (0 or 1) inverse of good
I need your help to build an equivalent table below. By changing the number of groups, i'd be able to split it either 10 or by 100 using xbeta. With the top row being the total (identifiable via TYPE), i'd like to produce the following table (see table below for more details)
- r_xbeta is just row number based on the # of groups.
- TYPE to identify total or group rank
- n = Total Count
- count of Good | Bad flag within the rank
- xbeta stats, min | max | mean | median
- GB_Odds = GOOD / BAD for the rank
- LN_GB_ODDs = Log(GB_Odds)
- rest should be self explanatory
Your help is much appreciated. Jim learning R
r_xbeta _TYPE_ n GOOD BAD xbeta_min xbeta_max xbeta_mean xbeta_MEDIAN GB_ODDS LN_GB_ODDS Cummu_Good Cummu_Bad Cummu_Good_pct Cummu_Bad_pct . 0 891 342 549 -4.42 3.63 -0.7 -1.09 0.62295 -0.47329 342 549 100% 100% 0 1 89 4 85 -4.42 -2.7 -3.6 -3.57 0.04706 -3.05636 4 85 1.20% 15% 1 1 89 12 77 -2.69 -2.37 -2.55 -2.54 0.15584 -1.8589 16 162 4.70% 30% 2 1 87 12 75 -2.35 -1.95 -2.16 -2.2 0.16 -1.83258 28 237 8.20% 43% 3 1 93 14 79 -1.95 -1.54 -1.75 -1.79 0.17722 -1.73039 42 316 12% 58% 4 1 88 10 78 -1.53 -1.09 -1.33 -1.33 0.12821 -2.05412 52 394 15% 72% 5 1 89 27 62 -1.03 -0.25 -0.67 -0.69 0.43548 -0.8313 79 456 23% 83% 6 1 89 44 45 -0.24 0.33 0.05 0.03 0.97778 -0.02247 123 501 36% 91% 7 1 89 54 35 0.37 1.07 0.66 0.63 1.54286 0.43364 177 536 52% 98% 8 1 88 77 11 1.08 2.15 1.56 1.5 7 1.94591 254 547 74% 100% 9 1 90 88 2 2.18 3.63 2.77 2.76 44 3.78419 342 549 100% 100%