r-statistics-fanの日記

統計好きの現場の臨床医の覚書のようなもの

受験番号と合格率の関係

2016年4月3日20:20念のため追記。言うまでもなく受験番号から合格への直接的因果関係はないからね。統計上有意ですが、単なる見かけ上の関係です。間違っても受験番号1ゲットなどという不毛なことを目指さないように。追記終了

すでに、旬は終わっているが、かつての上司のお子さんの合否が気になり 大学のサイトをみたものの、当たり前だが合格した人の受験番号しか書かれてなくて 合否は分からず。 その時に合格した受験番号だけダウンロードしておいた。

これを使って遊んでみる。

受験番号が若いほど合格率が高いのではないか?と気になったのである。 受付開始と同時に願書を出す人と、、ぎりぎりまで悩んだ人とでは 多分学力が違いそうという仮説である。

まずは元データの再現

hist.goukaku <- function(x, bw = 10){
      check.ok <- function(y){any(x == y)}
      goukaku <- sapply(range(x)[1]:range(x)[2], check.ok)
      hist(x, breaks = seq(range(x)[1], (2 + range(x)[2] %/% bw) * bw, by= bw))
}

###
sougouningen_bunkei <- c(1, 2, 6, 8, 12, 13, 14, 15, 16, 21, 25, 29, 30, 32, 33, 35, 
                  37, 44, 49, 55, 56, 61, 63, 65, 69, 70, 72, 74, 75, 76, 83, 89, 
                  90, 92, 94, 106, 107, 116, 118, 119, 125, 126, 131, 141, 146, 
                  147, 148, 149, 150, 154, 156, 159, 163, 165, 169, 174, 178, 182, 
                  185, 187, 195, 207, 209, 211, 217)

sougouningen_rikei <- c(3007, 3011, 3012, 3013, 3015, 3016, 3020, 3021, 3024, 3025, 
                        3032, 3034, 3037, 3039, 3041, 3042, 3043, 3044, 3049, 3052, 3057, 
                        3061, 3063, 3073, 3076, 3078, 3083, 3091, 3092, 3093, 3095, 3097, 
                        3101, 3103, 3104, 3106, 3109, 3110, 3112, 3113, 3128, 3131, 3132, 
                        3139, 3148, 3151, 3155, 3158, 3159, 3160, 3164, 3169, 3186, 3187
)

igaku <- c(1, 3, 4, 5, 7, 8, 9, 15, 16, 24, 25, 27, 33, 40, 47, 48, 54, 
                  58, 59, 61, 62, 67, 69, 71, 74, 75, 78, 79, 83, 84, 85, 86, 88, 
                  89, 90, 94, 97, 99, 100, 102, 103, 104, 105, 111, 113, 114, 115, 
                  116, 118, 125, 131, 132, 133, 134, 141, 143, 145, 146, 147, 151, 
                  152, 153, 155, 156, 158, 162, 165, 168, 169, 170, 171, 172, 179, 
                  185, 187, 188, 190, 192, 195, 197, 198, 201, 202, 203, 206, 207, 
                  209, 210, 211, 214, 219, 223, 224, 225, 226, 227, 230, 233, 235, 
                  237, 242, 245, 248, 256, 258, 270, 272, 276, 278, 294, 304, 314
)

bungaku <- c(1, 6, 8, 10, 12, 13, 14, 16, 18, 22, 23, 25, 26, 29, 31, 33, 
             34, 35, 37, 41, 42, 43, 45, 51, 52, 54, 55, 56, 57, 58, 61, 62, 
             63, 65, 66, 69, 72, 75, 77, 85, 86, 91, 94, 98, 101, 103, 104, 
             107, 110, 112, 114, 126, 132, 135, 136, 137, 138, 139, 141, 148, 
             155, 156, 159, 161, 165, 167, 168, 169, 170, 171, 172, 179, 180, 
             181, 185, 186, 194, 195, 196, 197, 200, 204, 205, 206, 208, 209, 
             211, 214, 215, 216, 222, 223, 226, 228, 229, 230, 234, 237, 238, 
             239, 246, 251, 253, 254, 255, 256, 258, 261, 264, 265, 269, 273, 
             281, 286, 290, 300, 302, 303, 305, 306, 307, 308, 310, 311, 315, 
             317, 322, 323, 329, 331, 332, 336, 337, 338, 339, 340, 345, 352, 
             353, 357, 359, 361, 363, 364, 366, 367, 372, 375, 376, 378, 382, 
             383, 393, 397, 399, 405, 406, 407, 411, 423, 425, 426, 428, 432, 
             434, 436, 438, 446, 448, 449, 450, 454, 456, 457, 460, 461, 463, 
             464, 470, 477, 481, 484, 487, 491, 493, 494, 495, 502, 505, 507, 
             508, 512, 513, 515, 516, 519, 522, 524, 528, 532, 535, 537, 538, 
             540, 551, 557, 562, 563, 568, 578, 580, 595, 598, 612, 613, 614
)

kyoiku_bunkei <- c(1, 2, 3, 4, 8, 11, 14, 15, 18, 19, 20, 21, 24, 25, 26, 28, 
                   35, 36, 37, 38, 39, 41, 42, 44, 48, 50, 54, 60, 63, 64, 68, 69, 
                   72, 80, 82, 83, 86, 95, 96, 99, 101, 104, 110, 114, 124, 128, 
                   136)

kyoiku_rikei <- c(3001, 3003, 3007, 3008, 3015, 3016, 3018, 3022, 3028, 3038)

