820 PRINT "Press Enter to continue: "; : INPUT D
830 ' Menu 1
840 ' ##########
850 CLEAR 200
860 CLS : PARA = 0: PRINT " MENU 1 (main)": PRINT : PRINT
870 PRINT
890 PRINT " MENU 3 (File creation)..........3"
900 PRINT " Probit analysis of a file.......4"
910 PRINT " Parallelism test................5"
920 PRINT " Resistance ratio for"
930 PRINT " non parallel lines............6"
940 PRINT " List files......................7"
950 PRINT " Quit............................8"
960 PRINT : PRINT " Please choose an option: ----------------->";
970 D=INKEY: D = VAL(D): D = ABS(D)
980 IF D < 3 OR D > 8 THEN GOTO 970
990 PRINT D
1000 F = 1 / SQR(2 * 3.1415927#)
1010 ON D GOTO 1060, 1030, 1050, 1070, 6860, 10720, 10530, 10630
1020 PRINT "Wrong number": GOTO 960
1030 CLEAR 200: GOSUB 6560
1040 CLS : GOTO 3400
1050 GOTO 8730
1060 PRINT "This is MENU 1": GOTO 960
1070 CLEAR 500: PRINT : PRINT : PRINT " PROBIT ANALYSIS": PRINT
1080 INPUT "Name of file to analyze: "; S1
1090 PRINT : INPUT "In which drive (A, B or C) is the file located (A = default):"; W11100IFW1 <> "b" AND W1<>"B"ANDW1 <> "c" AND W1<>"C"THENW1 = "a"
1110 ' Lecture Du Fichier Demande
1120 ' ################################
1130 ON ERROR GOTO 1170: OPEN "I", 1, W1+":"+S1
1140 ON ERROR GOTO 0
1150 INPUT #1, S2,N,S4: DIM X(N), RAV(N), T1(N), P: RESUME 1130
1180 PRINT "This file does not exist in this drive": RESUME 1080
1190 FOR I = 1 TO N
1200 INPUT #1, H(I), G(I), X(I)
1210 NEXT I
1220 INPUT #1, TT, MT: CLOSE 1
1230 CLS : PRINT : PRINT : PRINT "Name of the file: "; S1:PRINTS2: PRINT S4
1240 IF TT = 0 THEN PMT = 0 ELSE PMT = MT / TT
1250 PRINT "% control mortality :"; PMT * 100; " ("; MT; "/"; TT; ") ";
1260 IF PMT <> 0 THEN PRINT "(first estimation)" ELSE PRINT
1270 IF PMT > 0 THEN MP = PMT + .001 ELSE MP = PMT
1280 IF PMT < 0 THEN PRINT "error mortality; please correct and retry": GOTO 850
1290 ' Rangement des Points en Fonction des concentrations croissantes
1300 ' ###############################################################
1310 '
1320 FOR I = 1 TO N - 1
1330 FOR J = I + 1 TO N
1340 IF X(I) < X(J) GOTO 1380
1350 C1 = X(I): C2 = H(I): C3 = G(I)
1360 X(I) = X(J): H(I) = H(J): G(I) = G(J)
1370 X(J) = C1: H(J) = C2: G(J) = C3
1380 NEXT J
1390 NEXT I
1400 C12 = 1: '(C12 devient le multiplicateur du compteur d'itrations.)
1410 '
1420 ' Verification que le nombre de mort est inf. au total
1430 ' D'individus Testes
1440 ' #####################################################
1450 FOR I = 1 TO N
1460 IF G(I) > H(I) THEN PRINT "Point #"; I; " is incorrect: "; G(I); " deads out of "; H(I); " tested": GOTO 2320
1470 NEXT I
1480 ' Impression du fichier brut
1490 ' ##########################
1500 PRINT STRING(58, 95)
1510 PRINT " N Killed Total Dose Observed Corrected"
1520 PRINT " mortality mortality"
1530 IF PMT = 0 THEN GOTO 1550
1540 PRINT " (1st estimation)"
1550 PRINT STRING(58, 95)
1560 FOR I = 1 TO N
1570 ' Calcul de la Mortalite Corrigee (Formule D'Abbott).
1580 ' ####################################################
1590 GOSUB 1610
1600 GOTO 1650
1610 SU(I) = 1 - (G(I) / H(I) - MP) / (1 - MP)
1620 IF 1 - SU(I) < 0 THEN SU(I) = 1
1630 IF SU(I) < 0 THEN SU(I) = 0
1640 RETURN
1650 US = INT((1 - SU(I)) * 1000 + .5) / 10
1660 PRINT I; TAB(7); G(I); TAB(14); H(I); TAB(24); USING "###.######"; X(I);
1670 PRINT TAB(38); INT(G(I) / H(I) * 1000 + .5) / 10; TAB(50); USING "###.##";US
1680 NEXT I
1690 PRINT STRING(58, 95)
1700 ' Calcul de L'abscisse
1710 ' ####################
1720 M = 0: F = 1 / SQR(2 * 3.1415927#)
1730 PRINT : PRINT "Log transformation of the dose (-1 = NO, Enter = YES) "; : INPUT D
1740 IF D <> -1 THEN D = 1: PRINT TAB(45); "----> Yes" ELSE D = 0: PRINT TAB(45); "---> No"
1750 ' Les Doses Sont Converties en Unite Log
1760 ' #####################################################
1770 IF D <> 1 GOTO 1830
1780 DD = 1: T = 0
1790 FOR I = 1 TO N
1800 X(I) = LOG(X(I))
1810 NEXT I
1820 ' Elimination des points extremes doubles
1830 IF SU(1) = 1 AND SU(1) = SU(2) THEN GOTO 1850
1840 GOTO 1900
1850 FOR J = 1 TO N - 1
1860 X(J) = X(J + 1): H(J) = H(J + 1): G(J) = G(J + 1)
1870 SU(J) = SU(J + 1): NEXT J
1880 X(N) = 0: G(N) = 0: H(N) = 0: SU(N) = 0: N = N - 1
1890 GOTO 1830
1900 IF G(N) = H(N) AND G(N - 1) = H(N - 1) THEN 1920
1910 GOTO 1940
1920 G(N) = 0: H(N) = 0: SU(N) = 0: X(N) = 0: N = N - 1
1930 GOTO 1900
1940 N3 = N: ' N3= Nombre d epoints prsents dans l'analyse
1950 FOR I = 1 TO N
1960 ' Calcul du Probit(Approximation de L'Inverse de la
1970 ' Fonction de Repartition)
1980 ' #################################################
1990 IF SU(I) = 1 OR SU(I) = 0 THEN N3 = N3 - 1: GOTO 2120
2000 M = M + X(I): ' Somme des abscisses
2010 PB = 1 - SU(I)
2020 GOSUB 2040
2030 GOTO 2110
2040 GN = INT(2 * PB)
2050 PB = GN * (1 - 2 * PB) + PB
2060 T2 = LOG(1 / (PB * PB)): T1 = SQR(T2)
2070 L(I) = T1 - (2.515517 + .802853 * T1 + .010328 * T2) / (1 + 1.432788 * T1 + .189269 * T2 + .001308 * T1 * T2)
2080 L(I) = (2 * GN - 1) * L(I) + 5: RETURN
2090 REM l(i)=ordonnee en probit du % de survivant
2100 REM y(i)=ordonnee en probit pour le calcul
2110 T = T + L(I)
2120 NEXT I
2130 IF N3 <= 2 THEN PRINT "Not enough points for a regression line. At least 3 points between 0 and 100% mortality are needed": GOTO 2320
2140 ' Calcul D'une droite De Regression Non Ponderee
2150 ' ##############################################
2160 M = M / N3: T = T / N3: S = 0: U = 0: ' M: moyenne des abscisses
2170 FOR I = 1 TO N
2180 IF SU(I) = 1 OR SU(I) = 0 THEN GOTO 2210
2190 S = S + L(I) * (X(I) - M)
2200 U = U + (X(I) - M) ^ 2
2210 Y2(I) = 0
2220 NEXT I
2230 A = T: C = S / U
2240 REM Droite Regression Non Ponderee : y=a+c(x-m)
2250 XXX = 0: PRINT "iterations ---->";
2260 ON ERROR GOTO 2280
2270 GOTO 2330
2280 IF ERL = 2480 OR ERL = 2490 OR ERL = 2500 OR ERL = 2510 THEN RESUME 2310
2290 PRINT "Error number"; ERR; " line number"; ERL; " occurred": RESUME 2300
2300 STOP
2310 PRINT "You cannot analyze this file. One or more points are too far from the calculated line. If possible, remove them and re-run the analysis"
2320 INPUT "Press Enter to go back to Menu 1"; W9: GOTO 850
2330 Q = 0
2340 V = N3 - 2: DDL = V: ' calcul des ddl(ddl--> ddl avant regroupements)
2350 ' Recherche De La Meilleur Droite De Regression Ponderee.
2360 ' #######################################################
2370 FOR I = 1 TO N
2380 Y(I) = A + C * (X(I) - M) - 5
2390 GOSUB 2420
2400 IF Q < 1E-10 OR Q > 1E+10 OR Z < 1E-10 OR Z > 1E+10 THEN GOTO 2310
2410 GOTO 2460
2420 Z = F * EXP(-(Y(I) * Y(I)) / 2)
2430 Q = 1 / (1 + .33267 * ABS(Y(I))): Q3 = Q * Q: Q = Z * (.4361836 * Q - .1201676 * Q3 + .937298 * Q * Q3)
2440 IF Y(I) < 0 THEN Q = 1 - Q
2450 RETURN
2460 VA(I) = H(I) * (1 - Q) * (1 - MP) + MP * H(I): 'decomposition en Evenements Independants.
2470 IF SU(I) = 1 OR SU(I) = 0 THEN GOTO 2520
2480 Y2(I) = Y(I) + 5 + (Q - SU(I)) / Z
2490 P(I) = ((Z * Z) / (Q * (1 - Q + PMT / (1 - PMT)))) * H(I)
2500 T1(I) = Q / Z * P(I)
2510 O(I) = (G(I) - VA(I)) * (G(I) - VA(I)) / H(I) / Q / (1 - Q): OO(I) = O(I)
2520 NEXT I
2530 T = 0: M = 0: Q1 = 0: W = 0: T2 = 0: T3 = 0: T4 = 0: T5 = 0: T6 = 0: T7 = 0: T8 = 0
2540 FOR I = 1 TO N
2550 IF SU(I) = 1 OR SU(I) = 0 THEN GOTO 2600
2560 T2 = T1(I) + T2: T3 = T3 + X(I) * T1(I): T4 = T4 + T1(I) * T1(I) / P(I)
2570 Q1 = Q1 + O(I): M = M + P(I) * X(I)
2580 T = T + P(I) * Y2(I): W = W + P(I)
2590 T5 = T5 + Y2(I) * T1(I)
2600 NEXT I
2610 M = M / W: T = T / W: A = 0: C = 0
2620 FOR I = 1 TO N
2630 IF SU(I) = 1 OR SU(I) = 0 THEN GOTO 2660
2640 A = A + P(I) * Y2(I) * (X(I) - M): C = C + P(I) * (X(I) - M) ^ 2
2650 T8 = T8 + P(I) * (Y2(I) - T) ^ 2
2660 NEXT I
2670 XXX = XXX + 1: PRINT XXX;
2680 IF XXX > C12 * 100 THEN PRINT "No convergence at"; C12 * 100; " iterations.": PRINT " Do you want to continue (Y or N) ?"; ELSE GOTO 2710
2690 INPUT W9
2700 IF W9="Y"ORW9 = "y" THEN C12 = C12 + 1 ELSE PRINT " ... OK": GOTO 2320
2710 U = C: C = A / C: LA = A: A = T
2720 IF PMT = 0 THEN GOTO 2850
2730 T6 = T2 / W: T3 = T3 - M * W * T6: T7 = PMT - MP: T5 = T5 - T2 * A + (T7 / MP) * TT
2740 T4 = T4 - T2 * T6 + (1 - MP) / MP * TT: T8 = T8 + TT * T7 / MP * T7 / (1 - MP)
2750 C1 = 1 / (U - T3 / T4 * T3): C2 = 1 / (T3 - T4 / T3 * U): C3 = 1 / (T4 - T3 / U * T3)
2760 C = C1 * LA + C2 * T5: ' c=nouvelle pente
2770 C4 = C2 * LA + C3 * T5: A = A - C4 * T6: ' a= nouvelle moyenne des y
2780 MP = MP + C4 * (1 - MP): 'c=c+delta(c)
2790 GOTO 2850
2800 REM U=S w(x-m)^2 =S wx^2 -(Swx)^2/Sw=Sxx
2810 AD = A
2820 IF PMT = 0 THEN PRINT : GOTO 2950 ELSE PRINT
2830 PRINT "Natural Mortality (Last Estimation):"; INT(MP * 1000 + .5) / 10; "%"
2840 GOTO 2950
2850 D = 0
2860 FOR I = 1 TO N
2870 IF SU(I) = 1 OR SU(I) = 0 THEN GOTO 2900
2880 D = D + ABS(Y(I) + 5 - (A + C * (X(I) - M)))
2890 GOSUB 1610
2900 NEXT I
2910 IF D > N * .0001 THEN GOTO 2330
2920 GOTO 2810
2930 ' Test X2
2940 ' #############
2950 Q2 = Q1
2960 PR = 1: HE = 1: GOSUB 3140
2970 IF E < .95 THEN GOTO 3110
2980 BEEP: CLS : LOCATE 25, 1: PRINT "CHI2="; USING "###.####";Q1;
2981 PRINT ", df="; V; ", Probability="; USING "#.####";E: LOCATE 1, 1: PRINT "It is unlikely that these data are fit by a line.": PRINT
2990 PRINT " However, the high CHI2 value may be due to a very low or very high expected"
3000 PRINT " number of dead (check the CHI2 contribution of each point with option 7). If this is the case, you could pool extreme points with option 8 (the presence";
3010 PRINT " of at least a star is required). If after this operation the CHI2 is still too high, check the following points:"
3020 PRINT
3030 PRINT " -If there is a systematic heterogeneity (several consecutive points below or"
3040 PRINT " above the calculated line, presence of a plateau, etc.), a line is certainly not a good representation for these data. It is better to stop the analysis";
3050 PRINT " here.": PRINT
3060 PRINT " -If there is no systematic heterogeneity, and you have good reasons to think "
3070 PRINT " that the heterogeneity responsible for the high CHI2 is only due to environ- mental factors, you have the possibility to continue the analysis using";
3080 PRINT " option 9. This will calculate an heterogeneity factor which will be automa- tically introduced in the computed variances and confidence intervals."
3090 PRINT : INPUT "Press Enter to continue analysis: "; ZW: CLS
3100 W7 = 8: CLS : PRINT : PRINT : PRINT : PRINT "Choose one of the following:": PRINT : PRINT : PRINT : GOTO 3480
3110 PRINT "The data are well represented by a line. Option 6 of Menu 2 is suggested.": EH = 1: GOSUB 6390
3120 LOCATE 25, 1: PRINT "Press * to print out this screen": GOSUB 10660
3130 CLS : GOTO 3400
3140 E = 1: VX = V
3150 IF Q1 < 0 OR V < 1 THEN PRINT "CHI2 ERROR": STOP
3160 IF Q1 = 0 THEN PRINT "p(0,"; V; ")=0"
3170 ON ERROR GOTO 3310
3180 J = 1
3190 FOR I = V TO 2 STEP -2
3200 J = J * I: NEXT I
3210 A = Q1 ^ (INT((V + 1) / 2)) * EXP(-Q1 / 2) / J
3220 IF INT(V / 2) = V / 2 GOTO 3240
3230 B = SQR(2 / Q1 / 3.1415927#): GOTO 3250
3240 B = 1
3250 S = 1: T = 1
3260 VX = VX + 2: T = T * Q1 / VX
3270 IF T > 1E+30 THEN E = 1: GOTO 3330
3280 IF T < .00001 GOTO 3300
3290 S = S + T: GOTO 3260
3300 E = A * B * S: GOTO 3320
3310 E = 1: RESUME 3330
3320 IF E = 0 THEN E = 1
3330 PRINT "p(CHI2=";USING "###.####";Q1;
3331 PRINT ", df="; V; ")=";USING "#.####"; E: ON ERROR GOTO 0: RETURN
3340 Q2 = Q1