Compute Confidence Interval about q of logistic binary fit
I have results from a binary study. The study was analyzied by others using Gonogo (https://www2.isye.gatech.edu/~jeffwu/sensitivitytesting/), the prefered code developed by/for the government for such studies. My code for anlaysis is shown below. I am able to fit a logistic curve using glmfit (magentia line in plot). I then compute the confidence limits about the probablility p using glmval (black lines). These black line match well with the results given by Gonogo (dashed blue lines). However, I am unable to figure out how to compute the confidence limits about the quantile q (the Gonongo results are shown as dashed red lines). I tried using coefCI, with the results in cyan. It is doing something but I don’t understand exactly what, and it does not really match the dashed red lines that I am looking for. Does anyone know how I can compute the confidence limits about the quantile q? Your assistance is appreciated.
%% Output from Gonogo – Main code in next section
R_mu = 10.1707909;
R_sigma = 0.9344091;
R_b0 = -10.88473;
R_b1 = 1.070195;
R_output = [
1.124021, 5.5, 9.875979, 0, 0, 0.3761890
1.321891, 5.611111, 9.900331, 0, 1.e-06, 0.3861210
1.519710, 5.722222, 9.924735, 0, 1.e-06, 0.3961490
1.717474, 5.833333, 9.949193, 0, 2.e-06, 0.4062690
1.915181, 5.944444, 9.973708, 0, 3.e-06, 0.4164760
2.112825, 6.055556, 9.998286, 0, 5.e-06, 0.4267660
2.310404, 6.166667, 10.022929, 0, 9.e-06, 0.4371330
2.507913, 6.277778, 10.047643, 0, 1.5e-05, 0.4475740
2.705346, 6.388889, 10.072432, 0, 2.6e-05, 0.4580840
2.902698, 6.5, 10.097302, 0, 4.3e-05, 0.4686570
3.099963, 6.611111, 10.122259, 0, 7.e-05, 0.4792890
3.297135, 6.722222, 10.147309, 0, 0.000112, 0.4899760
3.494207, 6.833333, 10.17246, 0, 0.000177, 0.5007130
3.691170, 6.944444, 10.197719, 0, 0.000277, 0.5114950
3.888016, 7.055556, 10.223095, 0, 0.000428, 0.5223200
4.084734, 7.166667, 10.248599, 0, 0.000652, 0.5331820
4.281315, 7.277778, 10.274241, 0, 0.00098, 0.5440770
4.290992, 7.283250, 10.27551, 0, 0.001, 0.5446150
4.477745, 7.388889, 10.300033, 0, 0.001455000, 0.5550040
4.674012, 7.5, 10.325988, 0, 0.00213, 0.5659570
4.870099, 7.611111, 10.352123, 0, 0.003078000, 0.5769360
5.065991, 7.722222, 10.378454, 0, 0.004391000, 0.5879360
5.139437, 7.763912, 10.38839, 0, 0.005, 0.5920690
5.261667, 7.833333, 10.40500, 0, 0.006183000, 0.5989570
5.457105, 7.944444, 10.431784, 0, 0.008595000, 0.6099980
5.549510, 7.997030, 10.44455, 0, 0.01, 0.6152300
5.652280, 8.055556, 10.458831, 1.e-06, 0.01179600, 0.6210570
5.847164, 8.166667, 10.486169, 2.e-06, 0.01598400, 0.6321360
5.996179, 8.251749, 10.50732, 4.e-06, 0.02, 0.6406330
6.041725, 8.277778, 10.513831, 5.e-06, 0.02138800, 0.6432350
6.235924, 8.388889, 10.541854, 1.3e-05, 0.02826100, 0.6543570
6.278641, 8.413360, 10.54808, 1.6e-05, 0.03, 0.6568100
6.429717, 8.5, 10.570283, 3.1e-05, 0.03688200, 0.6655050
6.490555, 8.534934, 10.57931, 4.1e-05, 0.04, 0.6690160
6.623055, 8.611111, 10.599167, 7.3e-05, 0.04754300, 0.6766840
6.662517, 8.633825, 10.60513, 8.7e-05, 0.05, 0.6789740
6.808555, 8.717996, 10.62744, 0.00016, 0.06, 0.6874730
6.815879, 8.722222, 10.628566, 0.000165, 0.06054100, 0.6879010
6.936329, 8.791798, 10.64727, 0.000269, 0.07, 0.6949470
7.008118, 8.833333, 10.658548, 0.000356, 0.07616600, 0.6991630
7.050500, 8.857879, 10.66526, 0.00042, 0.08, 0.7016590
7.154124, 8.917977, 10.68183, 0.000622, 0.09, 0.7077800
7.199693, 8.944444, 10.689196, 0.000737, 0.09468800, 0.7104830
7.249320, 8.973297, 10.69727, 0.000884, 0.1, 0.7134330
7.337620, 9.024712, 10.71180, 0.001215000, 0.11, 0.7187020
7.390505, 9.055556, 10.720606, 0.001463000, 0.1163330, 0.7218710
7.420168, 9.072873, 10.72558, 0.001622000, 0.12, 0.7236530
7.497845, 9.118281, 10.73872, 0.002114000, 0.13, 0.7283370
7.571342, 9.161331, 10.75132, 0.002702000, 0.14, 0.7327920
7.580442, 9.166667, 10.752892, 0.002784000, 0.1412750, 0.7333450
7.641212, 9.202338, 10.76346, 0.003393000, 0.15, 0.7370500
7.707905, 9.241560, 10.77522, 0.004197000, 0.16, 0.7411360
7.769364, 9.277778, 10.786191, 0.005085000, 0.1696120, 0.7449230
7.771792, 9.279210, 10.78663, 0.005123000, 0.17, 0.7450730
7.833186, 9.315465, 10.79775, 0.00618, 0.18, 0.7488780
7.892348, 9.350477, 10.80861, 0.007377000, 0.19, 0.7525660
7.949501, 9.384372, 10.81924, 0.008722000, 0.2, 0.7561500
7.957108, 9.388889, 10.82067, 0.008916000, 0.2013560, 0.7566280
8.004840, 9.417264, 10.82969, 0.01022500, 0.21, 0.7596410
8.058530, 9.449247, 10.83996, 0.01189400, 0.22, 0.7630490
8.110717, 9.480406, 10.85009, 0.01373800, 0.23, 0.7663830
8.143472, 9.5, 10.856528, 0.01501800, 0.2364170, 0.7684870
8.161530, 9.510815, 10.86010, 0.01576600, 0.24, 0.7696500
8.211082, 9.540542, 10.87000, 0.01798500, 0.25, 0.7728580
8.259474, 9.569643, 10.87981, 0.02040400, 0.26, 0.7760110
8.306795, 9.598173, 10.88955, 0.02303000, 0.27, 0.7791170
8.328215, 9.611111, 10.894008, 0.02431000, 0.2745980, 0.7805300
8.353126, 9.626179, 10.89923, 0.02587200, 0.28, 0.7821790
8.398541, 9.653703, 10.90887, 0.02893700, 0.29, 0.7852020
8.443105, 9.680786, 10.91847, 0.03223200, 0.3, 0.7881910
8.486879, 9.707464, 10.92805, 0.03576400, 0.31, 0.7911490
8.511040, 9.722222, 10.933405, 0.03784500, 0.3155940, 0.7927920
8.529915, 9.733769, 10.93762, 0.03953900, 0.32, 0.7940800
8.572265, 9.759732, 10.94720, 0.04356500, 0.33, 0.7969870
8.613974, 9.785382, 10.95679, 0.04784700, 0.34, 0.7998740
8.655085, 9.810744, 10.96640, 0.05239100, 0.35, 0.8027430
8.691586, 9.833333, 10.975081, 0.05670600, 0.3589950, 0.8053110
8.695636, 9.835844, 10.97605, 0.05720200, 0.36, 0.8055970
8.735663, 9.860704, 10.98575, 0.06228500, 0.37, 0.8084400
8.775199, 9.885347, 10.99550, 0.06764600, 0.38, 0.8112720
8.814276, 9.909793, 11.00531, 0.07328800, 0.39, 0.8140970
8.852923, 9.934061, 11.01520, 0.07921400, 0.4, 0.8169180
8.869412, 9.944444, 11.019477, 0.08185100, 0.4042990, 0.8181290
8.891166, 9.958171, 11.02518, 0.08543000, 0.41, 0.8197360
8.929030, 9.982140, 11.03525, 0.09193600, 0.42, 0.8225530
8.966540, 10.005985, 11.04543, 0.09873700, 0.43, 0.8253720
9.003718, 10.029724, 11.05573, 0.1058330, 0.44, 0.8281950
9.040583, 10.053372, 11.06616, 0.1132270, 0.45, 0.8310240
9.043979, 10.055556, 11.067132, 0.1139260, 0.4509250, 0.8312860
9.077157, 10.076945, 11.07673, 0.1209200, 0.46, 0.8338610
9.113456, 10.100458, 11.08746, 0.1289110, 0.47, 0.8367070
9.149500, 10.123927, 11.09835, 0.1372010, 0.48, 0.8395650
9.185304, 10.147366, 11.10943, 0.1457900, 0.49, 0.8424370
9.214635, 10.166667, 11.118699, 0.1530890, 0.4982390, 0.8448150
9.220884, 10.170791, 11.12070, 0.1546750, 0.5, 0.8453250
9.256255, 10.194216, 11.13218, 0.1638560, 0.51, 0.8482300
9.291430, 10.217655, 11.14388, 0.1733300, 0.52, 0.8511540
9.326423, 10.241124, 11.15583, 0.1830940, 0.53, 0.8540990
9.361246, 10.264637, 11.16803, 0.1931430, 0.54, 0.8570680
9.380601, 10.277778, 11.174955, 0.1988720, 0.5455780, 0.8587350
9.395911, 10.28821, 11.18051, 0.2034750, 0.55, 0.8600610
9.430430, 10.311858, 11.19329, 0.2140840, 0.56, 0.8630820
9.464812, 10.335597, 11.20638, 0.2249640, 0.57, 0.8661300
9.499068, 10.359442, 11.21982, 0.2361090, 0.58, 0.8692090
9.533207, 10.383411, 11.23362, 0.2475120, 0.59, 0.8723210
9.540967, 10.388889, 11.236811, 0.2501450, 0.5922770, 0.8730340
9.567238, 10.407521, 11.24780, 0.2591660, 0.6, 0.8754650
9.601170, 10.431789, 11.26241, 0.2710620, 0.61, 0.8786460
9.635010, 10.456235, 11.27746, 0.2831900, 0.62, 0.8818630
9.668765, 10.480878, 11.29299, 0.2955420, 0.63, 0.8851190
9.694703, 10.5, 11.305297, 0.3051990, 0.6377000, 0.8876530
9.702443, 10.505738, 11.30903, 0.3081070, 0.64, 0.8884150
9.736049, 10.530838, 11.32563, 0.3208730, 0.65, 0.8917520
9.769590, 10.55620, 11.34281, 0.3338290, 0.66, 0.8951320
9.803071, 10.58185, 11.36063, 0.3469630, 0.67, 0.8985540
9.836498, 10.607813, 11.37913, 0.3602620, 0.68, 0.9020210
9.840710, 10.611111, 11.381512, 0.3619500, 0.6812610, 0.9024620
9.869875, 10.634118, 11.39836, 0.3737120, 0.69, 0.9055330
9.903207, 10.660796, 11.41838, 0.3872990, 0.7, 0.9090890
9.936498, 10.687879, 11.43926, 0.4010080, 0.71, 0.9126900
9.969753, 10.715403, 11.46105, 0.4148250, 0.72, 0.9163350
9.977900, 10.722222, 11.466545, 0.4182270, 0.7224510, 0.9172350
10.002975, 10.743409, 11.48384, 0.4287350, 0.73, 0.9200220
10.03617, 10.771939, 11.50771, 0.4427220, 0.74, 0.9237510
10.069341, 10.80104, 11.53274, 0.4567710, 0.75, 0.9275180
10.102495, 10.830767, 11.55904, 0.4708670, 0.76, 0.9313200
10.105323, 10.833333, 11.561344, 0.4720710, 0.7608530, 0.9316460
10.135637, 10.861176, 11.58672, 0.4849950, 0.77, 0.9351540
10.168774, 10.892335, 11.61590, 0.4991390, 0.78, 0.9390130
10.201916, 10.924318, 11.64672, 0.5132860, 0.79, 0.9428930
10.222317, 10.944444, 11.666572, 0.5219880, 0.7961530, 0.9452870
10.235074, 10.95721, 11.67934, 0.5274240, 0.8, 0.9467850
10.268263, 10.991105, 11.71395, 0.5415400, 0.81, 0.9506800
10.301499, 11.026116, 11.75073, 0.5556240, 0.82, 0.9545670
10.328631, 11.055556, 11.78248, 0.5670700, 0.8281480, 0.9577200
10.334807, 11.062372, 11.78994, 0.5696680, 0.83, 0.9584350
10.368215, 11.100021, 11.83183, 0.5836670, 0.84, 0.9622680
10.401762, 11.139244, 11.87673, 0.5976170, 0.85, 0.9660510
10.42447, 11.166667, 11.908864, 0.6069910, 0.8567390, 0.9685630
10.435495, 11.180251, 11.92501, 0.6115210, 0.86, 0.9697650
10.469477, 11.223301, 11.97712, 0.6253840, 0.87, 0.9733900
10.50379, 11.268709, 12.03363, 0.6392200, 0.88, 0.9769020
10.510459, 11.277778, 12.045096, 0.6418890, 0.8819300, 0.9775650
10.538537, 11.31687, 12.09520, 0.6530470, 0.89, 0.9802770
10.57386, 11.368284, 12.16271, 0.6668980, 0.9, 0.9834860
10.587526, 11.388889, 12.190252, 0.6721970, 0.9038150, 0.9846610
10.609944, 11.423605, 12.23727, 0.6808150, 0.91, 0.9865000
10.647043, 11.483703, 12.32036, 0.6948630, 0.92, 0.9892890
10.656749, 11.5, 12.343251, 0.6984920, 0.9225610, 0.9899630
10.685514, 11.549784, 12.41405, 0.7091330, 0.93, 0.9918190
10.719233, 11.611111, 12.502989, 0.7213780, 0.9383930, 0.9937180
10.725874, 11.623586, 12.52130, 0.7237600, 0.94, 0.9940570
10.768913, 11.707757, 12.64660, 0.7389480, 0.95, 0.9959710
10.776016, 11.722222, 12.668428, 0.7414130, 0.9515760, 0.9962410
10.815924, 11.806648, 12.79737, 0.7550340, 0.96, 0.9975300
10.828023, 11.833333, 12.838644, 0.7590860, 0.9624000, 0.9978490
10.869256, 11.928222, 12.98719, 0.7726170, 0.97, 0.9987110
10.876046, 11.944444, 13.012843, 0.7748040, 0.9711620, 0.9988230
10.920748, 12.055556, 13.190363, 0.7888970, 0.9781560, 0.9993840
10.933957, 12.089833, 13.24571, 0.7929600, 0.98, 0.9995000
10.96268, 12.166667, 13.370653, 0.8016350, 0.9836590, 0.9996920
11.002292, 12.277778, 13.553264, 0.8132320, 0.9879300, 0.9998530
11.025138, 12.344552, 13.66397, 0.8197250, 0.99, 0.9999070
11.039952, 12.388889, 13.737825, 0.8238590, 0.9911970, 0.9999330
11.075964, 12.5, 13.924036, 0.8336550, 0.9936610, 0.9999700
11.100291, 12.577669, 14.05505, 0.8400700, 0.995, 0.9999840
11.110574, 12.611111, 14.111649, 0.8427320, 0.9954940, 0.9999880
11.143986, 12.722222, 14.300459, 0.8511800, 0.9968380, 0.9999950
11.176368, 12.833333, 14.490299, 0.8590730, 0.9978100, 0.9999980
11.207861, 12.944444, 14.681028, 0.8664720, 0.9985030, 0.9999990
11.238582, 13.055556, 14.872529, 0.8734280, 0.9989900, 1
11.239341, 13.058332, 14.87732, 0.8735960, 0.999, 1
11.268629, 13.166667, 15.064705, 0.8799830, 0.9993270, 1
11.298084, 13.277778, 15.257472, 0.8861730, 0.9995580, 1
11.327018, 13.388889, 15.45076, 0.8920280, 0.9997130, 1
11.35549, 13.5, 15.64451, 0.8975760, 0.9998170, 1
11.383553, 13.611111, 15.838669, 0.9028380, 0.9998840, 1
11.41125, 13.722222, 16.033194, 0.9078340, 0.9999280, 1
11.438619, 13.833333, 16.228047, 0.9125810, 0.9999560, 1
11.465694, 13.944444, 16.423194, 0.9170960, 0.9999730, 1
11.492504, 14.055556, 16.618607, 0.9213910, 0.9999840, 1
11.519074, 14.166667, 16.81426, 0.9254790, 0.9999910, 1
11.545426, 14.277778, 17.01013, 0.9293720, 0.9999940, 1
11.57158, 14.388889, 17.206198, 0.9330780, 0.9999970, 1
11.597553, 14.5, 17.402447, 0.9366090, 0.9999980, 1
11.623361, 14.611111, 17.598862, 0.9399710, 0.9999990, 1
11.649017, 14.722222, 17.795427, 0.9431740, 0.9999990, 1
11.674534, 14.833333, 17.992133, 0.9462240, 1, 1
11.699923, 14.944444, 18.188966, 0.9491290, 1, 1
11.725194, 15.055556, 18.385917, 0.9518950, 1, 1
11.750355, 15.166667, 18.582978, 0.9545280, 1, 1
11.775415, 15.277778, 18.78014, 0.9570340, 1, 1
11.800381, 15.388889, 18.977397, 0.9594190, 1, 1
11.82526, 15.5, 19.17474, 0.9616870, 1, 1
11.850057, 15.611111, 19.372165, 0.9638430, 1, 1
11.874778, 15.722222, 19.569666, 0.9658940, 1, 1
11.899429, 15.833333, 19.767238, 0.9678420, 1, 1
11.924013, 15.944444, 19.964876, 0.9696920, 1, 1
11.948534, 16.055556, 20.162577, 0.9714490, 1, 1
11.972998, 16.166667, 20.360335, 0.9731170, 1, 1
11.997407, 16.277778, 20.558149, 0.9746990, 1, 1
12.021764, 16.388889, 20.756014, 0.9761990, 1, 1
12.046074, 16.5, 20.953926, 0.9776210, 1, 1 ];
%% Matlab GLM fitting
xWT = [5.5,16.5,11,13.8,10.1,14.7,10.4,11.7,9.7,7.3,7.8,8.1,12.2,8.5,11.8,11.7121,11.4083,11.1558,12.4633,12.2761,12.1107,11.9628,11.8291,11.7072,11.5952,11.4917,11.3955,11.3057,11.2214,11.1421]’;
yWT = [0,1,0,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1]’;
n = ones(size(yWT));
[b, dev, stats] = glmfit(xWT, [yWT, n], ‘binomial’, ‘Link’, ‘probit’);
wt = 5 : 0.05 : 17;
[y_fit, dylo, dyhi] = glmval(b, wt, ‘probit’, stats, ‘confidence’, 0.95);
mu_1 = -b(1) /b(2);
gradient = central_diff(y_fit, wt);
go = yWT == 1;
nogo = yWT == 0;
fig1 = figure;
plot(xWT(go), yWT(go), ‘ko’, ‘LineWidth’, 0.5, ‘MarkerFaceColor’, ‘g’, ‘MarkerSize’, 8)
hold on
plot(xWT(nogo), yWT(nogo), ‘ks’, ‘LineWidth’, 0.5, ‘MarkerFaceColor’, ‘r’, ‘MarkerSize’, 8)
p1 = plot(wt, y_fit, ‘-m’);
p2 = plot(wt, y_fit – dylo, ‘-k’);
plot(wt, y_fit + dyhi, ‘-k’)
p3 = plot(wt, gradient/max(gradient), ‘-‘, ‘Color’, 0.6*[1,1,1]);
xlim([5, 17]);
title(‘Wu and Tian Example’)
xlabel(‘Quantile (q, in units wt)’)
ylabel(‘Probability (p)’)
grid on; grid minor
mfw_pos = get(gcf, ‘Position’); mfw_pos(3) = mfw_pos(3) * 1.6; set(gcf, ‘Position’, mfw_pos); % Make Figure Wide (60% wider)
% These are the results from the R code "Gonogo"
% plot(R_output(:,2), R_output(:,5), ‘–b’)
p4 = plot(R_output(:,2), R_output(:,6), ‘–b’);
plot(R_output(:,2), R_output(:,4), ‘–b’)
p5 = plot(R_output(:,1), R_output(:,5), ‘–r’);
plot(R_output(:,3), R_output(:,5), ‘–r’)
legend([p1 p2 p3 p4 p5],{‘Logistic Fit’,’Confidence Bounds from glmval’,’diff of Logistic Fit’,’Confidence Interval about p’,’Confidence Interval about q’}, …
‘Location’, ‘east’)
mdl = fitglm(xWT, yWT, ‘Distribution’, ‘binomial’, ‘Link’, ‘probit’);
ci = coefCI(mdl, 0.95);
figure(fig1)
plot(wt, mdl.Link.Inverse([ones(size(wt’,1),1,"like",wt’) wt’] * ci(:,1)), ‘-c’, ‘DisplayName’, ‘from Matlab coefCI’)
plot(wt, mdl.Link.Inverse([ones(size(wt’,1),1,"like",wt’) wt’] * ci(:,2)), ‘-c’, ‘HandleVisibility’,’off’)I have results from a binary study. The study was analyzied by others using Gonogo (https://www2.isye.gatech.edu/~jeffwu/sensitivitytesting/), the prefered code developed by/for the government for such studies. My code for anlaysis is shown below. I am able to fit a logistic curve using glmfit (magentia line in plot). I then compute the confidence limits about the probablility p using glmval (black lines). These black line match well with the results given by Gonogo (dashed blue lines). However, I am unable to figure out how to compute the confidence limits about the quantile q (the Gonongo results are shown as dashed red lines). I tried using coefCI, with the results in cyan. It is doing something but I don’t understand exactly what, and it does not really match the dashed red lines that I am looking for. Does anyone know how I can compute the confidence limits about the quantile q? Your assistance is appreciated.
%% Output from Gonogo – Main code in next section
R_mu = 10.1707909;
R_sigma = 0.9344091;
R_b0 = -10.88473;
R_b1 = 1.070195;
R_output = [
1.124021, 5.5, 9.875979, 0, 0, 0.3761890
1.321891, 5.611111, 9.900331, 0, 1.e-06, 0.3861210
1.519710, 5.722222, 9.924735, 0, 1.e-06, 0.3961490
1.717474, 5.833333, 9.949193, 0, 2.e-06, 0.4062690
1.915181, 5.944444, 9.973708, 0, 3.e-06, 0.4164760
2.112825, 6.055556, 9.998286, 0, 5.e-06, 0.4267660
2.310404, 6.166667, 10.022929, 0, 9.e-06, 0.4371330
2.507913, 6.277778, 10.047643, 0, 1.5e-05, 0.4475740
2.705346, 6.388889, 10.072432, 0, 2.6e-05, 0.4580840
2.902698, 6.5, 10.097302, 0, 4.3e-05, 0.4686570
3.099963, 6.611111, 10.122259, 0, 7.e-05, 0.4792890
3.297135, 6.722222, 10.147309, 0, 0.000112, 0.4899760
3.494207, 6.833333, 10.17246, 0, 0.000177, 0.5007130
3.691170, 6.944444, 10.197719, 0, 0.000277, 0.5114950
3.888016, 7.055556, 10.223095, 0, 0.000428, 0.5223200
4.084734, 7.166667, 10.248599, 0, 0.000652, 0.5331820
4.281315, 7.277778, 10.274241, 0, 0.00098, 0.5440770
4.290992, 7.283250, 10.27551, 0, 0.001, 0.5446150
4.477745, 7.388889, 10.300033, 0, 0.001455000, 0.5550040
4.674012, 7.5, 10.325988, 0, 0.00213, 0.5659570
4.870099, 7.611111, 10.352123, 0, 0.003078000, 0.5769360
5.065991, 7.722222, 10.378454, 0, 0.004391000, 0.5879360
5.139437, 7.763912, 10.38839, 0, 0.005, 0.5920690
5.261667, 7.833333, 10.40500, 0, 0.006183000, 0.5989570
5.457105, 7.944444, 10.431784, 0, 0.008595000, 0.6099980
5.549510, 7.997030, 10.44455, 0, 0.01, 0.6152300
5.652280, 8.055556, 10.458831, 1.e-06, 0.01179600, 0.6210570
5.847164, 8.166667, 10.486169, 2.e-06, 0.01598400, 0.6321360
5.996179, 8.251749, 10.50732, 4.e-06, 0.02, 0.6406330
6.041725, 8.277778, 10.513831, 5.e-06, 0.02138800, 0.6432350
6.235924, 8.388889, 10.541854, 1.3e-05, 0.02826100, 0.6543570
6.278641, 8.413360, 10.54808, 1.6e-05, 0.03, 0.6568100
6.429717, 8.5, 10.570283, 3.1e-05, 0.03688200, 0.6655050
6.490555, 8.534934, 10.57931, 4.1e-05, 0.04, 0.6690160
6.623055, 8.611111, 10.599167, 7.3e-05, 0.04754300, 0.6766840
6.662517, 8.633825, 10.60513, 8.7e-05, 0.05, 0.6789740
6.808555, 8.717996, 10.62744, 0.00016, 0.06, 0.6874730
6.815879, 8.722222, 10.628566, 0.000165, 0.06054100, 0.6879010
6.936329, 8.791798, 10.64727, 0.000269, 0.07, 0.6949470
7.008118, 8.833333, 10.658548, 0.000356, 0.07616600, 0.6991630
7.050500, 8.857879, 10.66526, 0.00042, 0.08, 0.7016590
7.154124, 8.917977, 10.68183, 0.000622, 0.09, 0.7077800
7.199693, 8.944444, 10.689196, 0.000737, 0.09468800, 0.7104830
7.249320, 8.973297, 10.69727, 0.000884, 0.1, 0.7134330
7.337620, 9.024712, 10.71180, 0.001215000, 0.11, 0.7187020
7.390505, 9.055556, 10.720606, 0.001463000, 0.1163330, 0.7218710
7.420168, 9.072873, 10.72558, 0.001622000, 0.12, 0.7236530
7.497845, 9.118281, 10.73872, 0.002114000, 0.13, 0.7283370
7.571342, 9.161331, 10.75132, 0.002702000, 0.14, 0.7327920
7.580442, 9.166667, 10.752892, 0.002784000, 0.1412750, 0.7333450
7.641212, 9.202338, 10.76346, 0.003393000, 0.15, 0.7370500
7.707905, 9.241560, 10.77522, 0.004197000, 0.16, 0.7411360
7.769364, 9.277778, 10.786191, 0.005085000, 0.1696120, 0.7449230
7.771792, 9.279210, 10.78663, 0.005123000, 0.17, 0.7450730
7.833186, 9.315465, 10.79775, 0.00618, 0.18, 0.7488780
7.892348, 9.350477, 10.80861, 0.007377000, 0.19, 0.7525660
7.949501, 9.384372, 10.81924, 0.008722000, 0.2, 0.7561500
7.957108, 9.388889, 10.82067, 0.008916000, 0.2013560, 0.7566280
8.004840, 9.417264, 10.82969, 0.01022500, 0.21, 0.7596410
8.058530, 9.449247, 10.83996, 0.01189400, 0.22, 0.7630490
8.110717, 9.480406, 10.85009, 0.01373800, 0.23, 0.7663830
8.143472, 9.5, 10.856528, 0.01501800, 0.2364170, 0.7684870
8.161530, 9.510815, 10.86010, 0.01576600, 0.24, 0.7696500
8.211082, 9.540542, 10.87000, 0.01798500, 0.25, 0.7728580
8.259474, 9.569643, 10.87981, 0.02040400, 0.26, 0.7760110
8.306795, 9.598173, 10.88955, 0.02303000, 0.27, 0.7791170
8.328215, 9.611111, 10.894008, 0.02431000, 0.2745980, 0.7805300
8.353126, 9.626179, 10.89923, 0.02587200, 0.28, 0.7821790
8.398541, 9.653703, 10.90887, 0.02893700, 0.29, 0.7852020
8.443105, 9.680786, 10.91847, 0.03223200, 0.3, 0.7881910
8.486879, 9.707464, 10.92805, 0.03576400, 0.31, 0.7911490
8.511040, 9.722222, 10.933405, 0.03784500, 0.3155940, 0.7927920
8.529915, 9.733769, 10.93762, 0.03953900, 0.32, 0.7940800
8.572265, 9.759732, 10.94720, 0.04356500, 0.33, 0.7969870
8.613974, 9.785382, 10.95679, 0.04784700, 0.34, 0.7998740
8.655085, 9.810744, 10.96640, 0.05239100, 0.35, 0.8027430
8.691586, 9.833333, 10.975081, 0.05670600, 0.3589950, 0.8053110
8.695636, 9.835844, 10.97605, 0.05720200, 0.36, 0.8055970
8.735663, 9.860704, 10.98575, 0.06228500, 0.37, 0.8084400
8.775199, 9.885347, 10.99550, 0.06764600, 0.38, 0.8112720
8.814276, 9.909793, 11.00531, 0.07328800, 0.39, 0.8140970
8.852923, 9.934061, 11.01520, 0.07921400, 0.4, 0.8169180
8.869412, 9.944444, 11.019477, 0.08185100, 0.4042990, 0.8181290
8.891166, 9.958171, 11.02518, 0.08543000, 0.41, 0.8197360
8.929030, 9.982140, 11.03525, 0.09193600, 0.42, 0.8225530
8.966540, 10.005985, 11.04543, 0.09873700, 0.43, 0.8253720
9.003718, 10.029724, 11.05573, 0.1058330, 0.44, 0.8281950
9.040583, 10.053372, 11.06616, 0.1132270, 0.45, 0.8310240
9.043979, 10.055556, 11.067132, 0.1139260, 0.4509250, 0.8312860
9.077157, 10.076945, 11.07673, 0.1209200, 0.46, 0.8338610
9.113456, 10.100458, 11.08746, 0.1289110, 0.47, 0.8367070
9.149500, 10.123927, 11.09835, 0.1372010, 0.48, 0.8395650
9.185304, 10.147366, 11.10943, 0.1457900, 0.49, 0.8424370
9.214635, 10.166667, 11.118699, 0.1530890, 0.4982390, 0.8448150
9.220884, 10.170791, 11.12070, 0.1546750, 0.5, 0.8453250
9.256255, 10.194216, 11.13218, 0.1638560, 0.51, 0.8482300
9.291430, 10.217655, 11.14388, 0.1733300, 0.52, 0.8511540
9.326423, 10.241124, 11.15583, 0.1830940, 0.53, 0.8540990
9.361246, 10.264637, 11.16803, 0.1931430, 0.54, 0.8570680
9.380601, 10.277778, 11.174955, 0.1988720, 0.5455780, 0.8587350
9.395911, 10.28821, 11.18051, 0.2034750, 0.55, 0.8600610
9.430430, 10.311858, 11.19329, 0.2140840, 0.56, 0.8630820
9.464812, 10.335597, 11.20638, 0.2249640, 0.57, 0.8661300
9.499068, 10.359442, 11.21982, 0.2361090, 0.58, 0.8692090
9.533207, 10.383411, 11.23362, 0.2475120, 0.59, 0.8723210
9.540967, 10.388889, 11.236811, 0.2501450, 0.5922770, 0.8730340
9.567238, 10.407521, 11.24780, 0.2591660, 0.6, 0.8754650
9.601170, 10.431789, 11.26241, 0.2710620, 0.61, 0.8786460
9.635010, 10.456235, 11.27746, 0.2831900, 0.62, 0.8818630
9.668765, 10.480878, 11.29299, 0.2955420, 0.63, 0.8851190
9.694703, 10.5, 11.305297, 0.3051990, 0.6377000, 0.8876530
9.702443, 10.505738, 11.30903, 0.3081070, 0.64, 0.8884150
9.736049, 10.530838, 11.32563, 0.3208730, 0.65, 0.8917520
9.769590, 10.55620, 11.34281, 0.3338290, 0.66, 0.8951320
9.803071, 10.58185, 11.36063, 0.3469630, 0.67, 0.8985540
9.836498, 10.607813, 11.37913, 0.3602620, 0.68, 0.9020210
9.840710, 10.611111, 11.381512, 0.3619500, 0.6812610, 0.9024620
9.869875, 10.634118, 11.39836, 0.3737120, 0.69, 0.9055330
9.903207, 10.660796, 11.41838, 0.3872990, 0.7, 0.9090890
9.936498, 10.687879, 11.43926, 0.4010080, 0.71, 0.9126900
9.969753, 10.715403, 11.46105, 0.4148250, 0.72, 0.9163350
9.977900, 10.722222, 11.466545, 0.4182270, 0.7224510, 0.9172350
10.002975, 10.743409, 11.48384, 0.4287350, 0.73, 0.9200220
10.03617, 10.771939, 11.50771, 0.4427220, 0.74, 0.9237510
10.069341, 10.80104, 11.53274, 0.4567710, 0.75, 0.9275180
10.102495, 10.830767, 11.55904, 0.4708670, 0.76, 0.9313200
10.105323, 10.833333, 11.561344, 0.4720710, 0.7608530, 0.9316460
10.135637, 10.861176, 11.58672, 0.4849950, 0.77, 0.9351540
10.168774, 10.892335, 11.61590, 0.4991390, 0.78, 0.9390130
10.201916, 10.924318, 11.64672, 0.5132860, 0.79, 0.9428930
10.222317, 10.944444, 11.666572, 0.5219880, 0.7961530, 0.9452870
10.235074, 10.95721, 11.67934, 0.5274240, 0.8, 0.9467850
10.268263, 10.991105, 11.71395, 0.5415400, 0.81, 0.9506800
10.301499, 11.026116, 11.75073, 0.5556240, 0.82, 0.9545670
10.328631, 11.055556, 11.78248, 0.5670700, 0.8281480, 0.9577200
10.334807, 11.062372, 11.78994, 0.5696680, 0.83, 0.9584350
10.368215, 11.100021, 11.83183, 0.5836670, 0.84, 0.9622680
10.401762, 11.139244, 11.87673, 0.5976170, 0.85, 0.9660510
10.42447, 11.166667, 11.908864, 0.6069910, 0.8567390, 0.9685630
10.435495, 11.180251, 11.92501, 0.6115210, 0.86, 0.9697650
10.469477, 11.223301, 11.97712, 0.6253840, 0.87, 0.9733900
10.50379, 11.268709, 12.03363, 0.6392200, 0.88, 0.9769020
10.510459, 11.277778, 12.045096, 0.6418890, 0.8819300, 0.9775650
10.538537, 11.31687, 12.09520, 0.6530470, 0.89, 0.9802770
10.57386, 11.368284, 12.16271, 0.6668980, 0.9, 0.9834860
10.587526, 11.388889, 12.190252, 0.6721970, 0.9038150, 0.9846610
10.609944, 11.423605, 12.23727, 0.6808150, 0.91, 0.9865000
10.647043, 11.483703, 12.32036, 0.6948630, 0.92, 0.9892890
10.656749, 11.5, 12.343251, 0.6984920, 0.9225610, 0.9899630
10.685514, 11.549784, 12.41405, 0.7091330, 0.93, 0.9918190
10.719233, 11.611111, 12.502989, 0.7213780, 0.9383930, 0.9937180
10.725874, 11.623586, 12.52130, 0.7237600, 0.94, 0.9940570
10.768913, 11.707757, 12.64660, 0.7389480, 0.95, 0.9959710
10.776016, 11.722222, 12.668428, 0.7414130, 0.9515760, 0.9962410
10.815924, 11.806648, 12.79737, 0.7550340, 0.96, 0.9975300
10.828023, 11.833333, 12.838644, 0.7590860, 0.9624000, 0.9978490
10.869256, 11.928222, 12.98719, 0.7726170, 0.97, 0.9987110
10.876046, 11.944444, 13.012843, 0.7748040, 0.9711620, 0.9988230
10.920748, 12.055556, 13.190363, 0.7888970, 0.9781560, 0.9993840
10.933957, 12.089833, 13.24571, 0.7929600, 0.98, 0.9995000
10.96268, 12.166667, 13.370653, 0.8016350, 0.9836590, 0.9996920
11.002292, 12.277778, 13.553264, 0.8132320, 0.9879300, 0.9998530
11.025138, 12.344552, 13.66397, 0.8197250, 0.99, 0.9999070
11.039952, 12.388889, 13.737825, 0.8238590, 0.9911970, 0.9999330
11.075964, 12.5, 13.924036, 0.8336550, 0.9936610, 0.9999700
11.100291, 12.577669, 14.05505, 0.8400700, 0.995, 0.9999840
11.110574, 12.611111, 14.111649, 0.8427320, 0.9954940, 0.9999880
11.143986, 12.722222, 14.300459, 0.8511800, 0.9968380, 0.9999950
11.176368, 12.833333, 14.490299, 0.8590730, 0.9978100, 0.9999980
11.207861, 12.944444, 14.681028, 0.8664720, 0.9985030, 0.9999990
11.238582, 13.055556, 14.872529, 0.8734280, 0.9989900, 1
11.239341, 13.058332, 14.87732, 0.8735960, 0.999, 1
11.268629, 13.166667, 15.064705, 0.8799830, 0.9993270, 1
11.298084, 13.277778, 15.257472, 0.8861730, 0.9995580, 1
11.327018, 13.388889, 15.45076, 0.8920280, 0.9997130, 1
11.35549, 13.5, 15.64451, 0.8975760, 0.9998170, 1
11.383553, 13.611111, 15.838669, 0.9028380, 0.9998840, 1
11.41125, 13.722222, 16.033194, 0.9078340, 0.9999280, 1
11.438619, 13.833333, 16.228047, 0.9125810, 0.9999560, 1
11.465694, 13.944444, 16.423194, 0.9170960, 0.9999730, 1
11.492504, 14.055556, 16.618607, 0.9213910, 0.9999840, 1
11.519074, 14.166667, 16.81426, 0.9254790, 0.9999910, 1
11.545426, 14.277778, 17.01013, 0.9293720, 0.9999940, 1
11.57158, 14.388889, 17.206198, 0.9330780, 0.9999970, 1
11.597553, 14.5, 17.402447, 0.9366090, 0.9999980, 1
11.623361, 14.611111, 17.598862, 0.9399710, 0.9999990, 1
11.649017, 14.722222, 17.795427, 0.9431740, 0.9999990, 1
11.674534, 14.833333, 17.992133, 0.9462240, 1, 1
11.699923, 14.944444, 18.188966, 0.9491290, 1, 1
11.725194, 15.055556, 18.385917, 0.9518950, 1, 1
11.750355, 15.166667, 18.582978, 0.9545280, 1, 1
11.775415, 15.277778, 18.78014, 0.9570340, 1, 1
11.800381, 15.388889, 18.977397, 0.9594190, 1, 1
11.82526, 15.5, 19.17474, 0.9616870, 1, 1
11.850057, 15.611111, 19.372165, 0.9638430, 1, 1
11.874778, 15.722222, 19.569666, 0.9658940, 1, 1
11.899429, 15.833333, 19.767238, 0.9678420, 1, 1
11.924013, 15.944444, 19.964876, 0.9696920, 1, 1
11.948534, 16.055556, 20.162577, 0.9714490, 1, 1
11.972998, 16.166667, 20.360335, 0.9731170, 1, 1
11.997407, 16.277778, 20.558149, 0.9746990, 1, 1
12.021764, 16.388889, 20.756014, 0.9761990, 1, 1
12.046074, 16.5, 20.953926, 0.9776210, 1, 1 ];
%% Matlab GLM fitting
xWT = [5.5,16.5,11,13.8,10.1,14.7,10.4,11.7,9.7,7.3,7.8,8.1,12.2,8.5,11.8,11.7121,11.4083,11.1558,12.4633,12.2761,12.1107,11.9628,11.8291,11.7072,11.5952,11.4917,11.3955,11.3057,11.2214,11.1421]’;
yWT = [0,1,0,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1]’;
n = ones(size(yWT));
[b, dev, stats] = glmfit(xWT, [yWT, n], ‘binomial’, ‘Link’, ‘probit’);
wt = 5 : 0.05 : 17;
[y_fit, dylo, dyhi] = glmval(b, wt, ‘probit’, stats, ‘confidence’, 0.95);
mu_1 = -b(1) /b(2);
gradient = central_diff(y_fit, wt);
go = yWT == 1;
nogo = yWT == 0;
fig1 = figure;
plot(xWT(go), yWT(go), ‘ko’, ‘LineWidth’, 0.5, ‘MarkerFaceColor’, ‘g’, ‘MarkerSize’, 8)
hold on
plot(xWT(nogo), yWT(nogo), ‘ks’, ‘LineWidth’, 0.5, ‘MarkerFaceColor’, ‘r’, ‘MarkerSize’, 8)
p1 = plot(wt, y_fit, ‘-m’);
p2 = plot(wt, y_fit – dylo, ‘-k’);
plot(wt, y_fit + dyhi, ‘-k’)
p3 = plot(wt, gradient/max(gradient), ‘-‘, ‘Color’, 0.6*[1,1,1]);
xlim([5, 17]);
title(‘Wu and Tian Example’)
xlabel(‘Quantile (q, in units wt)’)
ylabel(‘Probability (p)’)
grid on; grid minor
mfw_pos = get(gcf, ‘Position’); mfw_pos(3) = mfw_pos(3) * 1.6; set(gcf, ‘Position’, mfw_pos); % Make Figure Wide (60% wider)
% These are the results from the R code "Gonogo"
% plot(R_output(:,2), R_output(:,5), ‘–b’)
p4 = plot(R_output(:,2), R_output(:,6), ‘–b’);
plot(R_output(:,2), R_output(:,4), ‘–b’)
p5 = plot(R_output(:,1), R_output(:,5), ‘–r’);
plot(R_output(:,3), R_output(:,5), ‘–r’)
legend([p1 p2 p3 p4 p5],{‘Logistic Fit’,’Confidence Bounds from glmval’,’diff of Logistic Fit’,’Confidence Interval about p’,’Confidence Interval about q’}, …
‘Location’, ‘east’)
mdl = fitglm(xWT, yWT, ‘Distribution’, ‘binomial’, ‘Link’, ‘probit’);
ci = coefCI(mdl, 0.95);
figure(fig1)
plot(wt, mdl.Link.Inverse([ones(size(wt’,1),1,"like",wt’) wt’] * ci(:,1)), ‘-c’, ‘DisplayName’, ‘from Matlab coefCI’)
plot(wt, mdl.Link.Inverse([ones(size(wt’,1),1,"like",wt’) wt’] * ci(:,2)), ‘-c’, ‘HandleVisibility’,’off’) I have results from a binary study. The study was analyzied by others using Gonogo (https://www2.isye.gatech.edu/~jeffwu/sensitivitytesting/), the prefered code developed by/for the government for such studies. My code for anlaysis is shown below. I am able to fit a logistic curve using glmfit (magentia line in plot). I then compute the confidence limits about the probablility p using glmval (black lines). These black line match well with the results given by Gonogo (dashed blue lines). However, I am unable to figure out how to compute the confidence limits about the quantile q (the Gonongo results are shown as dashed red lines). I tried using coefCI, with the results in cyan. It is doing something but I don’t understand exactly what, and it does not really match the dashed red lines that I am looking for. Does anyone know how I can compute the confidence limits about the quantile q? Your assistance is appreciated.
%% Output from Gonogo – Main code in next section
R_mu = 10.1707909;
R_sigma = 0.9344091;
R_b0 = -10.88473;
R_b1 = 1.070195;
R_output = [
1.124021, 5.5, 9.875979, 0, 0, 0.3761890
1.321891, 5.611111, 9.900331, 0, 1.e-06, 0.3861210
1.519710, 5.722222, 9.924735, 0, 1.e-06, 0.3961490
1.717474, 5.833333, 9.949193, 0, 2.e-06, 0.4062690
1.915181, 5.944444, 9.973708, 0, 3.e-06, 0.4164760
2.112825, 6.055556, 9.998286, 0, 5.e-06, 0.4267660
2.310404, 6.166667, 10.022929, 0, 9.e-06, 0.4371330
2.507913, 6.277778, 10.047643, 0, 1.5e-05, 0.4475740
2.705346, 6.388889, 10.072432, 0, 2.6e-05, 0.4580840
2.902698, 6.5, 10.097302, 0, 4.3e-05, 0.4686570
3.099963, 6.611111, 10.122259, 0, 7.e-05, 0.4792890
3.297135, 6.722222, 10.147309, 0, 0.000112, 0.4899760
3.494207, 6.833333, 10.17246, 0, 0.000177, 0.5007130
3.691170, 6.944444, 10.197719, 0, 0.000277, 0.5114950
3.888016, 7.055556, 10.223095, 0, 0.000428, 0.5223200
4.084734, 7.166667, 10.248599, 0, 0.000652, 0.5331820
4.281315, 7.277778, 10.274241, 0, 0.00098, 0.5440770
4.290992, 7.283250, 10.27551, 0, 0.001, 0.5446150
4.477745, 7.388889, 10.300033, 0, 0.001455000, 0.5550040
4.674012, 7.5, 10.325988, 0, 0.00213, 0.5659570
4.870099, 7.611111, 10.352123, 0, 0.003078000, 0.5769360
5.065991, 7.722222, 10.378454, 0, 0.004391000, 0.5879360
5.139437, 7.763912, 10.38839, 0, 0.005, 0.5920690
5.261667, 7.833333, 10.40500, 0, 0.006183000, 0.5989570
5.457105, 7.944444, 10.431784, 0, 0.008595000, 0.6099980
5.549510, 7.997030, 10.44455, 0, 0.01, 0.6152300
5.652280, 8.055556, 10.458831, 1.e-06, 0.01179600, 0.6210570
5.847164, 8.166667, 10.486169, 2.e-06, 0.01598400, 0.6321360
5.996179, 8.251749, 10.50732, 4.e-06, 0.02, 0.6406330
6.041725, 8.277778, 10.513831, 5.e-06, 0.02138800, 0.6432350
6.235924, 8.388889, 10.541854, 1.3e-05, 0.02826100, 0.6543570
6.278641, 8.413360, 10.54808, 1.6e-05, 0.03, 0.6568100
6.429717, 8.5, 10.570283, 3.1e-05, 0.03688200, 0.6655050
6.490555, 8.534934, 10.57931, 4.1e-05, 0.04, 0.6690160
6.623055, 8.611111, 10.599167, 7.3e-05, 0.04754300, 0.6766840
6.662517, 8.633825, 10.60513, 8.7e-05, 0.05, 0.6789740
6.808555, 8.717996, 10.62744, 0.00016, 0.06, 0.6874730
6.815879, 8.722222, 10.628566, 0.000165, 0.06054100, 0.6879010
6.936329, 8.791798, 10.64727, 0.000269, 0.07, 0.6949470
7.008118, 8.833333, 10.658548, 0.000356, 0.07616600, 0.6991630
7.050500, 8.857879, 10.66526, 0.00042, 0.08, 0.7016590
7.154124, 8.917977, 10.68183, 0.000622, 0.09, 0.7077800
7.199693, 8.944444, 10.689196, 0.000737, 0.09468800, 0.7104830
7.249320, 8.973297, 10.69727, 0.000884, 0.1, 0.7134330
7.337620, 9.024712, 10.71180, 0.001215000, 0.11, 0.7187020
7.390505, 9.055556, 10.720606, 0.001463000, 0.1163330, 0.7218710
7.420168, 9.072873, 10.72558, 0.001622000, 0.12, 0.7236530
7.497845, 9.118281, 10.73872, 0.002114000, 0.13, 0.7283370
7.571342, 9.161331, 10.75132, 0.002702000, 0.14, 0.7327920
7.580442, 9.166667, 10.752892, 0.002784000, 0.1412750, 0.7333450
7.641212, 9.202338, 10.76346, 0.003393000, 0.15, 0.7370500
7.707905, 9.241560, 10.77522, 0.004197000, 0.16, 0.7411360
7.769364, 9.277778, 10.786191, 0.005085000, 0.1696120, 0.7449230
7.771792, 9.279210, 10.78663, 0.005123000, 0.17, 0.7450730
7.833186, 9.315465, 10.79775, 0.00618, 0.18, 0.7488780
7.892348, 9.350477, 10.80861, 0.007377000, 0.19, 0.7525660
7.949501, 9.384372, 10.81924, 0.008722000, 0.2, 0.7561500
7.957108, 9.388889, 10.82067, 0.008916000, 0.2013560, 0.7566280
8.004840, 9.417264, 10.82969, 0.01022500, 0.21, 0.7596410
8.058530, 9.449247, 10.83996, 0.01189400, 0.22, 0.7630490
8.110717, 9.480406, 10.85009, 0.01373800, 0.23, 0.7663830
8.143472, 9.5, 10.856528, 0.01501800, 0.2364170, 0.7684870
8.161530, 9.510815, 10.86010, 0.01576600, 0.24, 0.7696500
8.211082, 9.540542, 10.87000, 0.01798500, 0.25, 0.7728580
8.259474, 9.569643, 10.87981, 0.02040400, 0.26, 0.7760110
8.306795, 9.598173, 10.88955, 0.02303000, 0.27, 0.7791170
8.328215, 9.611111, 10.894008, 0.02431000, 0.2745980, 0.7805300
8.353126, 9.626179, 10.89923, 0.02587200, 0.28, 0.7821790
8.398541, 9.653703, 10.90887, 0.02893700, 0.29, 0.7852020
8.443105, 9.680786, 10.91847, 0.03223200, 0.3, 0.7881910
8.486879, 9.707464, 10.92805, 0.03576400, 0.31, 0.7911490
8.511040, 9.722222, 10.933405, 0.03784500, 0.3155940, 0.7927920
8.529915, 9.733769, 10.93762, 0.03953900, 0.32, 0.7940800
8.572265, 9.759732, 10.94720, 0.04356500, 0.33, 0.7969870
8.613974, 9.785382, 10.95679, 0.04784700, 0.34, 0.7998740
8.655085, 9.810744, 10.96640, 0.05239100, 0.35, 0.8027430
8.691586, 9.833333, 10.975081, 0.05670600, 0.3589950, 0.8053110
8.695636, 9.835844, 10.97605, 0.05720200, 0.36, 0.8055970
8.735663, 9.860704, 10.98575, 0.06228500, 0.37, 0.8084400
8.775199, 9.885347, 10.99550, 0.06764600, 0.38, 0.8112720
8.814276, 9.909793, 11.00531, 0.07328800, 0.39, 0.8140970
8.852923, 9.934061, 11.01520, 0.07921400, 0.4, 0.8169180
8.869412, 9.944444, 11.019477, 0.08185100, 0.4042990, 0.8181290
8.891166, 9.958171, 11.02518, 0.08543000, 0.41, 0.8197360
8.929030, 9.982140, 11.03525, 0.09193600, 0.42, 0.8225530
8.966540, 10.005985, 11.04543, 0.09873700, 0.43, 0.8253720
9.003718, 10.029724, 11.05573, 0.1058330, 0.44, 0.8281950
9.040583, 10.053372, 11.06616, 0.1132270, 0.45, 0.8310240
9.043979, 10.055556, 11.067132, 0.1139260, 0.4509250, 0.8312860
9.077157, 10.076945, 11.07673, 0.1209200, 0.46, 0.8338610
9.113456, 10.100458, 11.08746, 0.1289110, 0.47, 0.8367070
9.149500, 10.123927, 11.09835, 0.1372010, 0.48, 0.8395650
9.185304, 10.147366, 11.10943, 0.1457900, 0.49, 0.8424370
9.214635, 10.166667, 11.118699, 0.1530890, 0.4982390, 0.8448150
9.220884, 10.170791, 11.12070, 0.1546750, 0.5, 0.8453250
9.256255, 10.194216, 11.13218, 0.1638560, 0.51, 0.8482300
9.291430, 10.217655, 11.14388, 0.1733300, 0.52, 0.8511540
9.326423, 10.241124, 11.15583, 0.1830940, 0.53, 0.8540990
9.361246, 10.264637, 11.16803, 0.1931430, 0.54, 0.8570680
9.380601, 10.277778, 11.174955, 0.1988720, 0.5455780, 0.8587350
9.395911, 10.28821, 11.18051, 0.2034750, 0.55, 0.8600610
9.430430, 10.311858, 11.19329, 0.2140840, 0.56, 0.8630820
9.464812, 10.335597, 11.20638, 0.2249640, 0.57, 0.8661300
9.499068, 10.359442, 11.21982, 0.2361090, 0.58, 0.8692090
9.533207, 10.383411, 11.23362, 0.2475120, 0.59, 0.8723210
9.540967, 10.388889, 11.236811, 0.2501450, 0.5922770, 0.8730340
9.567238, 10.407521, 11.24780, 0.2591660, 0.6, 0.8754650
9.601170, 10.431789, 11.26241, 0.2710620, 0.61, 0.8786460
9.635010, 10.456235, 11.27746, 0.2831900, 0.62, 0.8818630
9.668765, 10.480878, 11.29299, 0.2955420, 0.63, 0.8851190
9.694703, 10.5, 11.305297, 0.3051990, 0.6377000, 0.8876530
9.702443, 10.505738, 11.30903, 0.3081070, 0.64, 0.8884150
9.736049, 10.530838, 11.32563, 0.3208730, 0.65, 0.8917520
9.769590, 10.55620, 11.34281, 0.3338290, 0.66, 0.8951320
9.803071, 10.58185, 11.36063, 0.3469630, 0.67, 0.8985540
9.836498, 10.607813, 11.37913, 0.3602620, 0.68, 0.9020210
9.840710, 10.611111, 11.381512, 0.3619500, 0.6812610, 0.9024620
9.869875, 10.634118, 11.39836, 0.3737120, 0.69, 0.9055330
9.903207, 10.660796, 11.41838, 0.3872990, 0.7, 0.9090890
9.936498, 10.687879, 11.43926, 0.4010080, 0.71, 0.9126900
9.969753, 10.715403, 11.46105, 0.4148250, 0.72, 0.9163350
9.977900, 10.722222, 11.466545, 0.4182270, 0.7224510, 0.9172350
10.002975, 10.743409, 11.48384, 0.4287350, 0.73, 0.9200220
10.03617, 10.771939, 11.50771, 0.4427220, 0.74, 0.9237510
10.069341, 10.80104, 11.53274, 0.4567710, 0.75, 0.9275180
10.102495, 10.830767, 11.55904, 0.4708670, 0.76, 0.9313200
10.105323, 10.833333, 11.561344, 0.4720710, 0.7608530, 0.9316460
10.135637, 10.861176, 11.58672, 0.4849950, 0.77, 0.9351540
10.168774, 10.892335, 11.61590, 0.4991390, 0.78, 0.9390130
10.201916, 10.924318, 11.64672, 0.5132860, 0.79, 0.9428930
10.222317, 10.944444, 11.666572, 0.5219880, 0.7961530, 0.9452870
10.235074, 10.95721, 11.67934, 0.5274240, 0.8, 0.9467850
10.268263, 10.991105, 11.71395, 0.5415400, 0.81, 0.9506800
10.301499, 11.026116, 11.75073, 0.5556240, 0.82, 0.9545670
10.328631, 11.055556, 11.78248, 0.5670700, 0.8281480, 0.9577200
10.334807, 11.062372, 11.78994, 0.5696680, 0.83, 0.9584350
10.368215, 11.100021, 11.83183, 0.5836670, 0.84, 0.9622680
10.401762, 11.139244, 11.87673, 0.5976170, 0.85, 0.9660510
10.42447, 11.166667, 11.908864, 0.6069910, 0.8567390, 0.9685630
10.435495, 11.180251, 11.92501, 0.6115210, 0.86, 0.9697650
10.469477, 11.223301, 11.97712, 0.6253840, 0.87, 0.9733900
10.50379, 11.268709, 12.03363, 0.6392200, 0.88, 0.9769020
10.510459, 11.277778, 12.045096, 0.6418890, 0.8819300, 0.9775650
10.538537, 11.31687, 12.09520, 0.6530470, 0.89, 0.9802770
10.57386, 11.368284, 12.16271, 0.6668980, 0.9, 0.9834860
10.587526, 11.388889, 12.190252, 0.6721970, 0.9038150, 0.9846610
10.609944, 11.423605, 12.23727, 0.6808150, 0.91, 0.9865000
10.647043, 11.483703, 12.32036, 0.6948630, 0.92, 0.9892890
10.656749, 11.5, 12.343251, 0.6984920, 0.9225610, 0.9899630
10.685514, 11.549784, 12.41405, 0.7091330, 0.93, 0.9918190
10.719233, 11.611111, 12.502989, 0.7213780, 0.9383930, 0.9937180
10.725874, 11.623586, 12.52130, 0.7237600, 0.94, 0.9940570
10.768913, 11.707757, 12.64660, 0.7389480, 0.95, 0.9959710
10.776016, 11.722222, 12.668428, 0.7414130, 0.9515760, 0.9962410
10.815924, 11.806648, 12.79737, 0.7550340, 0.96, 0.9975300
10.828023, 11.833333, 12.838644, 0.7590860, 0.9624000, 0.9978490
10.869256, 11.928222, 12.98719, 0.7726170, 0.97, 0.9987110
10.876046, 11.944444, 13.012843, 0.7748040, 0.9711620, 0.9988230
10.920748, 12.055556, 13.190363, 0.7888970, 0.9781560, 0.9993840
10.933957, 12.089833, 13.24571, 0.7929600, 0.98, 0.9995000
10.96268, 12.166667, 13.370653, 0.8016350, 0.9836590, 0.9996920
11.002292, 12.277778, 13.553264, 0.8132320, 0.9879300, 0.9998530
11.025138, 12.344552, 13.66397, 0.8197250, 0.99, 0.9999070
11.039952, 12.388889, 13.737825, 0.8238590, 0.9911970, 0.9999330
11.075964, 12.5, 13.924036, 0.8336550, 0.9936610, 0.9999700
11.100291, 12.577669, 14.05505, 0.8400700, 0.995, 0.9999840
11.110574, 12.611111, 14.111649, 0.8427320, 0.9954940, 0.9999880
11.143986, 12.722222, 14.300459, 0.8511800, 0.9968380, 0.9999950
11.176368, 12.833333, 14.490299, 0.8590730, 0.9978100, 0.9999980
11.207861, 12.944444, 14.681028, 0.8664720, 0.9985030, 0.9999990
11.238582, 13.055556, 14.872529, 0.8734280, 0.9989900, 1
11.239341, 13.058332, 14.87732, 0.8735960, 0.999, 1
11.268629, 13.166667, 15.064705, 0.8799830, 0.9993270, 1
11.298084, 13.277778, 15.257472, 0.8861730, 0.9995580, 1
11.327018, 13.388889, 15.45076, 0.8920280, 0.9997130, 1
11.35549, 13.5, 15.64451, 0.8975760, 0.9998170, 1
11.383553, 13.611111, 15.838669, 0.9028380, 0.9998840, 1
11.41125, 13.722222, 16.033194, 0.9078340, 0.9999280, 1
11.438619, 13.833333, 16.228047, 0.9125810, 0.9999560, 1
11.465694, 13.944444, 16.423194, 0.9170960, 0.9999730, 1
11.492504, 14.055556, 16.618607, 0.9213910, 0.9999840, 1
11.519074, 14.166667, 16.81426, 0.9254790, 0.9999910, 1
11.545426, 14.277778, 17.01013, 0.9293720, 0.9999940, 1
11.57158, 14.388889, 17.206198, 0.9330780, 0.9999970, 1
11.597553, 14.5, 17.402447, 0.9366090, 0.9999980, 1
11.623361, 14.611111, 17.598862, 0.9399710, 0.9999990, 1
11.649017, 14.722222, 17.795427, 0.9431740, 0.9999990, 1
11.674534, 14.833333, 17.992133, 0.9462240, 1, 1
11.699923, 14.944444, 18.188966, 0.9491290, 1, 1
11.725194, 15.055556, 18.385917, 0.9518950, 1, 1
11.750355, 15.166667, 18.582978, 0.9545280, 1, 1
11.775415, 15.277778, 18.78014, 0.9570340, 1, 1
11.800381, 15.388889, 18.977397, 0.9594190, 1, 1
11.82526, 15.5, 19.17474, 0.9616870, 1, 1
11.850057, 15.611111, 19.372165, 0.9638430, 1, 1
11.874778, 15.722222, 19.569666, 0.9658940, 1, 1
11.899429, 15.833333, 19.767238, 0.9678420, 1, 1
11.924013, 15.944444, 19.964876, 0.9696920, 1, 1
11.948534, 16.055556, 20.162577, 0.9714490, 1, 1
11.972998, 16.166667, 20.360335, 0.9731170, 1, 1
11.997407, 16.277778, 20.558149, 0.9746990, 1, 1
12.021764, 16.388889, 20.756014, 0.9761990, 1, 1
12.046074, 16.5, 20.953926, 0.9776210, 1, 1 ];
%% Matlab GLM fitting
xWT = [5.5,16.5,11,13.8,10.1,14.7,10.4,11.7,9.7,7.3,7.8,8.1,12.2,8.5,11.8,11.7121,11.4083,11.1558,12.4633,12.2761,12.1107,11.9628,11.8291,11.7072,11.5952,11.4917,11.3955,11.3057,11.2214,11.1421]’;
yWT = [0,1,0,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1]’;
n = ones(size(yWT));
[b, dev, stats] = glmfit(xWT, [yWT, n], ‘binomial’, ‘Link’, ‘probit’);
wt = 5 : 0.05 : 17;
[y_fit, dylo, dyhi] = glmval(b, wt, ‘probit’, stats, ‘confidence’, 0.95);
mu_1 = -b(1) /b(2);
gradient = central_diff(y_fit, wt);
go = yWT == 1;
nogo = yWT == 0;
fig1 = figure;
plot(xWT(go), yWT(go), ‘ko’, ‘LineWidth’, 0.5, ‘MarkerFaceColor’, ‘g’, ‘MarkerSize’, 8)
hold on
plot(xWT(nogo), yWT(nogo), ‘ks’, ‘LineWidth’, 0.5, ‘MarkerFaceColor’, ‘r’, ‘MarkerSize’, 8)
p1 = plot(wt, y_fit, ‘-m’);
p2 = plot(wt, y_fit – dylo, ‘-k’);
plot(wt, y_fit + dyhi, ‘-k’)
p3 = plot(wt, gradient/max(gradient), ‘-‘, ‘Color’, 0.6*[1,1,1]);
xlim([5, 17]);
title(‘Wu and Tian Example’)
xlabel(‘Quantile (q, in units wt)’)
ylabel(‘Probability (p)’)
grid on; grid minor
mfw_pos = get(gcf, ‘Position’); mfw_pos(3) = mfw_pos(3) * 1.6; set(gcf, ‘Position’, mfw_pos); % Make Figure Wide (60% wider)
% These are the results from the R code "Gonogo"
% plot(R_output(:,2), R_output(:,5), ‘–b’)
p4 = plot(R_output(:,2), R_output(:,6), ‘–b’);
plot(R_output(:,2), R_output(:,4), ‘–b’)
p5 = plot(R_output(:,1), R_output(:,5), ‘–r’);
plot(R_output(:,3), R_output(:,5), ‘–r’)
legend([p1 p2 p3 p4 p5],{‘Logistic Fit’,’Confidence Bounds from glmval’,’diff of Logistic Fit’,’Confidence Interval about p’,’Confidence Interval about q’}, …
‘Location’, ‘east’)
mdl = fitglm(xWT, yWT, ‘Distribution’, ‘binomial’, ‘Link’, ‘probit’);
ci = coefCI(mdl, 0.95);
figure(fig1)
plot(wt, mdl.Link.Inverse([ones(size(wt’,1),1,"like",wt’) wt’] * ci(:,1)), ‘-c’, ‘DisplayName’, ‘from Matlab coefCI’)
plot(wt, mdl.Link.Inverse([ones(size(wt’,1),1,"like",wt’) wt’] * ci(:,2)), ‘-c’, ‘HandleVisibility’,’off’) generalized linear model, statistics, confidence limits MATLAB Answers — New Questions