hougaku <- c(1, 3, 4, 5, 9, 11, 12, 18, 20, 23, 24, 27, 29, 36, 37, 38, 
             39, 40, 41, 43, 44, 46, 48, 50, 51, 52, 53, 55, 57, 59, 68, 70, 
             71, 76, 78, 81, 82, 84, 85, 86, 87, 88, 89, 90, 93, 94, 95, 96, 
             97, 98, 99, 100, 102, 103, 104, 105, 107, 108, 109, 112, 116, 
             117, 123, 124, 125, 128, 133, 134, 136, 137, 139, 141, 145, 146, 
             149, 150, 152, 153, 155, 156, 161, 162, 163, 167, 168, 172, 175, 
             177, 180, 182, 183, 184, 185, 189, 191, 192, 193, 195, 196, 197, 
             202, 206, 210, 212, 213, 216, 219, 222, 224, 225, 228, 229, 232, 
             234, 238, 240, 244, 246, 248, 249, 250, 251, 253, 254, 255, 256, 
             257, 258, 259, 260, 262, 263, 264, 265, 266, 267, 269, 270, 272, 
             275, 277, 279, 283, 284, 289, 290, 295, 296, 297, 300, 302, 303, 
             304, 305, 306, 311, 312, 315, 316, 318, 319, 321, 323, 324, 325, 
             326, 332, 334, 336, 338, 339, 342, 343, 345, 350, 351, 353, 355, 
             356, 359, 360, 362, 363, 364, 365, 367, 368, 370, 371, 372, 373, 
             374, 376, 379, 382, 383, 386, 387, 389, 390, 392, 393, 399, 400, 
             401, 403, 404, 407, 410, 411, 412, 421, 424, 428, 433, 435, 440, 
             441, 442, 444, 446, 448, 450, 451, 452, 457, 462, 463, 464, 467, 
             479, 480, 484, 486, 487, 488, 507, 517, 519, 528, 531, 537, 538, 
             540, 541, 543, 548, 550, 562, 563, 577, 580, 582, 595, 598, 599, 
             600, 602, 603, 605, 610, 625, 627, 629, 632, 636, 638, 639, 641, 
             645, 649, 652, 654, 655, 656, 663, 666, 673, 674, 682, 686, 693, 
             694, 695, 697, 698, 705, 709, 712, 718, 721, 722, 726, 728, 729, 
             737, 742, 746, 748, 752, 753, 755, 760, 761, 764, 766, 776, 787, 
             789, 801, 804, 814)
      
keizai_bunkei <- c(2, 3, 6, 7, 9, 11, 17, 19, 20, 22, 24, 28, 30, 31, 36, 37, 
                   40, 41, 44, 45, 46, 47, 48, 50, 51, 52, 58, 59, 60, 62, 65, 66, 
                   67, 68, 69, 70, 72, 73, 74, 75, 77, 79, 80, 81, 82, 86, 89, 90, 
                   91, 92, 93, 94, 96, 97, 102, 103, 104, 105, 106, 107, 108, 109, 
                   110, 111, 112, 113, 114, 116, 118, 123, 124, 125, 128, 130, 131, 
                   132, 134, 135, 137, 142, 144, 145, 148, 149, 160, 163, 165, 168, 
                   169, 170, 171, 181, 183, 187, 188, 191, 193, 194, 197, 198, 200, 
                   201, 203, 204, 206, 215, 218, 219, 223, 224, 225, 229, 232, 236, 
                   239, 240, 244, 245, 246, 247, 252, 255, 256, 259, 261, 264, 273, 
                   274, 278, 279, 280, 281, 282, 284, 286, 289, 290, 296, 299, 303, 
                   305, 309, 310, 312, 319, 320, 321, 322, 324, 325, 326, 327, 332, 
                   336, 338, 340, 346, 349, 357, 360, 363, 370, 374, 378, 380, 384, 
                   388, 391, 393, 394, 400, 401, 402, 405, 406, 410, 414, 415, 416, 
                   419, 421, 429, 433, 436, 442, 447, 450, 452, 462, 468)

keizai_rikei <- c(4002, 4003, 4005, 4006, 4024, 4031, 4033, 4040, 4042, 4045, 
                  4046, 4051, 4054, 4055, 4058, 4059, 4071, 4072, 4081, 4084, 4097, 
                  4102, 4110, 4112, 4131)

rigaku <- c(1, 3, 9, 10, 11, 12, 14, 15, 17, 22, 24, 26, 32, 35, 36, 37, 
            39, 41, 43, 44, 45, 46, 50, 51, 55, 56, 58, 59, 61, 62, 63, 67, 
            68, 72, 75, 76, 77, 82, 83, 85, 86, 93, 97, 101, 102, 103, 104, 
            105, 110, 111, 113, 117, 119, 120, 123, 124, 126, 127, 128, 129, 
            130, 132, 133, 134, 135, 139, 140, 145, 147, 148, 150, 151, 153, 
            154, 156, 157, 160, 162, 164, 165, 171, 172, 174, 178, 181, 182, 
            183, 184, 185, 187, 189, 190, 192, 193, 196, 197, 199, 200, 202, 
            203, 204, 206, 207, 218, 219, 222, 229, 230, 233, 234, 236, 238, 
            239, 240, 241, 242, 254, 256, 258, 263, 264, 265, 267, 268, 271, 
            277, 281, 283, 286, 287, 289, 290, 292, 298, 299, 304, 307, 310, 
            312, 314, 316, 317, 318, 321, 322, 324, 326, 327, 328, 332, 334, 
            336, 340, 341, 342, 343, 345, 351, 352, 354, 357, 358, 360, 361, 
            363, 365, 366, 372, 375, 380, 381, 384, 385, 386, 388, 389, 391, 
            392, 393, 394, 395, 400, 402, 408, 409, 413, 414, 415, 420, 423, 
            429, 432, 436, 440, 449, 451, 453, 454, 458, 463, 469, 473, 474, 
            475, 476, 478, 481, 482, 484, 485, 493, 500, 509, 517, 522, 524, 
            526, 533, 536, 540, 541, 542, 551, 555, 557, 559, 564, 565, 569, 
            573, 574, 579, 580, 582, 590, 592, 596, 604, 605, 607, 608, 610, 
            613, 616, 618, 620, 624, 627, 633, 634, 635, 636, 637, 644, 651, 
            653, 655, 656, 657, 661, 669, 670, 672, 673, 676, 679, 680, 683, 
            684, 687, 689, 690, 692, 693, 696, 698, 700, 701, 706, 707, 711, 
            721, 722, 728, 732, 734, 735, 739, 741, 742, 745, 754, 758, 760, 
            766, 769, 772, 774, 781, 788, 791, 798, 799, 804, 809, 810, 822, 
            824, 827, 829)

kango <- c(2001, 2002, 2003, 2010, 2013, 2015, 2016, 2017, 2018, 2020, 
           2021, 2023, 2025, 2027, 2031, 2033, 2034, 2035, 2036, 2037, 2038, 
           2039, 2040, 2042, 2043, 2044, 2046, 2047, 2048, 2049, 2050, 2052, 
           2053, 2055, 2056, 2057, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 
           2071, 2075, 2078, 2079, 2080, 2088, 2091, 2094, 2095, 2096, 2097, 
           2098, 2100, 2101, 2102, 2105, 2106, 2107, 2110, 2113, 2114, 2115, 
           2117, 2118, 2120, 2123, 2124, 2125, 2129, 2131)

