Stepwise Multiple Linear Regression


Language: GWBasic.

Objective: Performs stepwise multiple linear regression.


***** Begin of Program Listing *****

10 ON ERROR GOTO 9000
100 CLS : KEY OFF: SCREEN 1: SCREEN 0: LOCATE 5
110 PRINT STRING$(40, "*"); : PRINT "*"; TAB(40); "*";
115 BF$ = "L   O   T   H   A   R": PRINT "*"; TAB((40 - LEN(BF$)) / 2 + 1); BF$; TAB(40); "*"; : PRINT "*"; TAB(40); "*"; : PRINT "*"; TAB(40); "*";
120 BF$ = "STEPWISE MULTIPLE LINEAR REGRESSION": PRINT "*"; TAB((40 - LEN(BF$)) / 2 + 1); BF$; TAB(40); "*"; : PRINT "*"; TAB(40); "*"; : PRINT "*"; TAB(40); "*";
130 BF$ = "Developed by:": PRINT "*"; TAB((40 - LEN(BF$)) / 2 + 1); BF$; TAB(40); "*"; : PRINT "*"; TAB(40); "*";
140 BF$ = "Antonio Augusto GORNI - OTPL": PRINT "*"; TAB((40 - LEN(BF$)) / 2 + 1); BF$; TAB(40); "*"; : PRINT "*"; TAB(40); "*";
150 BF$ = "Lattest Revision: 27/05/1990": PRINT "*"; TAB((40 - LEN(BF$)) / 2 + 1); BF$; TAB(40); "*"; : PRINT "*"; TAB(40); "*"; : PRINT STRING$(40, "*");
160 FOR I = 1 TO 50000: NEXT I: SCREEN 2: SCREEN 0
1000 CLS : B$ = CHR$(7)
1250 NOBS = 250: REM NO. MAX DE OBSERVACOES/VARIAVEL
1260 NVAR = 28: REM NO.MAX DE VARIAVEIS
1270 DIM X(NVAR, NOBS), WT(NOBS), WSUM(NVAR), WMEAN(NVAR)
1280 DIM R(NVAR, NVAR), SIGMA(NVAR), B(NVAR), SB(NVAR)
1290 DIM VNAM$(NVAR), T95(33), Y(NOBS), E1(NVAR - 1, NVAR - 1)
1300 FOR I = 1 TO 33: REM INICIALIZAR A MATRIZ DA ESTAT. T
1310 READ T95(I)
1320 NEXT I
1330 DATA 12.706,4.303,3.182,2.776,2.571,2.447,2.365
1340 DATA 3.306,2.262,2.228,2.201,2.179,2.16,2.145
1350 DATA 2.131,2.12,2.11,2.101,2.093,2.086,2.08
1360 DATA 2.074,2.069,2.064,2.06,2.056,2.052,2.048
1370 DATA 2.045,2.042,2.021,2.0,1.98
1410 FOR I = 1 TO NOBS
1420 WT(I) = 1
1430 NEXT I
1440 CLS : LOCATE 12: INPUT "List Program Options (Y/N)? ", Y$
1445 IF Y$ <> "Y" AND Y$ <> "N" THEN PRINT B$: GOTO 1440
1450 IF (Y$ <> "Y") THEN GOTO 1480
1460 GOSUB 7440
1470 GOTO 1480
1480 PRINT : PRINT
1490 CLS : LOCATE 10: INPUT "Data Input via Keyboard or Disk (K/D)? ", K$
1500 IF (K$ <> "K") AND (K$ <> "D") THEN PRINT B$: GOTO 1490
1510 IF K$ = "K" THEN 1540
1520 GOSUB 6960
1530 GOTO 1910
1540 CLS : INPUT "Name of the Dependent Variable? ", TEMP$
1550 PRINT : INPUT "Number of Independent Variables? ", IV
1560 IF (IV > 0) AND (IV < NVAR) THEN 1580
1570 PRINT : PRINT "Must be Positive and <"; NVAR; "!": GOTO 1550
1580 VNAM$(IV + 1) = TEMP$
1590 PRINT : FOR I = 1 TO IV
1600 PRINT "Name of the Independent Variable #"; I; ": ";
1610 INPUT "", VNAM$(I)
1620 NEXT I
1630 PRINT : INPUT "Do You Want to Perform Forecasting (Y/N)? ", F$
1640 IF (F$ <> "Y") AND (F$ <> "N") THEN PRINT B$: GOTO 1630
1650 IF F$ = "N" THEN I4 = 0: GOTO 1710
1660 PRINT : INPUT "Number of Periods to Forecast? ", I4
1670 PRINT : PRINT "Number of Points for Each Independent Variable,"
1690 INPUT "Incluinding Points to Be Used in Forecasting? ", IO
1700 GOTO 1730
1710 PRINT : PRINT "Number of Points for Each Independent Variable? ";
1720 INPUT "", IO
1730 IF IO >= (IV + 2 + I4) THEN 1750
1740 PRINT : PRINT "Number of Points Must be Greater than "; IV + 2 + I4: GOTO 1650
1750 IF IO <= NOBS THEN 1770
1760 PRINT : PRINT "Number of Points Must be Greater than "; NOBS + 1: GOTO 1650
1770 IT = IV + 1: IH = IO - I4
1780 PRINT : PRINT : PRINT : PRINT "Enter with Data:"
1790 FOR I = 1 TO IT
1800 PRINT : IF I <> IT THEN 1830
1810 PRINT : PRINT : PRINT IH; " Values Required for the Dependent Variable "; VNAM$(IT); ".": PRINT
1820 GOTO 1850
1830 PRINT : PRINT : PRINT IO; " Values Required for the Independent Variable "; VNAM$(I); ".": PRINT
1840 I5 = IO
1850 IF I = IT THEN I5 = IH
1860 FOR J = 1 TO I5
1870 PRINT "Value for the Point "; J;
1880 INPUT "? ", X(I, J)
1890 NEXT J
1900 NEXT I
1910 FLAG1 = 0: CLS : PRINT : BF$ = "OPTIONS FOR DATA HANDLING": PRINT TAB((80 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0
1920 PRINT "--------------------------------------------------------------------------------": LOCATE 6: NCOL = 26
1930 PRINT TAB(NCOL); " 1 - List Data"
1940 PRINT TAB(NCOL); " 2 - Correct Data"
1950 PRINT TAB(NCOL); " 3 - Add Data"
1960 PRINT TAB(NCOL); " 4 - Add Indendent Variable"
1970 PRINT TAB(NCOL); " 5 - Delete Variable"
1980 PRINT TAB(NCOL); " 6 - Perform Regression"
1990 PRINT TAB(NCOL); " 7 - Study Another Model"
2000 PRINT TAB(NCOL); " 8 - Save Data in Disk"
2010 PRINT TAB(NCOL); " 9 - Weight Data "
2020 PRINT TAB(NCOL); "10 - Transforma Data"
2030 PRINT TAB(NCOL); "11 - End"
2040 PRINT : PRINT : PRINT : INPUT "Your Choice? ", IP
2050 IF (IP < 1) OR (IP > 11) THEN PRINT B$: GOTO 1910
2060 CLS : IF IP = 1 THEN GOSUB 5700
2070 IF IP = 2 THEN GOSUB 5910
2080 IF IP = 3 THEN GOSUB 6260
2090 IF IP = 4 THEN GOSUB 6690
2100 IF IP = 5 THEN GOSUB 6530
2110 IF IP = 6 THEN GOTO 2180
2120 IF IP = 7 THEN GOTO 1410
2130 IF IP = 8 THEN GOSUB 6810
2140 IF IP = 9 THEN GOSUB 7140
2150 IF IP = 10 THEN FLAG1 = 1: GOSUB 7200
2160 IF IP = 11 THEN LOCATE 12: PRINT "*** END OF RUN ***": LOCATE 22: ON ERROR GOTO 0: END
2170 GOTO 1910
2180 CLS : PRINT : BF$ = "AVAILABLE OPTIONS": PRINT TAB((80 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0
2190 PRINT "--------------------------------------------------------------------------------": LOCATE 8: NCOL = 26
2200 PRINT TAB(NCOL); "1 - Multiple Regression"
2210 PRINT : PRINT TAB(NCOL); "2 - Stepwise Multiple Regression"
2220 PRINT : PRINT TAB(NCOL); "3 - Data Handling Options": PRINT
2230 LOCATE 20: INPUT "Your Choice? ", IC
2235 CLS
2240 IF (IC < 1) OR (IC > 3) THEN PRINT B$: GOTO 2180
2250 IF IC = 3 THEN 1910
2260 C$ = "S"
2270 IF IC = 2 THEN C$ = "N"
2280 IR = 1
2290 PRINT : INPUT "Show Solution after Each Iteraction (Y/N)? ", P$
2300 IF (P$ <> "Y") AND (P$ <> "N") THEN PRINT B$: GOTO 2290
2310 IF P$ = "N" THEN IR = IR + 1
2320 PRINT
2330 INPUT "Output via Screen or Printer (S/P)? ", O$
2340 IF (O$ <> "S") AND (O$ <> "P") THEN PRINT B$: GOTO 2330
2355 IF O$ = "S" THEN PRINT : PRINT "Enter Data Identification Message.": INPUT "", BUF$: PRINT : PRINT : PRINT "Prepare Printer;": INPUT "Press  to Continue...", BF$
2358 PRINT : PRINT
2360 IF C$ = "S" THEN 2400
2370 CLS : PRINT "Stepwise Multiple Regression"
2380 PRINT "--------------------------------------------------------------------------------"
2390 PRINT : PRINT : GOTO 2420
2400 CLS : PRINT "Multiple Regression"
2410 PRINT "--------------------------------------------------------------------------------": PRINT : PRINT
2420 IF O$ = "S" THEN 2500
2440 IF C$ = "S" THEN 2480
2450 LPRINT "Stepwise Multiple Regression"
2460 LPRINT STRING$(80, "-"); : LPRINT
2470 GOTO 2500
2480 LPRINT "Multiple Regression"
2490 LPRINT STRING$(80, "-"); : LPRINT
2500 F1 = 3.29: IF O$ = "P" THEN LPRINT BUF$: LPRINT
2510 F2 = 3.29
2520 TL = .0001
2530 IDS = 1
2540 ISTP = 1
2550 WDTA = 0
2560 FOR I = 1 TO IH
2570 WDTA = WDTA + WT(I)
2580 NEXT I
2590 FOR I = 1 TO IT
2600 WSUM(I) = 0
2610 FOR J = 1 TO IH
2620 WSUM(I) = WSUM(I) + WT(J) * X(I, J)
2630 NEXT J
2640 NEXT I
2650 REM
2660 FOR I = 1 TO IT
2670 FOR J = 1 TO IT
2680 R(I, J) = 0
2690 FOR K = 1 TO IH
2700 R(I, J) = R(I, J) + WT(K) * X(I, K) * X(J, K)
2710 NEXT K
2720 NEXT J
2730 NEXT I
2740 FOR I = 1 TO IT
2750 WMEAN(I) = WSUM(I) / WDTA
2760 NEXT I
2770 REM
2780 FOR I = 1 TO IT
2790 FOR J = 1 TO IT
2800 R(I, J) = R(I, J) - WSUM(I) * WSUM(J) / WDTA
2810 NEXT J
2820 NEXT I
2830 FOR I = 1 TO IT
2840 SIGMA(I) = R(I, I) ^ .5
2850 NEXT I
2860 REM
2870 FOR I = 1 TO IT
2880 FOR J = 1 TO IT
2890 R(I, J) = R(I, J) / (SIGMA(I) * SIGMA(J))
2900 NEXT J
2910 NEXT I
2920 FOR I = 2 TO IT
2930 II = I - 1
2940 FOR J = 1 TO II
2950 R(I, J) = R(J, I)
2960 NEXT J
2970 NEXT I
2980 IF C = 2 THEN 3050
2990 GOSUB 7840
3000 IF DET <> 0 THEN 3050
3020 PRINT B$: PRINT "It is Impossible to Find a Solution using Multiple Regression!": PRINT
3030 PRINT "The Variable Are Not Independent. Try the"
3040 PRINT "Stepwise Multiple Regression Option.": PRINT : INPUT "Tecle  para Continuar...", BF$: GOTO 2180
3050 PHI = WDTA - 1
3060 INDEX = 1
3070 FOR J = 1 TO IT
3080 SB(J) = 0
3090 B(J) = 0
3100 NEXT J
3110 IF (R(IT, IT) > -9.999999E-06) AND (R(IT, IT) < 0) THEN R(IT, IT) = 0
3120 SY = SIGMA(IT) * (R(IT, IT) / PHI) ^ .5
3130 IF C$ <> "S" THEN 4010
3140 IF ISTP <= 1 THEN 3300
3150 NN = ISTP - 1
3160 REM
3170 FOR I = 1 TO NN
3180 B(I) = R(I, IT) * SIGMA(IT) / SIGMA(I)
3190 IF R(I, I) > 0 THEN 3280
3210 PRINT B$: PRINT "It is Impossible to Find the Solution Using Multiple Regression."
3220 PRINT "Variable "; VNAM$(I); " is a Linear Combination of the Other Variables."
3240 PRINT
3250 PRINT "Try the Stepwise Regressio Option."
3260 PRINT : INPUT "Press  to Continue...", BF$: GOTO 2180
3270 REM
3280 SB(I) = SY * R(I, I) ^ .5 / SIGMA(I)
3290 NEXT I
3300 IF IR > 1 THEN 3680
3310 B(IT) = WMEAN(IT)
3320 NN = IT - 1
3330 FOR I = 1 TO NN
3340 B(IT) = B(IT) - B(I) * WMEAN(I)
3350 NEXT I
3360 REM
3370 DETER = 1 - R(IT, IT)
3380 IF DETER < .000001 THEN DETER = 0
3390 DVEST = SY
3400 IF DVEST < .000001 THEN DVEST = 0
3410 IF O$ = "P" THEN 3590
3430 PRINT : PRINT "Regression #"; ISTP
3440 PRINT "--------------------------------------------------------------------------------"
3450 PRINT VNAM$(IT); " = "; B(IT)
3460 FOR I = 1 TO NN
3470 IF B(I) = 0 THEN 3490
3480 PRINT " + "; B(I); " "; VNAM$(I)
3490 NEXT I
3500 DVEST = INT(DVEST * 10 ^ 4 + .5) / INT(10 ^ 4 + .5)
3510 DETER = INT(DETER * 10 ^ 7 + .5) / INT(10 ^ 7 + .5)
3520 PRINT : PRINT "Determination Coeficient = "; DETER
3530 PRINT "Standard Deviation of the Estimative = "; DVEST
3540 IF ISTP <> (IDS * 3) THEN 3570
3550 IF ISTP = IT THEN 3680
3560 IDS = IDS + 1: PRINT : COLOR 31, 0: INPUT "Press  to Continue...", Y$: COLOR 7, 0: CLS
3570 PRINT : GOTO 3680
3590 LPRINT : LPRINT : LPRINT "Regression #"; ISTP
3600 LPRINT VNAM$(IT); " = "; B(IT)
3610 FOR I = 1 TO NN
3620 IF B(I) = 0 THEN 3640
3630 LPRINT " + "; B(I); " "; VNAM$(I)
3640 NEXT I
3650 DETER = INT(DETER * 10 ^ 7 + .5) / INT(10 ^ 7 + .5)
3660 LPRINT : LPRINT "Determination Coeficient = "; DETER
3670 LPRINT "Standard Deviation of the Estimative = "; DVEST
3680 ISTP = ISTP + 1
3690 IF C$ <> "S" THEN 3840
3700 IF ISTP < IT THEN 3820
3710 IF ISTP > IT THEN 4370
3720 REM
3740 IF O$ = "P" THEN LPRINT : LPRINT : LPRINT : LPRINT "Final Solution:" ELSE PRINT : PRINT "Final Solution:": PRINT
3750 GOTO 3780
3770 IF O$ = "P" THEN LPRINT : LPRINT : LPRINT : LPRINT "Final Solution:" ELSE PRINT : PRINT "Final Solution:"
3780 IY = IR
3790 IR = 3
3800 IF C$ <> "S" THEN 3310
3810 IR = 1
3820 K = ISTP - 1
3830 PHI = PHI - 1
3840 IF IR > 2 THEN 4370
3850 REM
3860 FOR I = 1 TO IT
3870 IF I = K THEN 3920
3880 FOR J = 1 TO IT
3890 IF J = K THEN 3910
3900 R(I, J) = R(I, J) - R(I, K) * R(K, J) / R(K, K)
3910 NEXT J
3920 NEXT I
3930 FOR I = 1 TO IT
3940 IF I = K THEN 3970
3950 R(I, K) = -R(I, K) / R(K, K)
3960 R(K, I) = R(K, I) / R(K, K)
3970 NEXT I
3980 R(K, K) = 1 / R(K, K)
3990 IF C$ <> "S" THEN 3060
4000 GOTO 3110
4010 IX = 0
4020 VX = 0
4030 IM = 0
4040 VM = 99999!
4050 IF (R(INDEX, INDEX) - TL) > 0 THEN 4200
4060 IF (INDEX + 1) >= IT THEN 4090
4070 INDEX = INDEX + 1
4080 GOTO 4050
4090 IF R(IT, IT) <= 0 THEN 3720
4100 IF (VM * PHI / R(IT, IT)) >= F2 THEN 4140
4110 K = IM
4120 PHI = PHI + 1
4130 GOTO 3300
4140 IF R(IT, IT) <= VX THEN 4170
4150 REM
4160 IF (VX * (PHI - 1) / (R(IT, IT) - VX)) <= F1 THEN 3720
4170 K = IX
4180 PHI = PHI - 1
4190 GOTO 3300
4200 V = R(INDEX, IT) * R(IT, INDEX) / R(INDEX, INDEX)
4210 IF V = 0 THEN 4060
4220 IF V > 0 THEN 4330
4230 REM
4240 B(INDEX) = R(INDEX, IT) * SIGMA(IT) / SIGMA(INDEX)
4250 REM
4260 SB(INDEX) = SY * R(INDEX, INDEX) ^ .5 / SIGMA(INDEX)
4270 REM
4280 REM
4290 IF (V + VM) <= 0 THEN 4060
4300 VM = -V
4310 IM = INDEX
4320 GOTO 4060
4330 IF (V - VX) <= 0 THEN 4060
4340 VX = V
4350 IX = INDEX
4360 GOTO 4060
4370 IF O$ = "P" THEN 4400
4390 IF O$ = "S" THEN PRINT : COLOR 31, 0: INPUT "Press  to Continue...", Y$: COLOR 7, 0: CLS : PRINT
4400 IR = IY
4410 II = IT - 1
4420 REM
4430 FOR J = 1 TO IH
4440 Y(J) = B(IT)
4450 FOR I = 1 TO II
4460 Y(J) = Y(J) + B(I) * X(I, J)
4470 NEXT I
4480 NEXT J
4490 IGI = II - 1
4510 LOCATE 10: INPUT "Do You Want to See the Forecast Limits (Y/N)? ", F$: IF F$ <> "Y" AND F$ <> "N" THEN PRINT B$: GOTO 4510
4512 IF O$ = "P" THEN PRINT : INPUT "Do You Want to Print the Forecast Limits (Y/N)? ", BUF$: IF BUF$ <> "Y" AND BUF$ <> "N" THEN PRINT B$: GOTO 4512
4514 IF BUF$ = "N" THEN O$ = "S"
4520 IF F$ <> "Y" THEN 4740
4530 PRINT : INPUT "Do You Want to Use t Statistics to Determine Limits (Y/N)? ", L$
4550 IF (L$ <> "Y") AND (L$ <> "N") THEN PRINT B$: GOTO 4530
4560 IF L$ = "Y" THEN 4600
4570 INPUT "Entre com o Valor da Estatistica : ", T
4580 GOTO 4740
4590 REM
4600 IF PHI > 30 THEN 4640
4610 IBI = PHI
4620 T = T95(IBI)
4630 GOTO 4740
4640 IF PHI > 40 THEN 4670
4650 T = T95(30) - (PHI - 30) * .0021
4660 GOTO 4740
4670 IF PHI > 60 THEN 4700
4680 T = T95(31) - (PHI - 40) * .00105
4690 GOTO 4740
4700 IF PHI > 120 THEN 4730
4710 T = T95(32) - (PHI - 60) * .02 / 60
4720 GOTO 4740
4730 T = T95(33)
4740 SAS = SIGMA(IT) ^ 2 * R(IT, IT) / PHI
4750 IF O$ = "P" THEN 5020
4760 CLS : PRINT "Values Confrontation"; : COLOR 0, 7: PRINT "Real x Forecast"; : COLOR 7, 0: PRINT " para "; VNAM$(IT): PRINT
4770 PRINT "Real", "Forecast", "Difference"
4780 PRINT "---------------------------------------------"
4790 IC = 1
4800 FOR J = 1 TO IH
4810 IF J <> (IC * 18) THEN 4840
4820 IC = IC + 1
4830 PRINT : COLOR 31, 0: INPUT "Press  to Continue...", Y$: COLOR 7, 0: CLS
4831 CLS : PRINT "Values Confrontation "; : COLOR 0, 7: PRINT "Real x Forecast"; : COLOR 7, 0: PRINT " para "; VNAM$(IT): PRINT
4832 PRINT "Real", "Forecast", "Difference"
4834 PRINT "---------------------------------------------"
4840 DI = X(IT, J) - Y(J)
4850 IF X(IT, J) <> 0 THEN 4880
4860 IF DI <> 0 THEN PDI = 999999!
4870 GOTO 4890
4880 PDI = DI / X(IT, J) * 100
4890 OBS = X(IT, J)
4900 Y(J) = INT(1000 * Y(J) + .5) / 1000
4910 DI = INT(10 ^ 5 * DI + .5) / 10 ^ 5
4920 PRINT OBS, Y(J), DI
4930 NEXT J
4940 IF F$ <> "Y" THEN PRINT : PRINT : COLOR 31, 0: PRINT "Press  to Continue..."; : COLOR 7, 0: INPUT "", BF$:  CLS : GOTO 5680
4950 PRINT : COLOR 31, 0: INPUT "Press  to Continue...", Y$: COLOR 7, 0: CLS
4960 CLS : PRINT "Confidence Limits for the Forecast Values"
4970 PRINT : PRINT "Degrees  of Freedom = "; PHI
4980 PRINT : PRINT "t Statistics = "; T
4985 LOCATE 20: INPUT "Press  to Continue...", BF$: CLS
4990 PRINT : PRINT "Inferior Limit"; TAB(20); "Forecast"; TAB(40); "Superior Limit"
5000 PRINT STRING$(60, "-")
5010 GOTO 5190
5020 REM
5030 LPRINT : LPRINT : LPRINT "Real"; TAB(20); "Forecast"; TAB(40); "Difference"; TAB(60); "% Difference": LPRINT STRING$(80, "-");
5040 FOR J = 1 TO IH
5050 DI = X(IT, J) - Y(J)
5060 IF X(IT, J) <> 0 THEN 5090
5070 IF DI <> 0 THEN PDI = 999999!
5080 GOTO 5110
5090 OBS = X(IT, J)
5100 PDI = DI / X(IT, J) * 100
5110 LPRINT OBS; TAB(20); Y(J); TAB(40); DI; TAB(60); PDI
5120 NEXT J
5130 IF F$ <> "Y" THEN 5680
5140 LPRINT : LPRINT : LPRINT "Confidence Limits for the Forecast Values:"
5150 LPRINT : LPRINT "Degrees of Freedom ="; PHI
5160 LPRINT : LPRINT "t Statistic = "; T
5170 LPRINT : LPRINT "Inferior Limit"; TAB(20); "Forecast"; TAB(40); "Superior Limit"
5180 LPRINT STRING$(60, "-")
5190 XM = IH
5200 IC = 1
5210 FOR I = 1 TO IO
5220 IF I <> (IC * 19) THEN 5270
5230 IC = IC + 1
5240 IF O$ <> "S" THEN 5270
5260 PRINT : COLOR 31, 0: INPUT "Press  to Continue...", Y$: COLOR 7, 0: CLS
5261 PRINT : PRINT "Inferior Limit"; TAB(20); "Forecast"; TAB(40); "Superior Limit"
5262 PRINT STRING$(60, "-")
5270 VARY = SAS / XM
5280 Y(I) = B(IT)
5290 IF IGI <= 0 THEN 5500
5300 FOR J = 1 TO IGI
5310 IF SB(J) = 0 THEN 5350
5320 IF (SIGMA(J) = 0) OR (SIGMA(J) > 1E+20) THEN 5350
5330 XSB = SAS * R(J, J) / (SIGMA(J) ^ 2)
5340 GOTO 5360
5350 XSB = 0
5360 Y(I) = Y(I) + B(J) * X(J, I)
5370 DI = X(J, I) - WMEAN(J)
5380 VARY = VARY + XSB * DI ^ 2
5390 KK = J + 1
5400 FOR K = KK TO II
5410 IF SB(K) = 0 THEN 5460
5420 IF (SIGMA(J) = 0) OR (SIGMA(J) >= 1E+20) THEN 5460
5430 IF (SIGMA(K) = 0) OR (SIGMA(K) >= 1E+20) THEN 5460
5440 XSB = SAS * R(J, K) / (SIGMA(J) * SIGMA(K))
5450 GOTO 5470
5460 XSB = 0
5470 VARY = VARY + 2 * XSB * DI * (X(K, I) - WMEAN(K)) ^ 2
5480 NEXT K
5490 NEXT J
5500 IF SB(II) <= 0 THEN 5540
5510 IF (SIGMA(II) = 0) OR (SIGMA(II) >= 1E+20) THEN 5540
5520 XSB = SAS * R(II, II) / SIGMA(II) ^ 2
5530 GOTO 5550
5540 XSB = 0
5550 Y(I) = Y(I) + B(II) * X(II, I)
5560 VARY = VARY + XSB * (X(II, I) - WMEAN(II)) ^ 2
5570 SVARY = ABS(VARY + SAS) ^ .5
5580 LLM = Y(I) - SVARY * T
5590 ULM = Y(I) + SVARY * T
5600 IF O$ = "P" THEN 5630
5610 PRINT LLM; TAB(20); Y(I); TAB(40); ULM
5620 GOTO 5650
5630 REM
5640 LPRINT LLM; TAB(20); Y(I); TAB(40); ULM
5650 NEXT I
5670 IF O$ = "S" THEN PRINT : COLOR 31, 0: INPUT "Pressi  to Continue...", Y$: COLOR 7, 0: CLS
5680 REM
5690 GOTO 2180
5700 REM
5710 PRINT : INPUT "Variable to be Listed? ", ID$
5720 GOSUB 6190
5730 IF IL = 0 THEN 5770
5740 PRINT : INPUT "Variable Not Found - Try Again (Y/N)? ", Y$
5750 IF Y$ <> "Y" THEN RETURN
5760 GOTO 5710
5770 MM = IO
5780 IF I = IT THEN MM = IH
5790 PRINT : PRINT "Data Listing for "; VNAM$(I); " :"
5800 PRINT "--------------------------------------------------------------------------------": PRINT
5810 IC = 1
5820 FOR J = 1 TO MM
5830 IF IC <= 18 THEN 5860
5850 IC = 1: PRINT : COLOR 31, 0: INPUT "Press  to Continue...", Y$: COLOR 7, 0: CLS
5852 PRINT : PRINT "Data Listing for "; VNAM$(I); " :"
5854 PRINT "--------------------------------------------------------------------------------": PRINT
5860 IC = IC + 1: PRINT "#"; J, X(I, J)
5870 NEXT J
5880 PRINT : INPUT "Do You Want to List Another Variable (Y/N)? ", Y$
5890 IF Y$ = "Y" THEN 5700
5900 RETURN
5910 REM
5920 PRINT
5930 CLS : INPUT "Name of the Variable to be Modified? ", ID$
5940 GOSUB 6190
5950 IF IL = 0 THEN 5990
5960 PRINT : INPUT "Variable not Found - Do You Want to Try Again (Y/N)? ", Y$
5970 IF Y$ <> "Y" THEN RETURN
5980 GOTO 5920
5990 I5 = IO
6000 IF I = IT THEN I5 = IH
6010 PRINT : INPUT "All Data of this Variable Must be Modified (Y/N)? ", Y$
6020 IF Y$ = "Y" THEN 6110
6030 PRINT
6040 INPUT "Index of the Point to be Modified? ", J
6050 IF (J < 1) OR (J > I5) THEN PRINT B$: GOTO 6030
6060 PRINT : INPUT "New Data? ", X(I, J)
6070 PRINT : INPUT "Do You Want to Modify Another Point of This Variable (Y/N)? ", Y$
6090 IF Y$ = "Y" THEN 6030
6100 RETURN
6110 I5 = IO
6112 PRINT : INPUT "Do You Want to Modify the Name of this Variable (Y/N)? ", BF$: IF BF$ <> "Y" THEN 6120
6114 PRINT : INPUT "New Name? ", VNAM$(I)
6120 IF I = IT THEN I5 = IH
6130 PRINT : PRINT I5; " Needed Values for "; VNAM$(I): PRINT
6140 FOR J = 1 TO I5
6150 PRINT "Enter a New Value for the Index "; J;
6160 INPUT ": ", X(I, J)
6170 NEXT J
6180 GOTO 6070
6190 REM
6200 IL = 0
6210 FOR I = 1 TO IT
6220 IF ID$ = VNAM$(I) THEN RETURN
6230 NEXT I
6240 IL = 1
6250 RETURN
6260 REM
6270 PRINT : INPUT "Do You Want to Perform Forecast (Y/N)? ", F$
6280 IF (F$ <> "Y") AND (F$ <> "N") THEN PRINT B$: GOTO 6270
6290 IF F$ = "N" THEN I4 = 0: GOTO 6310
6300 INPUT "Number of Periods to Forecast? ", I4: PRINT
6310 PRINT : PRINT "Number of of Point for Each Independent Variable,"
6320 INPUT "Incluindind Points Required in Forecasting? ", IA
6340 IF IA > (IV + 2 - I4) THEN 6360
6350 PRINT : PRINT "Number of Points Must be Greater than "; IV + 2 - I4: GOTO 6310
6360 IF IA <= NOBS THEN I1 = IH + 1: I2 = IA: GOTO 6380
6370 PRINT : PRINT "Number of Points Must be Lower than "; NOBS + 1: GOTO 6310
6380 FOR I = 1 TO IT
6390 IF I = IT THEN I1 = IH + 1: I2 = IA - I4
6400 IF I <> IT THEN 6440
6410 IF I1 >= I2 THEN 6510 ELSE PRINT : PRINT : PRINT "Enter Additional Points for the ";
6420 PRINT "Dependent Variable"; VNAM$(IT); "."
6430 GOTO 6460
6440 PRINT : PRINT : PRINT "Enter Additional Points for the Independent Variable  "; VNAM$(I); "."
6460 PRINT : FOR J = I1 TO I2
6470 PRINT "Value for the Point "; J; "? ";
6480 INPUT "", X(I, J)
6490 NEXT J
6500 NEXT I
6510 IO = IA: IH = IO - I4
6520 RETURN
6530 REM
6540 PRINT : INPUT "Variable to be Deleted? ", ID$: PRINT
6550 GOSUB 6190
6560 IF IL = 0 THEN 6600
6570 INPUT "Variable Not Found - Try Again (Y/N)? ", Y$
6580 IF Y$ <> "Y" THEN RETURN
6590 GOTO 6540
6600 FOR J = I TO IT - 1
6610 VNAM$(J) = VNAM$(J + 1)
6620 FOR K = 1 TO IO
6630 X(J, K) = X(J + 1, K)
6640 NEXT K
6650 NEXT J
6660 IV = IV - 1
6670 IT = IT - 1
6680 RETURN
6690 REM
6700 VNAM$(IT + 1) = VNAM$(IT)
6710 PRINT : INPUT "Name of the Variable to be Added? ", VNAM$(IT): PRINT
6720 PRINT IO; "Values Required for "; VNAM$(IT): PRINT
6730 FOR J = 1 TO IO
6740 X(IT + 1, J) = X(IT, J)
6750 PRINT "Value for the Index "; J;
6760 INPUT "? ", X(IT, J)
6770 NEXT J
6780 IT = IT + 1
6790 IV = IV + 1
6800 RETURN
6810 REM
6820 LOCATE 12: INPUT "Disk File Name (? to List Directory)? ", NAM$: IF NAM$ = "?" THEN PRINT : FILES "*.STP": PRINT : INPUT "Press  to Continue...", NAM$: CLS : GOTO 6820 ELSE NAM$ = NAM$ + ".STP"
6830 OPEN "O", #1, NAM$
6850 WRITE #1, IT, IH, I4
6860 ID = IO
6870 FOR I = 1 TO IT
6880 WRITE #1, VNAM$(I)
6890 IF I = IT THEN ID = IH
6900 FOR J = 1 TO ID
6910 WRITE #1, X(I, J)
6920 NEXT J
6930 NEXT I
6940 CLOSE #1
6950 RETURN
6960 REM
6970 LOCATE 12: INPUT "Disk File Name (? to List Directory)? ", NAM$: IF NAM$ = "?" THEN PRINT : FILES "*.stp": PRINT : INPUT "Press  to Continue... ", NAM$: CLS : GOTO 6970 ELSE NAM$ = NAM$ + ".STP"
6980 OPEN "I", #1, NAM$
7000 INPUT #1, IT, IH, I4
7010 IO = IH + I4
7020 IV = IT - 1
7030 IF I4 > 0 THEN F$ = "Y"
7040 ID = IO
7050 FOR I = 1 TO IT
7060 INPUT #1, VNAM$(I)
7070 IF I = IT THEN ID = IH
7080 FOR J = 1 TO ID
7090 INPUT #1, X(I, J)
7100 NEXT J
7110 NEXT I
7120 CLOSE #1
7130 RETURN
7140 REM
7150 FOR I = 1 TO IH
7160 PRINT "Weight for the Point "; I; "? ";
7170 INPUT "", WT(I)
7180 NEXT I
7190 RETURN
7200 REM
7210 GOSUB 7790
7220 MM = IO
7230 FOR I = 1 TO IT
7240 IF I = IT THEN MM = IH
7250 PRINT : PRINT "Transformation for the Variable "; VNAM$(I); "? ";
7260 INPUT "", TC$
7270 IF TC$ = "N" THEN 7420
7280 IF TC$ = "E" THEN IK = 1: GOTO 7320
7290 IF TC$ = "P" THEN IK = 2: GOTO 7310
7295 IF TC$ = "X" THEN IK = 3: GOTO 7320
7300 PRINT B$: GOTO 7250
7310 PRINT : INPUT "Exponente Value (X^N)? ", EX: PRINT
7320 FOR J = 1 TO MM
7330 ON IK GOTO 7340, 7400
7340 IF X(I, J) > 0 THEN 7380
7350 PRINT "There is No Logarithm of a Negative Number!"
7360 PRINT "The Value of the Element in Hand is "; X(I, J)
7370 PRINT : GOTO 7410
7380 X(I, J) = LOG(X(I, J))
7390 GOTO 7410
7400 X(I, J) = X(I, J) ^ EX: GOTO 7410
7405 X(I, J) = EXP(X(I, J))
7410 NEXT J
7420 NEXT I
7430 RETURN
7440 REM
7450 CLS : PRINT : COLOR 0, 7: PRINT "Available Options:": COLOR 7, 0
7460 PRINT "--------------------------------------------------------------------------------"
7470 PRINT "Data Input:"
7480 PRINT : PRINT "K = Keyboard"
7490 PRINT "D = Disk File"
7500 PRINT : COLOR 0, 7: PRINT "Data Treatment:": COLOR 7, 0
7510 PRINT : PRINT "Correct Data"
7520 PRINT "Add Data"
7530 PRINT "Delete Variables"
7540 PRINT "Add Variables"
7550 PRINT "Weight Data"
7560 PRINT "Transform Data"
7570 PRINT "Salve Data in Disk"
7580 PRINT : COLOR 0, 7: PRINT "Results Output:": COLOR 7, 0
7590 PRINT : PRINT "S = Screen"
7600 PRINT "P = Printer"
7610 PRINT : COLOR 31, 0: INPUT "Press  to Continue...", Y$: COLOR 7, 0
7615 CLS
7630 PRINT : COLOR 0, 7: PRINT "Statistical Options:": COLOR 7, 0
7640 PRINT : PRINT "Multiple Regression"
7650 PRINT "Stepwise Regression"
7660 PRINT : COLOR 0, 7: PRINT "Results:": COLOR 7, 0
7670 PRINT : PRINT "S = Show Solution in Each Iteraction"
7680 PRINT "N = Show Only Final Solution Final"
7690 PRINT : COLOR 0, 7: PRINT "Data Weighting Schemes:": COLOR 7, 0
7700 PRINT : PRINT "Uniform, Program Default"
7710 PRINT "Non-Uniform, Weights Supplied by the User"
7720 PRINT : COLOR 0, 7: PRINT "Confidence Limits:": COLOR 7, 0
7730 PRINT : PRINT "Y = t-95 Statistics t-95, Program Default"
7740 PRINT "N = t-95 Statistics Supplied by the User"
7750 PRINT : PRINT : PRINT : COLOR 31, 0: INPUT "Press  to Continue...", Y$: COLOR 7, 0
7755 CLS
7760 PRINT : COLOR 0, 7: PRINT "Forecasting Horizon:": COLOR 7, 0
7770 PRINT : PRINT "S = Required Forecasting"
7780 PRINT "N = Forecasting Not Required"
7790 PRINT : COLOR 0, 7:  PRINT "Available Transformations:": COLOR 7, 0
7800 PRINT : PRINT "N = No Transform"
7810 PRINT "E = Neperian Logarithm"
7820 PRINT "P = Polinomial X ^ N"
7822 PRINT "X = Exponential"
7825 IF FLAG1 = 1 THEN RETURN ELSE PRINT : PRINT : PRINT : COLOR 31, 0: INPUT "Press  to Continue...", Y$: COLOR 7, 0: CLS
7830 RETURN
7840 REM
7850 FOR I = 1 TO IV
7860 FOR J = 1 TO IV
7870 REM
7880 E1(I, J) = R(I, J)
7890 NEXT J
7900 NEXT I
7910 REM
7920 DET = 1
7930 FOR I = 1 TO IV - 1
7940 REM
7950 IF E1(I, I) = 0 THEN GOSUB 8110
7960 IF DET = 0 THEN RETURN
7970 FOR J = I + 1 TO IV
7980 REM
7990 XM = E1(J, I) / E1(I, I)
8000 FOR K = I TO IV
8010 REM
8020 E1(J, K) = E1(J, K) - XM * E1(I, K)
8030 NEXT K
8040 NEXT J
8050 NEXT I
8060 REM
8070 FOR I = 1 TO IV
8080 DET = DET * E1(I, I)
8090 NEXT I
8100 RETURN
8110 REM
8120 REM
8130 REM
8140 FOR J = J + 1 TO IV
8150 IF E1(J, I) = 0 THEN GOTO 8210
8160 FOR K = 1 TO IV
8170 REM
8180 E1(I, K) = E1(I, K) + E1(J, K)
8190 NEXT K
8200 RETURN
8210 NEXT J
8220 REM
8230 DET = 0
8240 RETURN
9000 PRINT : PRINT : PRINT B$: COLOR 31, 0: PRINT "Error "; ERR; " in Line "; ERL; "!": COLOR 7, 0: PRINT : PRINT : INPUT "Press  to Continue...", BF$: RESUME 1910

***** End of Program Listing ******

Return to the Software Menu.

Last Update: 28 June 1996
© Antonio Augusto Gorni