kensagijutu <- c(4001, 4002, 4005, 4006, 4008, 4012, 4013, 4014, 4016, 4017, 
                 4019, 4023, 4025, 4027, 4029, 4031, 4034, 4036, 4037, 4041, 4044, 
                 4048, 4049, 4050, 4053, 4054, 4055, 4057, 4058, 4066, 4068, 4070, 
                 4071, 4072, 4076, 4077, 4081, 4084, 4085)

rigakuryouhou <- c(5002, 5003, 5005, 5006, 5007, 5008, 5009, 5012, 5014, 5015, 
                   5019, 5020, 5025, 5029, 5032, 5033, 5034, 5036)
      
sagyouryouhou <- c(6001, 6002, 6003, 6004, 6005, 6006, 6007, 6009, 6010, 6011, 
                   6012, 6015, 6018, 6019, 6021, 6022, 6024, 6025)

yakka <- c(1, 3, 7, 8, 9, 10, 11, 12, 15, 17, 19, 20, 25, 26, 27, 29, 
           31, 32, 34, 37, 39, 46, 49, 50, 51, 52, 55, 56, 57, 59, 60, 62, 
           64, 67, 69, 72, 73, 78, 83, 89, 91, 92, 93, 97, 102, 103, 107, 
           110, 113, 116, 117, 119, 121)

yakugaku <- c(3001, 3003, 3004, 3005, 3007, 3008, 3010, 3013, 3014, 3016, 
              3018, 3020, 3021, 3023, 3025, 3027, 3028, 3031, 3032, 3036, 3040, 
              3043, 3044, 3047, 3048, 3050, 3054, 3057, 3058, 3059, 3067)

kougaku <- c(5, 6, 10, 16, 21, 22, 23, 26, 28, 30, 32, 36, 44, 45, 46, 48, 
             50, 51, 52, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 66, 71, 73, 
             80, 85, 86, 87, 88, 89, 94, 98, 99, 101, 106, 108, 109, 112, 
             113, 114, 115, 116, 118, 119, 120, 122, 124, 129, 130, 132, 133, 
             137, 138, 142, 143, 147, 148, 156, 157, 160, 161, 164, 167, 171, 
             172, 179, 185, 191, 192, 193, 196, 198, 200, 203, 207, 209, 211, 
             212, 213, 221, 227, 231, 232, 234, 239, 243, 247, 249, 250, 253, 
             254, 255, 257, 259, 262, 264, 265, 270, 274, 275, 277, 278, 282, 
             285, 292, 293, 298, 303, 304, 305, 306, 311, 313, 316, 317, 318, 
             319, 320, 321, 323, 329, 331, 332, 333, 341, 344, 345, 346, 347, 
             348, 349, 350, 353, 354, 357, 358, 359, 360, 361, 362, 363, 368, 
             369, 372, 373, 374, 377, 381, 383, 385, 387, 388, 390, 391, 397, 
             400, 401, 403, 404, 406, 407, 409, 412, 414, 418, 421, 423, 425, 
             426, 430, 432, 433, 436, 437, 438, 439, 450, 453, 454, 458, 459, 
             462, 463, 465, 466, 467, 471, 478, 485, 487, 490, 491, 496, 497, 
             499, 500, 501, 503, 504, 510, 511, 514, 515, 517, 518, 521, 527, 
             530, 532, 533, 536, 542, 545, 549, 550, 555, 558, 560, 562, 563, 
             565, 566, 568, 571, 575, 579, 582, 585, 586, 587, 588, 589, 593, 
             594, 607, 613, 616, 622, 624, 628, 629, 630, 631, 635, 636, 637, 
             638, 643, 645, 647, 651, 652, 654, 655, 657, 659, 661, 662, 665, 
             669, 671, 672, 673, 678, 680, 681, 696, 698, 700, 704, 707, 708, 
             711, 712, 714, 718, 719, 720, 722, 723, 728, 729, 731, 732, 734, 
             737, 738, 740, 741, 742, 743, 745, 747, 748, 750, 753, 756, 760, 
             761, 762, 766, 767, 769, 770, 773, 774, 777, 778, 781, 787, 791, 
             795, 797, 801, 802, 813, 815, 817, 818, 822, 825, 828, 830, 834, 
             838, 840, 841, 842, 843, 845, 846, 848, 852, 854, 855, 857, 858, 
             859, 866, 867, 872, 873, 874, 875, 876, 877, 878, 881, 884, 885, 
             888, 889, 890, 892, 895, 897, 899, 901, 902, 908, 909, 910, 913, 
             914, 915, 916, 917, 918, 919, 922, 923, 927, 929, 932, 936, 938, 
             939, 945, 946, 949, 950, 952, 955, 958, 968, 970, 971, 973, 976, 
             979, 984, 985, 988, 989, 992, 993, 994, 998, 999, 1001, 1002, 
             1003, 1007, 1013, 1014, 1016, 1017, 1018, 1020, 1021, 1024, 1026, 
             1028, 1029, 1034, 1035, 1040, 1041, 1043, 1045, 1048, 1051, 1052, 
             1053, 1058, 1062, 1063, 1076, 1078, 1079, 1083, 1084, 1088, 1090, 
             1091, 1092, 1101, 1102, 1106, 1110, 1112, 1116, 1117, 1118, 1122, 
             1123, 1124, 1126, 1127, 1128, 1129, 1130, 1131, 1133, 1136, 1138, 
             1139, 1140, 1142, 1144, 1145, 1149, 1151, 1152, 1156, 1166, 1168, 
             1169, 1170, 1174, 1176, 1185, 1189, 1191, 1194, 1195, 1197, 1199, 
             1203, 1206, 1208, 1214, 1220, 1221, 1223, 1224, 1225, 1226, 1230, 
             1231, 1234, 1235, 1240, 1252, 1253, 1255, 1256, 1257, 1258, 1261, 
             1262, 1265, 1266, 1267, 1268, 1273, 1274, 1275, 1277, 1278, 1279, 
             1283, 1293, 1294, 1296, 1302, 1303, 1306, 1309, 1311, 1312, 1313, 
             1314, 1317, 1318, 1319, 1320, 1321, 1324, 1326, 1329, 1330, 1331, 
             1332, 1336, 1338, 1339, 1340, 1341, 1342, 1347, 1349, 1351, 1352, 
             1353, 1354, 1355, 1356, 1360, 1362, 1366, 1367, 1370, 1373, 1374, 
             1375, 1378, 1385, 1386, 1387, 1390, 1391, 1393, 1399, 1400, 1403, 
             1404, 1408, 1409, 1411, 1417, 1418, 1421, 1425, 1428, 1431, 1432, 
             1433, 1437, 1440, 1441, 1444, 1452, 1456, 1465, 1466, 1467, 1468, 
             1478, 1479, 1482, 1484, 1485, 1489, 1496, 1497, 1499, 1500, 1505, 
             1512, 1513, 1515, 1516, 1520, 1522, 1525, 1527, 1531, 1536, 1539, 
             1544, 1546, 1551, 1558, 1560, 1562, 1565, 1566, 1568, 1569, 1577, 
             1579, 1580, 1583, 1588, 1600, 1606, 1609, 1616, 1617, 1618, 1622, 
             1624, 1628, 1634, 1639, 1644, 1645, 1646, 1652, 1654, 1655, 1660, 
             1669, 1671, 1676, 1677, 1685, 1686, 1689, 1690, 1691, 1692, 1693, 
             1704, 1706, 1710, 1714, 1715, 1720, 1721, 1724, 1725, 1727, 1733, 
             1735, 1737, 1738, 1741, 1745, 1746, 1750, 1751, 1753, 1754, 1755, 
             1756, 1761, 1763, 1764, 1766, 1767, 1769, 1772, 1774, 1783, 1796, 
             1797, 1798, 1804, 1805, 1806, 1807, 1811, 1813, 1814, 1820, 1822, 
             1827, 1828, 1830, 1831, 1838, 1840, 1841, 1842, 1846, 1851, 1855, 
             1856, 1857, 1859, 1860, 1864, 1865, 1875, 1876, 1877, 1882, 1883, 
             1886, 1888, 1889, 1896, 1897, 1903, 1915, 1916, 1917, 1920, 1921, 
             1922, 1928, 1931, 1932, 1935, 1946, 1952, 1962, 1963, 1964, 1965, 
             1967, 1969, 1972, 1973, 1974, 1975, 1977, 1981, 1983, 1985, 1987, 
             1990, 1991, 1992, 1994, 1996, 1997, 1999, 2017, 2023, 2026, 2027, 
             2028, 2036, 2038, 2046, 2048, 2050, 2055, 2058, 2059, 2061, 2063, 
             2068, 2069, 2073, 2074, 2075, 2076, 2077, 2083, 2084, 2086, 2090, 
             2092, 2093, 2100, 2103, 2104, 2105, 2107, 2109, 2110, 2112, 2115, 
             2119, 2120, 2124, 2127, 2129, 2131, 2132, 2134, 2141, 2144, 2148, 
             2154, 2156, 2165, 2170, 2171, 2172, 2177, 2186, 2190, 2192, 2193, 
             2197, 2198, 2200, 2204, 2205, 2208, 2210, 2221, 2225, 2231, 2232, 
             2237, 2241, 2242, 2243, 2251, 2261, 2265, 2266, 2267, 2269, 2274, 
             2287, 2291, 2292, 2295, 2298, 2300, 2304, 2305, 2312, 2316, 2319, 
             2320, 2323, 2324, 2326, 2329, 2330, 2333, 2334, 2336, 2340, 2357, 
             2358, 2359, 2360, 2362, 2364, 2365, 2367, 2372, 2375, 2381, 2383, 
             2384, 2386, 2390, 2394, 2397, 2406, 2414, 2415, 2420, 2421, 2429, 
             2438, 2439, 2441, 2443, 2446, 2449, 2452, 2455, 2459, 2466, 2474, 
             2475, 2486, 2487, 2489, 2492, 2493, 2495, 2515, 2516, 2522, 2524, 
             2529, 2537, 2540, 2545, 2553, 2558, 2559, 2571, 2581, 2585, 2591, 
             2596, 2597, 2607, 2613, 2616, 2621, 2623, 2630, 2643, 2647, 2651, 
             2652, 2667, 2691, 2705, 2716, 2723, 2725, 2727)

kougaku_gakka <- structure(c(3L, 3L, 4L, 6L, 6L, 6L, 6L, 1L, 1L, 1L, 1L, 2L, 1L, 
                             3L, 6L, 3L, 3L, 3L, 3L, 3L, 3L, 6L, 3L, 1L, 3L, 4L, 1L, 3L, 1L, 
                             4L, 5L, 6L, 1L, 2L, 2L, 2L, 2L, 3L, 1L, 2L, 2L, 2L, 1L, 3L, 1L, 
                             3L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 3L, 3L, 1L, 6L, 3L, 1L, 4L, 
                             6L, 6L, 6L, 5L, 4L, 4L, 6L, 3L, 3L, 3L, 6L, 6L, 6L, 5L, 6L, 6L, 
                             6L, 6L, 1L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 6L, 6L, 6L, 5L, 5L, 
                             4L, 1L, 2L, 2L, 4L, 4L, 4L, 6L, 4L, 6L, 3L, 1L, 1L, 1L, 1L, 1L, 
                             2L, 2L, 2L, 6L, 3L, 3L, 2L, 2L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 
                             3L, 3L, 3L, 3L, 4L, 4L, 4L, 1L, 6L, 6L, 5L, 3L, 3L, 3L, 1L, 4L, 
                             4L, 5L, 5L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 5L, 4L, 6L, 6L, 3L, 
                             6L, 3L, 1L, 3L, 3L, 6L, 3L, 3L, 3L, 3L, 3L, 3L, 5L, 3L, 3L, 5L, 
                             1L, 4L, 3L, 3L, 5L, 5L, 4L, 3L, 3L, 1L, 4L, 6L, 3L, 1L, 3L, 3L, 
                             5L, 5L, 5L, 5L, 5L, 6L, 2L, 6L, 4L, 4L, 4L, 4L, 4L, 3L, 3L, 3L, 
                             3L, 1L, 4L, 4L, 4L, 6L, 6L, 6L, 1L, 5L, 5L, 1L, 1L, 2L, 6L, 6L, 
                             1L, 6L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 6L, 3L, 4L, 6L, 6L, 6L, 6L, 
                             6L, 5L, 1L, 5L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 
                             2L, 2L, 1L, 1L, 6L, 3L, 6L, 1L, 3L, 3L, 3L, 3L, 6L, 6L, 5L, 6L, 
                             5L, 1L, 4L, 4L, 4L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 3L, 6L, 
                             3L, 3L, 3L, 3L, 6L, 1L, 4L, 3L, 3L, 6L, 6L, 3L, 3L, 6L, 1L, 3L, 
                             3L, 4L, 4L, 4L, 4L, 6L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 1L, 3L, 3L, 
                             5L, 1L, 6L, 6L, 6L, 6L, 6L, 1L, 3L, 3L, 1L, 1L, 6L, 3L, 1L, 3L, 
                             3L, 3L, 1L, 4L, 4L, 4L, 4L, 6L, 6L, 6L, 6L, 6L, 6L, 1L, 3L, 3L, 
                             3L, 3L, 3L, 3L, 1L, 3L, 3L, 3L, 3L, 6L, 3L, 3L, 3L, 4L, 4L, 6L, 
                             6L, 6L, 6L, 2L, 2L, 3L, 3L, 3L, 1L, 1L, 5L, 4L, 4L, 4L, 4L, 6L, 
                             6L, 6L, 5L, 5L, 1L, 6L, 3L, 6L, 3L, 3L, 6L, 6L, 6L, 6L, 3L, 4L, 
                             3L, 6L, 6L, 1L, 3L, 3L, 6L, 1L, 3L, 3L, 1L, 1L, 1L, 2L, 2L, 2L, 
                             3L, 3L, 3L, 3L, 3L, 6L, 3L, 4L, 4L, 6L, 6L, 6L, 4L, 4L, 4L, 4L, 
                             5L, 5L, 5L, 6L, 6L, 6L, 2L, 2L, 2L, 4L, 4L, 4L, 6L, 6L, 6L, 3L, 
                             3L, 1L, 3L, 1L, 3L, 1L, 4L, 3L, 3L, 6L, 3L, 6L, 3L, 6L, 3L, 6L, 
                             6L, 6L, 1L, 6L, 3L, 3L, 3L, 6L, 6L, 6L, 6L, 1L, 3L, 4L, 3L, 6L, 
                             2L, 2L, 5L, 3L, 3L, 3L, 1L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 3L, 
                             3L, 3L, 3L, 3L, 3L, 6L, 6L, 1L, 6L, 1L, 1L, 3L, 2L, 1L, 2L, 4L, 
                             6L, 6L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 6L, 5L, 5L, 1L, 1L, 1L, 
                             1L, 1L, 1L, 1L, 3L, 6L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 6L, 1L, 4L, 
                             5L, 6L, 6L, 6L, 6L, 6L, 6L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
                             3L, 3L, 6L, 3L, 3L, 3L, 3L, 6L, 6L, 5L, 1L, 4L, 4L, 4L, 4L, 4L, 
                             3L, 3L, 3L, 4L, 1L, 1L, 1L, 1L, 3L, 3L, 1L, 2L, 2L, 2L, 2L, 6L, 
                             2L, 1L, 1L, 6L, 6L, 6L, 6L, 6L, 5L, 3L, 3L, 6L, 4L, 5L, 5L, 6L, 
                             6L, 6L, 6L, 6L, 1L, 3L, 3L, 1L, 4L, 4L, 4L, 5L, 1L, 1L, 2L, 1L, 
                             1L, 1L, 1L, 3L, 3L, 4L, 6L, 1L, 1L, 1L, 1L, 2L, 4L, 5L, 5L, 1L, 
                             1L, 6L, 6L, 6L, 6L, 6L, 3L, 3L, 1L, 1L, 6L, 1L, 6L, 6L, 5L, 5L, 
                             5L, 6L, 1L, 3L, 1L, 1L, 1L, 5L, 5L, 1L, 5L, 3L, 4L, 3L, 6L, 1L, 
                             6L, 4L, 6L, 3L, 1L, 1L, 1L, 5L, 5L, 5L, 4L, 4L, 3L, 3L, 3L, 3L, 
                             3L, 3L, 1L, 3L, 6L, 3L, 3L, 6L, 1L, 6L, 6L, 6L, 5L, 5L, 5L, 4L, 
                             4L, 4L, 4L, 6L, 1L, 6L, 6L, 3L, 3L, 3L, 6L, 6L, 6L, 3L, 6L, 2L, 
                             2L, 3L, 1L, 3L, 3L, 3L, 4L, 4L, 4L, 2L, 2L, 2L, 1L, 2L, 1L, 3L, 
                             3L, 1L, 2L, 6L, 4L, 6L, 3L, 3L, 4L, 3L, 3L, 2L, 4L, 5L, 5L, 4L, 
                             4L, 6L, 4L, 3L, 6L, 3L, 4L, 6L, 4L, 5L, 5L, 4L, 3L, 3L, 6L, 3L, 
                             1L, 3L, 2L, 1L, 6L, 6L, 6L, 6L, 5L, 4L, 4L, 4L, 4L, 1L, 1L, 1L, 
                             1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 1L, 3L, 3L, 4L, 
                             4L, 4L, 4L, 3L, 6L, 1L, 3L, 1L, 6L, 6L, 6L, 3L, 3L, 3L, 3L, 6L, 
                             2L, 2L, 2L, 2L, 2L, 6L, 5L, 5L, 4L, 6L, 4L, 6L, 4L, 3L, 6L, 6L, 
                             6L, 1L, 3L, 1L, 1L, 6L, 6L, 5L, 5L, 2L, 1L, 1L, 1L, 4L, 5L, 5L, 
                             5L, 5L, 6L, 6L, 6L, 3L, 3L, 1L, 4L, 1L, 4L, 4L, 5L, 3L, 3L, 3L, 
                             5L, 4L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 4L, 1L, 6L, 6L, 6L, 6L, 6L, 
                             6L, 6L, 3L, 4L, 3L, 6L, 6L, 6L, 1L, 3L, 6L, 3L, 3L, 3L, 4L, 2L, 
                             6L, 5L, 5L, 3L, 6L, 4L, 1L, 1L, 6L, 4L, 1L, 1L, 6L, 6L, 6L, 1L, 
                             5L, 1L, 1L, 5L, 5L, 4L, 6L, 6L, 1L, 1L, 1L, 3L, 6L, 4L, 5L, 3L, 
                             4L, 6L, 4L, 5L, 6L, 6L, 3L, 6L, 3L, 1L, 1L, 1L, 3L, 1L, 3L, 4L, 
                             1L, 6L, 1L, 6L), .Label = c("A", "B", "C", "D", "E", "F"), 
                           class = "factor")

nougaku <- c(1, 3, 9, 11, 13, 14, 15, 16, 18, 20, 21, 22, 23, 24, 25, 28, 
             30, 35, 36, 38, 43, 52, 54, 55, 56, 60, 61, 63, 67, 69, 70, 71, 
             72, 76, 77, 78, 82, 83, 93, 95, 96, 97, 98, 100, 103, 106, 107, 
             109, 116, 119, 120, 123, 124, 128, 129, 130, 134, 142, 143, 145, 
             147, 149, 150, 151, 152, 154, 155, 158, 159, 163, 164, 166, 168, 
             172, 173, 175, 177, 178, 179, 182, 185, 186, 188, 189, 190, 194, 
             197, 198, 202, 205, 206, 207, 211, 212, 218, 219, 224, 225, 228, 
             231, 233, 236, 239, 244, 248, 249, 251, 252, 253, 256, 260, 261, 
             262, 266, 268, 271, 272, 274, 286, 291, 292, 296, 311, 316, 318, 
             319, 320, 325, 326, 329, 333, 334, 336, 337, 339, 347, 348, 350, 
             352, 353, 359, 366, 369, 371, 374, 376, 377, 378, 379, 381, 385, 
             386, 387, 391, 394, 395, 399, 400, 406, 407, 427, 428, 429, 432, 
             434, 435, 438, 441, 443, 447, 451, 452, 457, 460, 461, 463, 466, 
             468, 475, 478, 480, 482, 485, 486, 492, 495, 498, 501, 504, 505, 
             506, 510, 512, 521, 523, 525, 527, 531, 532, 533, 536, 538, 539, 
             542, 545, 546, 552, 553, 554, 558, 567, 569, 583, 584, 587, 589, 
             590, 591, 593, 595, 597, 598, 602, 603, 605, 609, 612, 613, 614, 
             618, 621, 624, 625, 626, 627, 634, 640, 642, 647, 649, 651, 652, 
             653, 654, 655, 660, 662, 663, 664, 665, 668, 669, 671, 672, 673, 
             676, 677, 680, 681, 683, 685, 686, 688, 692, 693, 695, 700, 701, 
             706, 707, 708, 713, 717, 720, 725, 727, 728, 731, 735, 736, 738, 
             745, 746, 748, 752, 754, 759, 760, 761, 765, 766, 770, 772, 773, 
             783, 785, 786, 791, 793, 805, 810, 819, 824, 826, 831, 833, 835, 
             842, 844, 845)

nougaku_gakka <- c(1, 3, 9, 11, 13, 14, 15, 16, 18, 20, 21, 22, 23, 24, 25, 28, 
                   30, 35, 36, 38, 43, 52, 54, 55, 56, 60, 61, 63, 67, 69, 70, 71, 
                   72, 76, 77, 78, 82, 83, 93, 95, 96, 97, 98, 100, 103, 106, 107, 
                   109, 116, 119, 120, 123, 124, 128, 129, 130, 134, 142, 143, 145, 
                   147, 149, 150, 151, 152, 154, 155, 158, 159, 163, 164, 166, 168, 
                   172, 173, 175, 177, 178, 179, 182, 185, 186, 188, 189, 190, 194, 
                   197, 198, 202, 205, 206, 207, 211, 212, 218, 219, 224, 225, 228, 
                   231, 233, 236, 239, 244, 248, 249, 251, 252, 253, 256, 260, 261, 
                   262, 266, 268, 271, 272, 274, 286, 291, 292, 296, 311, 316, 318, 
                   319, 320, 325, 326, 329, 333, 334, 336, 337, 339, 347, 348, 350, 
                   352, 353, 359, 366, 369, 371, 374, 376, 377, 378, 379, 381, 385, 
                   386, 387, 391, 394, 395, 399, 400, 406, 407, 427, 428, 429, 432, 
                   434, 435, 438, 441, 443, 447, 451, 452, 457, 460, 461, 463, 466, 
                   468, 475, 478, 480, 482, 485, 486, 492, 495, 498, 501, 504, 505, 
                   506, 510, 512, 521, 523, 525, 527, 531, 532, 533, 536, 538, 539, 
                   542, 545, 546, 552, 553, 554, 558, 567, 569, 583, 584, 587, 589, 
                   590, 591, 593, 595, 597, 598, 602, 603, 605, 609, 612, 613, 614, 
                   618, 621, 624, 625, 626, 627, 634, 640, 642, 647, 649, 651, 652, 
                   653, 654, 655, 660, 662, 663, 664, 665, 668, 669, 671, 672, 673, 
                   676, 677, 680, 681, 683, 685, 686, 688, 692, 693, 695, 700, 701, 
                   706, 707, 708, 713, 717, 720, 725, 727, 728, 731, 735, 736, 738, 
                   745, 746, 748, 752, 754, 759, 760, 761, 765, 766, 770, 772, 773, 
                   783, 785, 786, 791, 793, 805, 810, 819, 824, 826, 831, 833, 835, 
                   842, 844, 845)

nougaku_gakka <- structure(c(5L, 1L, 3L, 5L, 1L, 2L, 2L, 3L, 3L, 2L, 6L, 2L, 4L, 
            5L, 1L, 4L, 1L, 5L, 3L, 3L, 4L, 5L, 6L, 1L, 5L, 3L, 1L, 5L, 6L, 
            1L, 1L, 6L, 1L, 1L, 2L, 2L, 1L, 5L, 5L, 3L, 6L, 6L, 1L, 4L, 2L, 
            3L, 4L, 5L, 5L, 5L, 6L, 1L, 2L, 2L, 4L, 6L, 2L, 5L, 1L, 5L, 2L, 
            6L, 1L, 1L, 1L, 2L, 6L, 5L, 4L, 1L, 1L, 2L, 1L, 1L, 1L, 4L, 4L, 
            5L, 1L, 2L, 4L, 6L, 2L, 1L, 2L, 6L, 1L, 4L, 2L, 3L, 2L, 3L, 5L, 
            6L, 5L, 2L, 5L, 3L, 4L, 6L, 3L, 1L, 1L, 1L, 3L, 5L, 2L, 1L, 2L, 
            5L, 2L, 1L, 1L, 4L, 1L, 1L, 1L, 5L, 1L, 4L, 1L, 5L, 4L, 1L, 5L, 
            6L, 1L, 1L, 1L, 5L, 3L, 2L, 2L, 1L, 1L, 3L, 1L, 5L, 2L, 1L, 3L, 
            6L, 5L, 3L, 1L, 4L, 1L, 6L, 4L, 1L, 5L, 4L, 4L, 4L, 1L, 4L, 1L, 
            1L, 5L, 6L, 5L, 1L, 1L, 1L, 5L, 2L, 3L, 2L, 3L, 6L, 3L, 5L, 1L, 
            3L, 3L, 6L, 5L, 1L, 2L, 5L, 6L, 5L, 2L, 5L, 1L, 2L, 6L, 1L, 3L, 
            3L, 2L, 4L, 2L, 3L, 1L, 1L, 1L, 3L, 5L, 1L, 6L, 3L, 4L, 2L, 6L, 
            3L, 1L, 1L, 1L, 5L, 2L, 5L, 6L, 1L, 1L, 2L, 4L, 1L, 2L, 5L, 2L, 
            5L, 1L, 1L, 1L, 1L, 5L, 5L, 3L, 1L, 5L, 1L, 3L, 1L, 5L, 1L, 4L, 
            1L, 3L, 4L, 2L, 2L, 5L, 1L, 1L, 5L, 3L, 4L, 3L, 5L, 5L, 1L, 1L, 
            1L, 3L, 5L, 6L, 6L, 6L, 1L, 3L, 5L, 2L, 6L, 1L, 6L, 3L, 1L, 2L, 
            1L, 1L, 1L, 3L, 5L, 1L, 2L, 1L, 4L, 1L, 1L, 3L, 5L, 2L, 6L, 2L, 
            2L, 5L, 2L, 6L, 1L, 4L, 6L, 4L, 1L, 2L, 2L, 6L, 5L, 5L, 5L, 3L, 
            1L, 2L, 4L, 3L, 5L, 5L, 6L, 1L, 1L), 
          .Label = c("A", "B", "C", "D", "E", "F"), class = "factor")

これをデータフレーム化

name1 <- c("bungaku", "hougaku", "igaku", "kango", "keizai_bunkei", 
           "keizai_rikei", "kensagijutu", "kougaku", "kyoiku_bunkei", "kyoiku_rikei", 
           "nougaku", "rigaku", "rigakuryouhou", "sagyouryouhou", "sougouningen_bunkei", 
           "sougouningen_rikei", "yakka", "yakugaku")

hist.goukaku2 <- function(x, bw = 10){
      eval(parse(text = paste0("z <- ", x, sep="", collapse = "")))
      check.ok <- function(y){any(z == y)}
      goukaku <- sapply(range(z)[1]:range(z)[2], check.ok)
      hist(z, breaks = seq(range(z)[1], (2 + range(z)[2] %/% bw) * bw, by= bw))
}

data1 <- data.frame()   #data frame化
for(i in name1){
      eval(parse(text = paste0("tmp_data <-", i)))
      data_one <- tmp_data - (tmp_data[1] %/% 10) *10 #はじめの10人が連続不合格した学科はないと仮定
      #最後の受験番号は不明。最後と最後から二番目合格者の間の人数/2(切り上げ)を追加
      temp_length <- length(data_one)
      temp_delta <- data_one[temp_length] - data_one[temp_length - 1]
      ceiling(temp_delta / 2)
      num_one <- seq_len(max(data_one) + ceiling(temp_delta / 2))
      goukaku <- sapply(num_one, function(x)any(x == data_one))
      data_rate <- num_one / max(num_one)
      tmp <- data.frame(gakka = i, num_one = num_one, num_rate = data_rate, goukaku = goukaku)
      data1 <- rbind(data1, tmp)
}

まずは普通のロジスティック回帰

res_1 <- glm(goukaku ~ num_rate, data = data1, family = binomial(logit))
summary(res_1)
## 
## Call:
## glm(formula = goukaku ~ num_rate, family = binomial(logit), data = data1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.1564  -0.9665  -0.8186   1.3172   1.6730  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -0.04933    0.04627  -1.066    0.286    
## num_rate    -1.06729    0.08327 -12.817   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 10247  on 7833  degrees of freedom
## Residual deviance: 10079  on 7832  degrees of freedom
## AIC: 10083
## 
## Number of Fisher Scoring iterations: 4
res_2 <- glm(goukaku ~ num_one, data = data1, family = binomial(logit))
summary(res_2)
## 
## Call:
## glm(formula = goukaku ~ num_one, family = binomial(logit), data = data1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.0145  -0.9829  -0.8923   1.3673   1.6837  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -3.959e-01  3.188e-02  -12.42  < 2e-16 ***
## num_one     -2.728e-04  3.462e-05   -7.88 3.28e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 10247  on 7833  degrees of freedom
## Residual deviance: 10182  on 7832  degrees of freedom
## AIC: 10186
## 
## Number of Fisher Scoring iterations: 4
res_3 <- glm(goukaku ~ num_rate + num_one, data = data1, family = binomial(logit))
summary(res_3)
## 
## Call:
## glm(formula = goukaku ~ num_rate + num_one, family = binomial(logit), 
##     data = data1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.1565  -0.9678  -0.8189   1.3159   1.7075  
## 
## Coefficients:
##               Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -4.908e-02  4.627e-02  -1.061    0.289    
## num_rate    -9.965e-01  9.868e-02 -10.098   <2e-16 ***
## num_one     -5.413e-05  4.092e-05  -1.323    0.186    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 10247  on 7833  degrees of freedom
## Residual deviance: 10077  on 7831  degrees of freedom
## AIC: 10083
## 
## Number of Fisher Scoring iterations: 4
res_4 <- glm(goukaku ~ num_rate + gakka, data = data1, family = binomial(logit))
summary(res_4)
## 
## Call:
## glm(formula = goukaku ~ num_rate + gakka, family = binomial(logit), 
##     data = data1)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.6469  -0.9622  -0.8043   1.3038   2.0736  
## 
## Coefficients:
##                            Estimate Std. Error z value Pr(>|z|)    
## (Intercept)              -0.0866914  0.0941919  -0.920 0.357380    
## num_rate                 -1.0810523  0.0837775 -12.904  < 2e-16 ***
## gakkahougaku              0.1308349  0.1122017   1.166 0.243586    
## gakkaigaku                0.0002669  0.1461376   0.002 0.998543    
## gakkakango                0.8493735  0.1966870   4.318 1.57e-05 ***
## gakkakeizai_bunkei        0.2276737  0.1277555   1.782 0.074732 .  
## gakkakeizai_rikei        -0.9348748  0.2379133  -3.929 8.51e-05 ***
## gakkakensagijutu          0.4424097  0.2352474   1.881 0.060024 .  
## gakkakougaku             -0.0223312  0.0945930  -0.236 0.813373    
## gakkakyoiku_bunkei       -0.0672868  0.2000343  -0.336 0.736587    
## gakkakyoiku_rikei        -0.5800056  0.3739524  -1.551 0.120898    
## gakkanougaku              0.0673537  0.1118000   0.602 0.546876    
## gakkarigaku               0.0983553  0.1120666   0.878 0.380134    
## gakkarigakuryouhou        0.5864504  0.3436677   1.706 0.087925 .  
## gakkasagyouryouhou        1.4775357  0.4377294   3.375 0.000737 ***
## gakkasougouningen_bunkei -0.2591714  0.1719577  -1.507 0.131764    
## gakkasougouningen_rikei  -0.2993656  0.1838186  -1.629 0.103399    
## gakkayakka                0.3614791  0.2035938   1.775 0.075817 .  
## gakkayakugaku             0.3737973  0.2567470   1.456 0.145421    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 10246.7  on 7833  degrees of freedom
## Residual deviance:  9990.3  on 7815  degrees of freedom
## AIC: 10028
## 
## Number of Fisher Scoring iterations: 4

とりあえず、受験番号そのものよりも、各学科での“個人の受験番号/各学科最大の受験番号” num_rateの方がより良い予測因子のようだ。 係数は負であり、各学科での受験番号が大きいほど、合格率は低いようだ。

次に混合モデル。学科ごとにランダムな合格率があると仮定。 本当は正しい合格者数があるはずだが、調べるのが面倒なのでこれで行く。

library(lme4)
## Loading required package: Matrix
library(lmerTest)
## Warning: package 'lmerTest' was built under R version 3.2.4
## Warning: replacing previous import by 'ggplot2::unit' when loading 'Hmisc'
## Warning: replacing previous import by 'ggplot2::arrow' when loading 'Hmisc'
## Warning: replacing previous import by 'scales::alpha' when loading 'Hmisc'
## 
## Attaching package: 'lmerTest'
## 
##  以下のオブジェクトは 'package:lme4' からマスクされています: 
## 
##      lmer 
## 
##  以下のオブジェクトは 'package:stats' からマスクされています: 
## 
##      step
res_mix1 <- glmer(goukaku ~ num_rate + (1 + num_rate|gakka), data = data1, family = binomial(logit))
summary(res_mix1)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: goukaku ~ num_rate + (1 + num_rate | gakka)
##    Data: data1
## 
##      AIC      BIC   logLik deviance df.resid 
##  10057.5  10092.3  -5023.7  10047.5     7829 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.2820 -0.7676 -0.6236  1.1626  2.5547 
## 
## Random effects:
##  Groups Name        Variance Std.Dev. Corr 
##  gakka  (Intercept) 0.12325  0.3511        
##         num_rate    0.07179  0.2679   -0.01
## Number of obs: 7834, groups:  gakka, 18
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  0.02136    0.10618   0.201    0.841    
## num_rate    -1.10296    0.12397  -8.897   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##          (Intr)
## num_rate -0.411

同じく、各学科での受験番号が大きいほど、合格率は低いようだ。

“個人の受験番号/各学科最大の受験番号”ごとの合格者のヒストグラム。 大まかに合格率と比例。

data1_goukaku <- subset(data1, goukaku == TRUE)
hist(data1_goukaku$num_rate, breaks = seq(0, 1, by = 0.05))

なんだか、“個人の受験番号/各学科最大の受験番号”が0.5くらいまでは 合格率は良好。その後下がり、最後の駆け込み10%くらいは激しく 悪い感じ。

線形のモデルは相性が悪いと考えて、最後にgbmでの解析を追加する

library(gbm)
## Loading required package: survival
## Loading required package: lattice
## Loading required package: splines
## Loading required package: parallel
## Loaded gbm 2.1.1
res_gbm <- gbm(goukaku ~ num_rate + gakka, data = data1, distribution = "bernoulli",
               n.trees = 10000,
               interaction.depth = 3,
               n.minobsinnode = 10,
               shrinkage = 0.001,
               bag.fraction = 0.5,
               train.fraction = 1.0,
               cv.folds=5,
               keep.data = TRUE,
               verbose = "CV",
               class.stratify.cv=NULL,
               n.cores = 4)
best.iter <- gbm.perf(res_gbm,method="cv")

print(best.iter)
## [1] 4212
summary(res_gbm, n.trees=best.iter) 

##               var  rel.inf
## num_rate num_rate 59.60418
## gakka       gakka 40.39582
print(pretty.gbm.tree(res_gbm,res_gbm$n.trees))
##   SplitVar SplitCodePred LeftNode RightNode MissingNode ErrorReduction
## 0        1  1.257000e+04        1         8           9      0.6199666
## 1        0  1.581571e-02        2         3           7      0.5989936
## 2       -1  6.670651e-04       -1        -1          -1      0.0000000
## 3        0  6.823725e-02        4         5           6      0.6161752
## 4       -1 -5.788456e-04       -1        -1          -1      0.0000000
## 5       -1 -9.316886e-05       -1        -1          -1      0.0000000
## 6       -1 -1.167603e-04       -1        -1          -1      0.0000000
## 7       -1 -1.021398e-04       -1        -1          -1      0.0000000
## 8       -1  2.800834e-05       -1        -1          -1      0.0000000
## 9       -1 -4.055205e-06       -1        -1          -1      0.0000000
##   Weight    Prediction
## 0   3917 -4.055205e-06
## 1    965 -1.021398e-04
## 2     18  6.670651e-04
## 3    947 -1.167603e-04
## 4     46 -5.788456e-04
## 5    901 -9.316886e-05
## 6    947 -1.167603e-04
## 7    965 -1.021398e-04
## 8   2952  2.800834e-05
## 9   3917 -4.055205e-06
plot(res_gbm,1:2,best.iter, type = "response")

クロスバリデーションありのgbmではこんな感じになった。 やはり受験番号が大きいほど合格率は悪い感じ。

最後に受験番号ごとの合格率(最小値~+99まで)

bangoubetu <- function(x){
      temp <- subset(data1, data1$num_one == x)
      sum(temp$goukaku) / nrow(temp)
}

barplot(sapply(1:100, bangoubetu), names.arg = 1:100)
abline(h = sum(data1$goukaku) / nrow(data1))

受験番号1とか3001とかその学科最小の受験番号の合格率は 7割超えであった。 有意だが、100個の検定を繰り返したことを調整すると、有意 ではなくなる程度のもの。グラフを見る限り、たまたまの印象。