Estadística en Microcomputadores/Archivos BASIC/ESTAD6
10 ' ESTAD6 - Revision 5/ 1/89
15 ' --------------------------
20 GOSUB 1000
25 CHAIN "ESTAD"
200 ' EST91 Definicion de Variables
205 ' ---------------------------
210 GOSUB 500
215 IF NV=0 THEN 265
220 PRINT
225 GOSUB 730
255 INPUT " Definicion de Nuevas Variables ? (N) = ",A$
260 IF A$<>"S" AND A$<>"s" THEN RETURN
265 PRINT
270 K=0
273 IF KNV=0 THEN KNV=NC
275 WHILE K<=KNV-1
280 K=K+1 : NV=K
290 PRINT " Variable Nro.";K; : INPUT "= ",A$
295 IF LEN(A$)=0 AND K=1 THEN NV=0 : RETURN
300 IF LEN(A$)=0 THEN NV=K-1 : K=KNV : GOTO 320
305 J=VAL(A$)
310 IF J<1 OR J>NC THEN KE=4 : GOSUB 900 : GOTO 290
311 IF K=1 THEN 318
312 FOR M=1 TO K-1
313 IF J=JX(M) THEN PRINT CHR$(7) : PRINT :
INPUT "** VARIABLE REPETIDA",A$ : PRINT : GOTO 290
315 NEXT M
318 JX(K)=J
320 WEND
324 IF KDA=1 THEN JF=0 : KDA=0 : NX=NF : RETURN
325 PRINT
330 INPUT " Variable para Observaciones Agrupadas (No) = ",A$
335 IF LEN(A$)=0 THEN JF=0 : GOTO 350
340 JF=VAL(A$)
345 IF JF<1 OR JF>NC THEN KE=4 : GOSUB 900 : GOTO 330
347 IF JF=0 THEN NX=NF : RETURN
350 KE=0 : NX=0
355 FOR I=1 TO NF
370 ND=1 : IF JF>0 THEN ND=A(I,JF)
372 IF ND=XVF THEN 380
373 IF ND<0 THEN KE=1
375 NX=NX+ND
380 NEXT I
383 IF KE=1 THEN PRINT : PRINT CHR$(7) : PRINT "** VALOR <0 EN VARIABLE";JF; :
INPUT "",A$ : GOTO 325
385 RETURN
390 ' EST92 - Seleccion de Variable
395 ' ----------------------------
400 J=0
405 IF NC=0 OR KVA=1 THEN KVA=0 : GOTO 412
410 GOSUB 500
412 PRINT
415 INPUT " Posicion de Variable a utilizar = ",A$
420 IF LEN(A$)=0 THEN RETURN
425 X=VAL(A$)
430 IF X<1 OR X>NCM THEN KE=4 : GOSUB 900 : GOTO 415
435 IF LEN(TC$(X))=0 OR LEFT$(TC$(X),2)=" " THEN 455
440 PRINT : PRINT " Variable";X;" actual = ",TC$(X)
445 INPUT " Se utiliza ? (N) = ",A$
450 IF A$<>"S" AND A$<>"s" THEN 415
451 PRINT : INPUT " Borrado de Datos existentes ? (N) = ",A$
452 IF A$="S" OR A$="s" THEN FOR I=1 TO NFM : A(I,X)=0 : NEXT I
455 PRINT : PRINT " Nombre de la Variable";X; : INPUT " = ",A$
460 IF LEN(A$)=0 AND TC$(X)<>" " THEN 485
465 IF LEN(A$)=0 OR LEFT$(A$,8)=" " THEN 415
470 TC$(X)=LEFT$(A$,8)
485 IF NC<X THEN NC=X
490 J=X
495 RETURN
500 ' EST93 - Variables en memoria
505 ' ----------------------------
510 PRINT : PRINT " Variables en Memoria" : PRINT
515 I=1
520 FOR L=1 TO NC
525 IF LEFT$(TC$(L),2)=" " THEN 540
530 PRINT TAB(15*I-11);L;"-";TC$(L);
535 I=I+1 : IF I>5 THEN I=1 : PRINT
540 NEXT L
545 PRINT
550 RETURN
555 ' EST94 Encabezamiento Pantallas y Resultados
560 ' -------------------------------------------
565 IF DS$="SCRN:" THEN PRINT CHR$(12);
570 PRINT#3,"Proceso : ";TP$;TAB(70);DATE$
575 IF TSP$>"" THEN PRINT#3,TAB(11);TSP$ ELSE PRINT
577 A$=NA$ : IF NF=0 THEN A$="No hay Datos en Memoria"
580 PRINT#3,"Datos : ";A$;" - ";N$
583 IF JF>0 THEN PRINT#3,TAB(11);"Variable para Observaciones Agrupadas = ";
JF;"-";TC$(JF)
585 IF CD$>"" THEN PRINT#3,TAB(11);"Condicion de Seleccion = ";CD$
590 IF NX>0 THEN PRINT#3,TAB(11);"Numero de Observac.: ";
595 IF NX>0 THEN PRINT#3,"Totales =";NX;
597 IF NXX>0 THEN PRINT#3," / Consideradas =";NXX ELSE PRINT#3,
600 KA=1 : KB=79 : GOSUB 695
605 PRINT#3,
610 RETURN
650 ' EST95 Seleccion de Dispositivo de Salida
655 ' ----------------------------------------
660 CLOSE#3 : KS=0 : DS$="SCRN:"
665 PRINT : INPUT "Salida por Impresora/I/ o a un Archivo/Nombre/ (No) = ",A$
670 IF LEN(A$)=0 THEN OPEN DS$ FOR OUTPUT AS #3 : RETURN
673 KS=1 : DS$="LPT1:"
675 IF A$="i" OR A$="I" THEN OPEN DS$ FOR OUTPUT AS#3 : RETURN
680 DS$=A$
685 OPEN DS$+".TXT" FOR APPEND AS #3
690 RETURN
695 ' EST96 Subrayado
700 ' ---------------
705 PRINT#3,TAB(KA);
710 FOR S=KA TO KB : PRINT#3,TAB(S);"-"; : NEXT S : PRINT#3,
715 RETURN
730 ' EST97 - Variables definidas
735 ' ---------------------------
740 I=1
743 IF KX=0 THEN PRINT#3," Variables ya Definidas" : PRINT#3,
745 IF KX=1 THEN PRINT#3," Variables Consideradas" : PRINT#3,
750 FOR K=1 TO NV
755 J=JX(K)
760 PRINT#3,TAB(15*I-11);J;"-";TC$(J);
765 I=I+1 : IF I>5 THEN I=1 : PRINT#3,
770 NEXT K
773 PRINT#3, : PRINT#3, : KX=0
775 RETURN
900 ' EST99 - SUBRUTINA DE MENSAJES
905 ' -----------------------------
910 PRINT CHR$(7) : PRINT
911 IF KE=1 THEN INPUT "** NO HAY DATOS EN MEMORIA ",A$ : KE=0 : RETURN
912 IF KE=2 THEN INPUT "** NUMERO DE VARIABLES NO ADECUADO PARA EL PROCESO ",A$
- KE=0 : RETURN
915 IF KE=3 THEN INPUT "** NUMERO DE OBSERVAC.INSUFICIENTE PARA EL PROCESO ",A$
- KE=0 : RETURN
928 IF KE=9 THEN INPUT "** PROCESO NO ADECUADO A LOS DATOS CONSIDERADOS ",A$ :
KE=0 : RETURN
929 IF KE=4 THEN INPUT "** VARIABLE NO EXISTENTE O SIN DATOS ",A$ :
KE=0 : RETURN
930 IF KE=5 THEN PRINT "** VALOR ERRONEO - Debe ser ";B$ : INPUT " ",A$ :
KE=0 : RETURN
931 IF KE=6 THEN INPUT "** CAPACIDAD INSUFICIENTE DE MEMORIA DE TRABAJO",A$ :
KE=0 : RETURN
934 INPUT "Valor Erroneo ",A$
935 RETURN
936 IF ERR<>53 THEN PRINT CHR$(7) : PRINT
937 IF ERR<>53 THEN KE=KE+1 : IF KE>1 THEN RESUME 948
938 IF ERR=25 OR ERR=57 OR ERR=68 OR ERR=70 OR ERR=71 THEN PRINT "** DISPOSITIVO ";XDDA$;
" NO DISPONIBLE O ERROR E/S"; : INPUT " ",A$ : RESUME NEXT
939 IF ERR=61 THEN PRINT "** DISCO ";XDDA$;" LLENO" : INPUT " ",A$ : RESUME
940 IF ERR=53 THEN KAR=1 : RESUME NEXT
941 IF ERR=62 THEN PRINT "** FIN DE GRABACION O LECTURA EN DISP. ";XDDA$; : INPUT "
",A$ : RESUME NEXT
942 IF ERR=2 OR ERR=22 THEN PRINT "** ERROR DE SINTAXIS EN FUNCION "; : INPUT "O
CONDICION",A$ : RESUME NEXT
943 IF ERR=24 OR ERR=27 THEN INPUT "** PROBLEMA EN IMPRESORA",A$ : RESUME NEXT
944 IF ERR=64 OR ERR=75 OR ERR=76 THEN INPUT "** NOMBRE INCORRECTO ARCHIVO",A$ : RESUME
947 PRINT "Error";ERR;"en linea";ERL :STOP
948 CHAIN"ESTAD"
950 ' EST98 - Descripcion Archivo
952 ' ---------------------------
954 LD=0
956 IF MID$(A$,2,1)<>":" THEN XDDA$=DDA$+":" : GOTO 964
958 B$=LEFT$(A$,1)
960 'IF INSTR("ABCabc",B$)=0 THEN GOSUB 900 : RETURN
962 XDDA$="" : LD=2
964 B$=RIGHT$(A$,4)
966 IF LEFT$(B$,1)<>"." THEN EXT$=XA$ ELSE EXT$="" : LD=LD+4
968 'IF LEN(A$)-LD>8 THEN GOSUB 900
970 KAR=0 : KE=0
972 OPEN XDDA$+A$+EXT$ FOR INPUT AS#1
974 CLOSE#1
978 RETURN
980 ' EST9. - Presentacion Menu
982 ' -------------------------
983 PRINT : ISP=0 : A$=""
984 FOR K=1 TO KL
986 PRINT " ";K;"- ";TF$(K)
988 NEXT K
990 PRINT : PRINT "Opcion Elegida = ";
991 B$=INKEY$ : PRINT B$;
992 IF B$=CHR$(13) THEN 996
993 IF B$=CHR$(27) THEN A$="" : GOTO 996
994 A$=A$+B$ : GOTO 991
996 IF LEN(A$)=0 THEN RETURN
997 ISP=INT(VAL(A$))
998 IF ISP<1 OR ISP>KL THEN PRINT CHR$(7) : GOTO 983
999 RETURN
1000 ' EST6 - Regresion
1005 ' ----------------
1010 DEFINT I-N
1015 COMMON ITE,NFM,NCM,A(),TC$(),NC,NF,NX,DDA$,NDE,NV,JX(),P(),DA$,NA$,CD$,
PAR1,PAR2,XVF
1020 ON ERROR GOTO 936
1025 IF KZZ=0 THEN DIM VX(NFM),VY(NFM),TF$(8),V(NCM),CY(2)
1027 IF KZZ=0 THEN DIM PM(NCM),XYZ(NCM),AA(NCM),DAA(NCM),TS(NCM),SI(NCM),
PMI(5),PMA(5),XI(5),DEL(5)
1030 IF KZZ=0 THEN DIM TI(PAR1+1,PAR2+1),TJ(PAR1+1,PAR2+1),TK(PAR1+1,PAR2+1) :
1035 DEF FNR(X,DE)=INT(10^DE*X+.5)/10^DE
1040 CLOSE : DS$="SCRN:" : OPEN DS$ FOR OUTPUT AS#3
1045 WHILE KW=0
1050 TP$="REGRESION" : TSP$=""
1055 NXX=0
1060 GOSUB 555
1065 PRINT TAB(70);FRE(0)
1070 PRINT "PROCESOS"
1075 TF$(1)="Regresion Lineal y Transformables a Lineal"
1080 TF$(2)="Regresion no Lineal"
1085 TF$(3)="Graficacion"
1090 TF$(4)="Manejo de Datos"
1095 KL=4 : GOSUB 980
1100 IF ISP=0 THEN CHAIN "ESTAD"
1110 IF ISP=4 THEN CHAIN "ESTAD1"
1115 IF NF=0 THEN KE=1 : GOSUB 900 : GOTO 1130
1120 IKP=ISP
1125 ON ISP GOSUB 1140,2915,5200
1130 WEND
1135 '
1140 ' EST61 - Regresion Lineal
1145 ' ------------------------
1150 TSP$="Regresion Lineal y Transformables a Lineal"
1155 WHILE KW=0
1160 GOSUB 555
1165 PRINT "FUNCION DE REGRESION"
1170 TF$(1)="LINEAL Y= a0 + a1*X1 +...+ ak*Xk"
1175 TF$(2)="Potencial Y= a0 * (X1^a1) *...* (Xk^ak)"
1180 TF$(3)="Exponencial Y= a0 * exp(a1*X1 +...+ ak*Xk)"
1185 TF$(4)="Exponenc.genral Y= a0 * (a1^X1) *...* (ak^Xk)"
1190 TF$(5)="Semilogaritmica Y= a0 + a1*ln(X1) +...+ ak*ln(Xk)"
1195 TF$(6)="Hiperbolica Y= a0 + a1/X1 +...+ ak/Xk"
1200 TF$(7)="Logistica Y= exp(a0+a1/X)"
1205 TF$(8)="Polinomica Y= a0 + a1*X^1 +...+ ak*X^k"
1210 KL=8 : GOSUB 980
1215 IF ISP=0 THEN RETURN
1220 TF=ISP
1225 C$=TF$(TF)
1230 GOSUB 555
1235 PRINT "FUNCION DE REGRESION: ";C$ : PRINT
1240 PRINT : PRINT "DEFINICION DE VARIABLES (2 ";
1245 IF TF=7 OR TF=8 THEN PRINT ")" ELSE PRINT "a";PAR2-1;")"
1250 PRINT " Las Primeras son las Variables Independientes"
1255 PRINT " La Ultima es la Variable Dependiente"
1260 KNV=PAR2-1 : IF TF=7 OR TF=8 THEN KNV=2
1265 GOSUB 200
1267 IF NV=0 THEN RETURN
1270 IF NV<2 OR NV>KNV THEN KE=2: GOSUB 900: GOTO 1265
1275 NVI=NV-1
1280 IF TF<>8 THEN 1310
1285 PRINT :INPUT "Grado del Polinomio = ",A$
1290 IF LEN(A$)=0 THEN RETURN
1295 GR=VAL(A$)
1300 IF GR<1 OR GR>NX-1 THEN KE=5 : B$=">=1 y <="+STR$(NXX-1) :
GOSUB 900 : GOTO 1285
1305 NVI=GR
1310 XP(0)=1 : KI=0
1315 PRINT : INPUT "Modelo sin Termino Independiente ? (N) = ",A$
1320 IF A$="S" OR A$="s" THEN KI=1
1325 PRINT : PRINT : PRINT TAB(25);"EN PROCESO"
1330 FOR K=0 TO NVI+1
1335 PM(K)=0
1340 FOR L=0 TO K : TJ(K,L)=0 :NEXT L
1345 NEXT K
1350 NXX=0 : KE=0
1355 FOR I=1 TO NF
1360 VX(I)=1
1365 IF A(I,0)=1 THEN 1475
1370 ND=1 : IF JF>0 THEN ND=A(I,JF) : IF ND=XVF THEN 1475
1375 KX=0
1380 FOR K=1 TO NV
1385 XP(K)=A(I,JX(K))
1390 IF XP(K)=XVF THEN KX=1 : K=NV
1395 NEXT K
1400 IF KX=1 THEN 1475
1405 FOR K=1 TO NVI+1
1410 IF TF=1 THEN 1450
1415 IF TF<8 THEN X=XP(K)
1420 IF TF=2 THEN IF X>0 THEN XP(K)=LOG(X) ELSE KE=1
1425 IF (TF=3 OR TF=4) AND K=NVI+1 THEN IF X>0 THEN XP(K)=LOG(X)
ELSE KE=1
1430 IF (TF=5 OR TF=6) AND K<NVI+1 THEN IF X>0 THEN XP(K)=LOG(X)
ELSE KE=1
1435 IF TF=7 AND K=NVI+1 THEN IF X>0 THEN XP(K)=LOG(X)
ELSE KE=1
1440 IF TF=7 AND K<NVI+1 THEN IF X<>0 THEN XP(K)=1/X
ELSE KE=1
1445 IF TF=8 THEN IF K<NVI+1 THEN XP(K)=XP(K-1)*A(I,JX(1))
ELSE XP(K)=A(I,JX(2))
1450 PM(K)=PM(K)+XP(K)*ND
1455 FOR L=KI TO K
1460 TJ(K,L)=TJ(K,L)+XP(K)*XP(L)*ND
1465 NEXT L,K
1470 NXX=NXX+ND : VX(I)=0
1475 NEXT I
1480 WHILE KE=1
1485 PRINT CHR$(7) : PRINT
1490 INPUT "** TRANSFORMACION INTERRUMPIDA - Valores<=0",A$ : RETURN
1495 WEND
1500 IF NXX<=NP THEN KE=3 : GOSUB 900 : RETURN
1505 TJ(0,0)=NXX
1510 FOR K=1 TO NVI+1
1515 FOR L=KI TO K
1520 TJ(L,K)=TJ(K,L)
1525 NEXT L,K
1530 FOR K=KI TO NVI
1535 ZXY(K)=TJ(K,NVI+1)
1540 NEXT K
1545 DET=TJ(NVI+1,NVI+1)
1550 N=NVI : GOSUB 11000
1555 IF KE=1 THEN RETURN
1560 AA(0)=0 : DAA(0)=0 : TS(0)=0 : SI(0)=0
1565 TC$(0)="TermIndep" : JX(0)=0
1570 FOR K=KI TO NVI
1575 AA(K)=TJ(K,NVI+1)
1580 TS(K)=ABS(TK(K,K))
1585 DET=DET-AA(K)*ZXY(K)
1590 IF TF=4 THEN AA(K)=EXP(AA(K))
1595 NEXT K
1600 IF TF=2 OR TF=3 THEN AA(0)=EXP(AA(0))
1605 IF KI=0 THEN NP=NVI+1 ELSE NP=NVI
1610 DET=SQR(DET/(NX-NP))
1615 GOSUB 1865
1620 VER=SER/(NXX-NP)
1625 DER=SQR(VER)
1630 SDY=SCY-SY^2/NXX
1635 VY=SDY/(NXX-1)
1640 RR=1-VER/VY
1645 FOR Z=KI TO NVI
1650 DAA(Z)=DET*SQR(TS(Z))
1655 TS(Z)=ABS(AA(Z)/DAA(Z))
1660 X=TS(Z) : P(1)=NXX-NP
1665 IP=1 : GOSUB 9125
1670 SI(Z)=100*2*(1-FP)
1675 NEXT Z
1680 KS=1
1685 WHILE KS=1
1690 GOSUB 555
1695 PRINT#3,"FUNCION DE REGRESION = ";C$
1700 PRINT#3," Variable Y = ";JX(NV);"- ";TC$(JX(NV))
1705 PRINT#3,: PRINT#3,"COEFICIENTES DE REGRESION" : PRINT#3,
1710 PRINT#3," Variable Xj Coefic. aj Desvio.Coef."; "
Valor t Signif.(%)"
1715 KA=3 : KB=79 : GOSUB 695
1717 KZ=0
1720 FOR K=0 TO NVI
1725 XX=JX(K) : IF TF=8 AND K>0 THEN XX=JX(1)
1730 D$=TC$(XX) : IF TF=8 AND K>0 THEN D$=LEFT$(D$,6)+"^"+STR$(K)
1735 PRINT#3,TAB(3);XX;"- ";D$;TAB(20);FNR(AA(K),NDE+2);
TAB(36);FNR(DAA(K),NDE+2);
1740 PRINT#3,TAB(50);FNR(TS(K),NDE);TAB(60);FNR(SI(K),2)
1742 IF K>5 AND KZ=0 AND DS$="SCRN:" THEN INPUT "",A$ : KZ=1
1745 NEXT K
1747 KA=3 : KB=79 : GOSUB 695
1748 PRINT#3,
1750 PRINT#3,"ESTADISTICAS DE REGRESION" : PRINT#3,
1755 PRINT#3, " Coefic.de Determin. R^2 = ";FNR((1-SER/SDY),NDE)
1760 PRINT#3, " Coefic.de Determin. R^2 (Correg.) = ";FNR(RR,NDE)
1765 PRINT#3, " Desvio Residuos = ";FNR(DER,NDE)
1770 GOSUB 650
1775 WEND
1780 KZ=0
1785 WHILE KZ=0
1790 GOSUB 555
1795 PRINT "PROCESOS COMPLEMENTARIOS"
1800 TF$(1)="Salida de Coeficientes de Correlacion"
1805 TF$(2)="Analisis de Variancia"
1810 TF$(3)="Prueba de Durbin-Watson"
1815 TF$(4)="Calculo de Valores Estimados y Residuos"
1820 TF$(5)="Prediccion de Valores de Y"
1825 TF$(6)="Graficacion"
1830 KL=6 : GOSUB 980
1835 IF ISP=0 THEN KZ=1 : GOTO 1845
1840 ON ISP GOSUB 2035,2135,2240,2435,2670,5200
1845 WEND
1850 WEND
1860 '
1865 ' EST612 - Calculo de Desvios Cuadraticos
1870 ' ---------------------------------------
1875 SER=0 : SY=0 : SCY=0
1880 FOR I=1 TO NF
1885 IF VX(I)=1 THEN 1935
1890 ND=1 : IF JF>0 THEN ND=A(I,JF)
1895 FOR K=1 TO NVI
1900 XP(K)=A(I,JX(K))
1905 NEXT K
1910 Y=A(I,JX(NV))
1915 SY=SY+ND*Y : SCY=SCY+ND*Y*Y
1920 GOSUB 1950
1925 ER=Y-YE
1930 SER=SER+ER*ER*ND
1935 NEXT I
1940 RETURN
1945 '
1950 ' EST613 - Calculo de y Estimado
1955 ' ------------------------------
1960 YE=AA(0)
1965 ON TF GOTO 1970,1975,1980,1985,1990,1995,2000,2005,2010
1970 FOR K=1 TO NVI : YE=YE+AA(K)*XP(K) : NEXT K : RETURN
1975 FOR K=1 TO NVI : YE=YE*XP(K)^AA(K) : NEXT K : RETURN
1980 FOR K=1 TO NVI : YE=YE*EXP(AA(K)*XP(K)) : NEXT K : RETURN
1985 FOR K=1 TO NVI : YE=YE*(AA(K))^XP(K) : NEXT K : RETURN
1990 FOR K=1 TO NVI : YE=YE+AA(K)*LOG(XP(K)) : NEXT K : RETURN
1995 FOR K=1 TO NVI : YE=YE+AA(K)/XP(K) : NEXT K : RETURN
2000 YE=EXP(AA(0)+AA(1)/XP(1)) : RETURN
2005 FOR K=1 TO NVI : YE=YE+AA(K)*XP(1)^K : NEXT K : RETURN
2010 FOR K=1 TO NVI : V(JX(K))=XP(K) : NEXT K
2015 YE=P(1)+P(2)*V(1)
2020 RETURN
2030 '
2035 ' EST613 - Calculo de coeficientes de Correlacion
2040 ' -----------------------------------------------
2045 GOSUB 5825
2050 IPC=2
2055 C$="COEFICIENTES DE CORRELACION"
2060 GOSUB 5974
2125 RETURN
2130 '
2135 ' EST614 - Analisis de Variancia
2140 ' ------------------------------
2145 SES=SDY-SER
2150 DES=SES/NVI
2155 X=DES/VER
2160 P(1)=NVI : P(2)=NXX-NVI-1
2165 IP=1 : GOSUB 9325
2170 SI(1)=FNR(100*(1-FP),2)
2175 KS=1
2180 WHILE KS=1
2185 PRINT#3, : PRINT#3, : PRINT#3,"ANALISIS DE VARIANCIA" : PRINT#3,
2190 PRINT#3,TAB(3);"Causa de Suma de Grados de Desvio"; "
F Significac."
2195 PRINT#3,TAB(3);"Variac.de Y Dev.Cuadr. Libertad Medio"; "
2200 KA=3 : KB=75 : GOSUB 695
2205 PRINT#3,TAB(3);"Variables X";TAB(16);FNR(SES,NDE);TAB(30);P(1);
TAB(38);FNR(DES,NDE);TAB(49);FNR(X,NDE);TAB(60);FNR(SI(1),2)
2210 PRINT#3,TAB(3);"Error e";TAB(16);FNR(SER,NDE);TAB(30);P(2);
TAB(38);FNR(VER,NDE)
2215 PRINT#3,TAB(3);"Total";TAB(16);FNR(SDY,NDE);TAB(30);NXX-1
2220 KA=3 : KB=75 : GOSUB 695 : PRINT#3,
2225 GOSUB 650
2230 WEND
2235 RETURN
2237 '
2240 ' EST615 - Prueba de Durbin-Watson
2245 ' --------------------------------
2250 KX=0 : DW=0 : SER=0
2255 FOR I=1 TO NF
2260 IF VX(I)=1 THEN KX=0 : GOTO 2305
2265 FOR K=1 TO NVI
2270 XP(K)=A(I,JX(K))
2275 NEXT K
2280 Y=A(I,JX(NV))
2285 GOSUB 1950 : ER=Y-YE
2290 SER=SER+ER*ER
2295 IF KX=1 THEN DW=DW+(ER-ERA)^2 ELSE KX=1
2300 ERA=ER
2305 NEXT I
2310 DW=DW/SER
2315 IF DW>2 THEN DW=4-DW
2320 DL(1)=.78576-.16513*NVI+.03427*NX+.0035773*NVI*NX-.0005*NX*NX -
.000022*NVI*NX*NX+2.49E-06*NX*NX*NX
2325 DU(1)=1.1176+.26277*NVI+.004913*NX-.0065215*NVI*NX+.000133*NX*NX
+4.283E-05*NVI*NX*NX-1.33E-06*NX*NX*NX
2330 DL(2)=.5529*(NVI^-.0134)*(NX^.11765)*DL(1)
2335 DU(2)=.69835*(NVI^.02326)*(NX^.05622)*DU(1)
2340 ALF(1)=5 : ALF(2)=1
2345 KS=1
2350 WHILE KS=1
2355 PRINT#3,
2360 PRINT#3,"PRUEBA DE DURBIN-WATSON" : PRINT#3,
2365 PRINT#3," Estadistica Durbin-Watson = ";FNR(DW,3) : PRINT#3,
2370 PRINT#3,TAB(4);"Niv.Sign(%)";TAB(16);"Rechazo";TAB(25);"dl";
TAB(29);"Indefin.";TAB(38);"du";TAB(43);"No Rechazo"
2375 KA=3 : KB=53 : GOSUB 695
2380 FOR M=1 TO 2
2385 A$="" : B$="" : C$=""
2390 IF DW<DL(M) THEN A$="*"
2395 IF DW>=DL(M) AND DW<=DU(M) THEN B$="*"
2400 IF DW>DU(M) THEN C$="*"
2405 PRINT#3,TAB(5);ALF(M);TAB(18);A$;TAB(24);FNR(DL(M),2);TAB(31);B$;
TAB(37);FNR(DU(M),2);TAB(45);C$
2410 NEXT M
2415 PRINT#3,
2420 GOSUB 650
2425 WEND
2430 RETURN
2433 '
2435 ' EST616 - Calculo de Valores Estimados y Residuos
2440 ' ------------------------------------------------
2443 FOR M=1 TO 2
2445 A$="VALORES ESTIMADOS DE Y" : IF M=2 THEN A$="RESIDUOS" : KVA=1
2447 PRINT : PRINT
2450 PRINT "ALMACENAMIENTO DE ";A$;" EN MEMORIA DE TRABAJO"
2460 GOSUB 390 : CY(M)=J
2465 NEXT M
2475 KS=1
2480 WHILE KS=1
2485 KX=0
2490 PRINT#3, : PRINT#3,
2495 FOR I=1 TO NF
2500 WHILE KX=0
2505 PRINT#3,"Nro.Obs. Y Real Y Estimado";" Residuo";
TAB(58);"Residuos Normalizados"
2510 PRINT#3,TAB(52);"-2S 0 2S"
2515 KA=1 : KB=79 : GOSUB 695
2520 IL=4 : KX=1
2525 WEND
2530 IF VX(I)=1 THEN 2645
2535 FOR K=1 TO NVI
2540 XP(K)=A(I,JX(K))
2545 NEXT K
2550 Y=A(I,JX(NV))
2555 GOSUB 1950 : ER=Y-YE : ERN=ER/(DER*2)
2560 IF CY(1)>0 THEN A(I,CY(1))=YE
2565 IF CY(2)>0 THEN A(I,CY(2))=ER
2570 PRINT#3,TAB(3);I;TAB(10);Y;TAB(24);FNR(YE,NDE);TAB(38);FNR(ER,NDE);TAB(53);
2575 FOR M=1 TO 25 : VY(M)=0 : NEXT M
2580 VY(2)=2 : VY(13)=1 : VY(24)=2
2585 X=INT(11*ERN+.5)
2590 IF X>11 THEN X=12
2595 IF X<-11 THEN X=-11
2600 VY(12+X)=3
2605 FOR M=1 TO 25
2610 A$=" "
2615 IF VY(M)=1 THEN A$="."
2620 IF VY(M)=2 THEN A$="I"
2625 IF VY(M)=3 THEN A$="*"
2630 PRINT#3,A$;
2635 NEXT M : PRINT#3,
2640 IL=IL+1 : IF IL=20 AND DS$="SCRN:" THEN INPUT "Enter",A$ : CLS :KX=0
2645 NEXT I
2650 GOSUB 650
2655 WEND
2660 RETURN
2665 '
2670 ' EST617 - Prediccion de valores de Y
2675 ' -----------------------------------
2680 PRINT : INPUT "Nivel de Significacion Prediccion en % = ",A$
2685 IF LEN(A$)=0 THEN RETURN
2690 AL=VAL(A$)
2695 IF AL<=0 OR AL>=100 THEN KE=5 : B$=">0 y <100" : GOSUB 900: GOTO 2680
2700 WHILE KW=0
2705 PRINT
2710 FOR K=1 TO NV-1
2715 J=JX(K)
2720 PRINT "Valor de Variable";J; "(";TC$(J);")"; : INPUT " = ",A$
2725 IF LEN(A$)=0 THEN RETURN
2730 XP(K)=VAL(A$)
2735 XYZ(K)=XP(K)
2740 IF TF=2 OR TF=5 AND XP(K)<=0 THEN KE=5 : B$=">0" :
GOSUB 900 : GOTO 2720
2745 IF TF=2 OR TF=5 THEN XYZ(K)=LOG(XP(K))
2750 IF TF=6 OR TF=7 AND XP(K)<=0 THEN KE=5 : B$=">0" :
GOSUB 900 : GOTO 2720
2755 IF TF=6 OR TF=7 THEN XYZ(K)=1/XP(K)
2760 IF TF=8 THEN FOR M=1 TO NVI : XYZ(M)=XP(M)^M : NEXT M
2765 NEXT K
2770 GOSUB 1950
2775 XXX=TF : TF=7 : IP=1 : P(1)=NX-2
2780 FPX=1-AL/200 : GOSUB 7710 : TF=XXX
2785 XYZ(0)=1
2790 HH=0
2795 FOR K=KI TO NVI
2800 TS(K)=0
2805 FOR L=KI TO NVI
2810 TS(K)=TS(K)+XYZ(L)*TK(L,K)
2815 NEXT L
2820 HH=HH+TS(K)*XYZ(K)
2825 NEXT K
2830 XLP=X*DER*SQR(HH)
2835 XLI=X*DER*SQR(HH+1)
2840 IF TF=1 OR TF=5 OR TF=6 OR TF=8 THEN XSP=YE+XLP : XIP=YE-XLP :
XSI=YE+XLI : XII=YE-XLI
2845 IF TF=2 OR TF=3 OR TF=4 OR TF=7 THEN XSP=YE*EXP(XLP) : XIP=YE/EXP(XLP) :
XSI=YE*EXP(XLI) : XII=YE/EXP(XLI)
2850 KS=1
2855 WHILE KS=1
2860 PRINT#3, : PRINT#3,"PREDICCION" : PRINT#3,
2865 FOR K=1 TO NV-1
2870 PRINT#3,TAB(3);JX(K);"- ";TC$(JX(K));" = ";XYZ(K)
2875 NEXT K
2880 PRINT#3, : PRINT#3,TAB(3);JX(NV);"- ";TC$(JX(NV));" = ";YE
2885 PRINT#3, : PRINT#3,TAB(3);"Intervalos de Confianza (para nivel sign. ";AL;" %)"
2890 PRINT#3,TAB(6);"Promedio = ";FNR(XIP,NDE);" - ";FNR(XSP,NDE)
2895 PRINT#3,TAB(6);"Valor Individual = ";FNR(XII,NDE);" - ";FNR(XSI,NDE)
2900 GOSUB 650
2905 WEND
2910 WEND
2912 '
2915 ' EST62 - Regresion No Lineal
2920 ' ---------------------------
2925 TF=9
2930 TSP$="Regresion no Lineal General"
2935 'WHILE KW=0
2940 GOSUB 555
2945 PRINT : PRINT "DEFINICION DE VARIABLES (2 a";PAR2-1;")"
2947 PRINT " Las Primeras son las Variables Independientes"
2950 PRINT " La Ultima es la Variable Dependiente"
2955 KNV=PAR2-1
2957 GOSUB 200
2960 IF NV=0 THEN RETURN
2965 IF NV<2 OR NV>KNV THEN KE=2: GOSUB 900: GOTO 2957
2970 NVI=NV-1
2975 NXX=0 : KE=0
2980 FOR I=1 TO NF
2985 VX(I)=1
2990 IF A(I,0)=1 THEN 3020
2993 ND=1 : IF JF>0 THEN ND=A(I,JF) : IF ND=XVF THEN 3020
2995 FOR K=1 TO NV
3000 X=A(I,JX(K))
3005 IF X=XVF THEN KE=1 : K=NV
3010 NEXT K
3015 IF KE=0 THEN NXX=NXX+ND : VX(I)=0
3020 NEXT I
3025 IF NXX<=NP THEN KE=3 : GOSUB 900 : RETURN
3030 PRINT : PRINT : PRINT "INGRESO DE FUNCION DE REGRESION" : PRINT
3035 GOSUB 500
3040 IF LEN(FU$)=0 THEN 3060
3045 PRINT "Funcion de Regresion Existente = ",FU$
3050 INPUT "Se Modifica (S/N) ? = ",A$
3055 IF A$<>"S" AND A$<>"s" THEN 3100
3060 PRINT : INPUT "Funcion a Ingresar = ",A$
3065 IF LEN(A$)=0 THEN FU$="" : RETURN
3070 FU$=A$
3075 OPEN DDA$+":xyz.bas" FOR OUTPUT AS #1
3080 PRINT#1,"2015 ye="+FU$
3085 CLOSE#1
3090 CHAIN MERGE DDA$+":xyz",3095,ALL
3095 KILL DDA$+":xyz.bas"
3140 PRINT : INPUT "Numero de Parametros = ",A$
3145 IF LEN(A$)=0 THEN RETURN
3150 NP=VAL(A$)
3155 IF NP<1 OR NP >5 THEN KE=5 : B$=">=1 y <=5" : GOSUB 900 : GOTO 3140
3160 FOR I=1 TO NP
3165 PRINT
3170 PRINT "Parametro";I
3175 INPUT " Valor Inicial = ",A$
3180 IF LEN(A$)=0 THEN RETURN
3185 P(I)=VAL(A$)
3190 INPUT " Incremento Inicial = ",A$
3195 IF LEN(A$)=0 THEN RETURN
3200 DELT(I)=VAL(A$)
3205 IF DELT(I)<=0 THEN KE=5 : B$=">0" : GOSUB 900 : PRINT : GOTO 3190
3215 NEXT I
3220 PRINT : INPUT "Numero Maximo de Iteraciones (50) = ",A$
3225 IF LEN(A$)=0 THEN ITM=50 ELSE ITM=VAL(A$)
3227 IF ITM<1 THEN KE=5 : B$=">0" : GOSUB 900 : GOTO 3220
3230 PRINT : PRINT TAB(25);"EN PROCESO"
3235 GOSUB 1865
3240 GOSUB 3450
3245 VER=SER/(NXX-NP)
3250 DER=SQR(VER)
3255 SDY=SCY-SY^2/NXX
3260 VY=SDY/(NXX-1)
3265 RR=1-VER/VY
3270 KS=1
3275 WHILE KS=1
3280 GOSUB 555
3285 PRINT#3,"FUNCION DE REGRESION = ";FU$
3290 PRINT#3," Variable Y = ";JX(NV);"- ";TC$(JX(NV))
3295 PRINT#3," Variables Independientes = ";
3300 FOR I=1 TO NVI
3305 PRINT#3,TAB(31);JX(I);"- ";TC$(JX(I))
3310 NEXT I
3315 PRINT#3,: PRINT#3,"COEFICIENTES DE REGRESION" : PRINT#3,
3317 PRINT#3," j Coefic. aj Desvio.Coef. aj"
3318 KA=3 : KB=60 : GOSUB 695
3319 KZ=0
3320 FOR I=1 TO NP
3325 PRINT#3,TAB(3);I;TAB(15);FNR(P(I),NDE+2);TAB(30);FNR(SIGP(I),NDE+2)
3327 IF K>5 AND KZ=0 AND DS$="SCRN:" THEN INPUT "",A$ : KZ=1
3330 NEXT I
3333 KA=3 : KB=60 : GOSUB 695
3335 PRINT#3,
3340 PRINT#3, : PRINT#3,"ESTADISTICAS DE REGRESION" : PRINT#3,
3345 PRINT#3, " Coefic.de Determin. R^2 = ";FNR((1-SER/SDY),NDE)
3350 PRINT#3, " Coefic.de Determin. R^2 (Correg.) = ";FNR(RR,NDE)
3355 PRINT#3, " Desvio Residuos = ";FNR(DER,NDE)
3360 GOSUB 650
3365 WEND
3370 KZ=0
3375 WHILE KZ=0
3380 GOSUB 555
3385 PRINT "PROCESOS COMPLEMENTARIOS"
3390 TF$(1)="Coeficientes de Correlacion"
3395 TF$(2)="Analisis de Variancia"
3400 TF$(3)="Prueba de Durbin-Watson"
3405 TF$(4)="Calculo de Valores estimados y Residuos"
3410 TF$(5)="Prediccion de Valores de Y"
3415 TF$(6)="Graficacion"
3420 KL=6 : GOSUB 980
3425 IF ISP=0 THEN KZ=1 : GOTO 3435
3430 ON ISP GOSUB 2035,2135,2240,2435,2670,5200
3435 WEND
3440 GOTO 20
3445 '
3450 ' EST621 - Minimizacion de una funcion general
3455 ' --------------------------------------------
3460 ITE=0 : SERA=0 : SER=1
3500 WHILE ABS((SER-SERA)/SER)>.001 AND ITE<ITM
3510 SERA=SER
3520 FOR J=1 TO NP
3525 GOSUB 1865 : SER1=SER
3530 NK=0
3535 DEL=DELT(J)
3537 XX=P(J)
3540 P(J)=P(J)+DEL
3545 GOSUB 1865 : SER2=SER
3550 IF SER2=SER1 THEN 3540
3555 IF SER2<SER1 THEN 3575
3560 DEL=-DEL
3563 P(J)=XX+DEL
3565 GOSUB 1865
3570 SER1=SER2 : SER2=SER
3575 NK=NK+1
3580 P(J)=P(J)+DEL
3585 GOSUB 1865 : SER3=SER
3590 IF SER3<SER2 THEN SER1=SER2 : SER2=SER3 : GOTO 3575
3595 DEL=DEL*(1/(1+(SER1-SER2)/(SER3-SER2))+.5)
3600 P(J)=P(J)-DEL
3610 SIGP(J)=DELT(J)*SQR(2/((NXX-NP)*(SER3-2*SER2+SER1)))
3615 DELT(J)=DELT(J)*NK/3
3625 NEXT J
3640 WEND
3650 GOSUB 1865
3680 RETURN
5200 ' EST24 - Graficacion
5205 ' -------------------
5210 TSP$="Graficacion"
5215 WHILE KW=0
5220 GOSUB 555
5225 TF$(1)="Graficacion Normal"
5230 TF$(2)="Graficacion Codificada"
5235 KL=2 : GOSUB 980
5240 IF ISP=0 THEN RETURN
5245 KM=3 : IF ISP=2 THEN KM=1
5250 GOSUB 500
5255 PRINT
5260 FOR Y=1 TO 2
5265 IF Y>1 THEN 5305
5270 INPUT "Variable Independiente = ",A$
5275 IF LEN(A$)=0 THEN RETURN
5280 IF (A$="I" OR A$="i") THEN TG$(0)="Nro.Obs" : XMN(1)=0
- XMX(1)=INT(NF/5+1)*5:DEL(1)=XMX(1)/5:GOTO 5460
5285 KX=VAL(A$)
5290 J=KX : GOSUB 5480
5295 XC=XMI : XD=XMA
5300 TG$(0)=TC$(KX) : GOTO 5380
5305 XC=1E+10 : XD=-1E+10
5310 PRINT
5315 FOR Z=1 TO KM
5320 PRINT "Variable Dependiente";Z;
5325 INPUT " = ",A$
5330 IF LEN(A$)=0 THEN NG=Z-1 : Z=KM : GOTO 5365
5335 NG=Z
5340 JY(Z)=VAL(A$)
5345 J=JY(Z) : GOSUB 5480
5350 IF XMI<XC THEN XC=XMI
5355 IF XMA>XD THEN XD=XMA
5360 TG$(Z)=TC$(JY(Z))
5365 NEXT Z
5370 IF NG=0 THEN RETURN
5375 PRINT
5380 PRINT "(Valores Maximo y Minimo de los Datos = ";XC;"-";XD;")"
5385 INPUT " Valor Minimo = ",A$
5390 IF LEN(A$)=0 THEN RETURN
5395 XMN(Y)=VAL(A$)
5400 INPUT " Valor Maximo = ",A$
5405 IF LEN(A$)=0 THEN RETURN
5410 XMX(Y)=VAL(A$)
5415 INPUT " Intervalo = ",A$
5420 IF LEN(A$)=0 THEN RETURN
5425 DEL(Y)=VAL(A$)
5430 IF ISP=1 THEN GOTO 5460
5435 IF Y=1 THEN 5460
5440 PRINT : INPUT "Variable con Valores codificados (No) = ",A$
5445 IF LEN(A$)=0 THEN ISP=1 : GOTO 5460
5450 IF A$="I" OR A$="i" THEN JV=0 : GOTO 5460
5455 JV=VAL(A$)
5460 NEXT Y
5463 NPG=NF
5465 KA=0
5470 IF NG>0 THEN GOSUB 6745
5475 WEND
5477 '
5480 ' EST211 - Calculo de Valor medio, Desv.Std.,Max.,Min.
5485 ' ----------------------------------------------------
5490 SX=0 : SCX=0 : NXX=0
5495 XMI=1E+10 : XMA=-1E+10
5500 FOR I=1 TO NF
5505 IF A(I,0)=1 THEN 5550
5510 X= A(I,J)
5515 IF X=XVF THEN 5550
5520 IF X<XMI THEN XMI=X
5525 IF X>XMA THEN XMA=X
5530 ND=1 : IF JF>0 THEN ND=A(I,JF)
5535 IF ND=XVF THEN 5550
5540 SX=SX+ND*X : SCX=SCX+ND*X^2
5545 NXX=NXX+ND
5550 NEXT I
5555 IF NXX<2 THEN RETURN
5560 PX=SX/NXX
5565 DEM=SQR((SCX-NXX*PX^2)/NXX)
5570 DEX=SQR((SCX-NXX*PX^2)/(NXX-1))
5575 RETURN
5580 '
5825 ' EST214 - Calculo de Matriz de Covariancias
5830 ' ------------------------------------------
5835 FOR K=1 TO NV
5840 PM(K)=0
5845 FOR L=1 TO K : TI(K,L)=0 :NEXT L
5850 NEXT K
5855 NXX=0
5860 FOR I=1 TO NF
5865 IF A(I,0)=1 THEN 5945
5870 ND=1 : IF JF>0 THEN ND=A(I,JF)
5875 IF ND=XVF THEN 5945
5880 KE=0
5885 FOR K=1 TO NV
5890 XP(K)=A(I,JX(K))
5895 IF XP(K)=XVF THEN KE=1 : K=NV
5900 NEXT K
5905 IF KE=1 THEN 5945
5910 FOR K=1 TO NV
5915 PM(K)=PM(K)+XP(K)*ND
5920 FOR L=1 TO K
5925 TI(K,L)=TI(K,L)+XP(K)*XP(L)*ND
5930 NEXT L
5935 NEXT K
5940 NXX=NXX+ND
5945 NEXT I
5950 IF NXX<2 THEN RETURN
5955 FOR K=1 TO NV
5960 VX(K)=PM(K)
5962 PM(K)=PM(K)/NXX
5964 DE(K)=SQR((TI(K,K)-NXX*PM(K)^2)/(NXX-1))
5966 FOR L=1 TO K
5968 TI(K,L)=(TI(K,L)-NXX*PM(K)*PM(L))/(NXX-1)
5970 TI(L,K)=TI(K,L)
5971 NEXT L,K
5972 RETURN
5973 '
5974 ' EST215 - Salida Covar. y Coef.Correlac.
5975 ' ---------------------------------------
5977 KS=1
5978 WHILE KS=1
5979 PRINT#3, : PRINT#3, : PRINT#3,C$
5980 PRINT#3, : KN=0
5981 FOR M=1 TO NV STEP 6
5982 KM=KN+1 : KN=KM+5
5983 IF KN>NV THEN KN=NV
5984 PRINT#3,"Variable";
5985 FOR K=KM TO KN : PRINT#3,TAB(9*(K-KM)+19);TC$(JX(K)); : NEXT K
5986 PRINT#3, : PRINT#3,
5987 FOR K=KM TO KN
5988 PRINT#3,TAB(3);JX(K);TAB(7);"-";TC$(JX(K));
5989 FOR L=K TO KN
5990 CA=1 : IF IPC>1 THEN CA=DE(K)*DE(L)
5991 IF CA>0 THEN X=TI(L,K)/CA ELSE X=0
5992 IF IPC<3 THEN 5999
5993 IF X>.9999 THEN X=0 : GOTO 5999
5994 X=ABS(X*SQR((NXX-2)/(1-X*X)))
5995 P(1)=NXX-2 : KXX=K
5996 IP=1 : GOSUB 8800
5997 X=200*(1-FP)
5998 K=KXX
5999 IF IPC<3 THEN PRINT#3,TAB(9*(L-KM)+19);FNR(X,NDE);
6000 IF IPC=3 THEN PRINT#3,TAB(9*(L-KM)+19);FNR(X,NDE-1);
6001 NEXT L
6002 PRINT#3,
6003 NEXT K
6004 IF DS$="SCRN:" THEN PRINT : INPUT "Enter ",A$
6005 NEXT M
6006 GOSUB 650
6007 WEND
6008 RETURN
6743 '
6745 ' EST241 - Proceso de Graficacion
6750 ' -------------------------------
6755 DEF FNC(X)=60*(X-XMN(1))/(XMX(1)-XMN(1))
6760 DEF FNF(X)=20*(X-XMN(2))/(XMX(2)-XMN(2))
6765 CLS
6770 X=21-FNF(0) : KC=0
6775 IF X>0 AND X<21 THEN KC=1
6780 FOR I=1 TO 60
6785 IF KC=1 THEN LOCATE X,I+20 : PRINT "."
6790 LOCATE 1,I+20 : PRINT "-"
6795 LOCATE 21,I+20 : PRINT "-"
6800 NEXT I
6805 FOR X=XMN(1) TO XMX(1) STEP DEL(1)
6810 XC=FNC(X)
6815 LOCATE 1,XC+20 : PRINT "+"
6820 LOCATE 21,XC+20 : PRINT "+"
6825 IF X<XMX(1) THEN LOCATE 22,XC+18 : PRINT FNR(X,2)
6830 NEXT X
6835 LOCATE 23,70 : PRINT TG$(0)
6840 X=FNC(0)+20 : KC=0
6845 IF X>20 AND X<80 THEN KC=1
6850 FOR I=1 TO 20
6855 IF KC=1 THEN LOCATE I,X : PRINT "."
6860 LOCATE I,20 : PRINT CHR$(124)
6865 LOCATE I,80 : PRINT CHR$(124)
6870 NEXT I
6875 FOR X=XMN(2) TO XMX(2) STEP DEL(2)
6880 XF=21-FNF(X)
6885 LOCATE XF,20 : PRINT "+"
6890 LOCATE XF,80 : PRINT "+"
6895 LOCATE XF,13 : PRINT FNR(X,2)
6900 NEXT X
6905 TF$(1)="*" : TF$(2)=CHR$( 22) : TF$(3)="x"
6910 IF ISP=2 THEN C$="ABCDEFGHIJKLMNOPQRTSUVWXYZ"
6915 FOR J=1 TO NG
6920 LOCATE 3+3*J,1 : IF ISP=1 THEN PRINT TF$(J)
6925 PRINT TG$(J)
6930 NEXT J
6935 IF ISP=2 THEN PRINT : PRINT : PRINT "Var.Codif=" : PRINT JV;" - ";TC$(JV)
6940 NXX=0
6945 FOR I=1 TO NPG
6950 IF KA=0 THEN IF A(I,0)=1 THEN 7105
6955 IF KX=0 THEN X=I : GOTO 6975
6960 IF KA=0 THEN X=A(I,KX)
6965 IF KA=0 AND X=XVF THEN 7105
6970 IF KA=1 THEN X=TI(I,0)
6975 XC=FNC(X)+20
6980 IF XC<20 OR XC>80 THEN 7100
6985 FOR J=1 TO NG
6990 IF KA=0 THEN Y=A(I,JY(J))
6995 IF KA=0 AND Y=XVF THEN 7105
7000 IF KA=1 THEN Y=TI(I,JY(J))
7005 YF=21-FNF(Y)
7010 IF YF<1 OR YF>21 THEN 7090
7015 FOR XF=YF TO 21
7020 LOCATE XF,XC
7025 A$=TF$(J)
7030 IF ISP=1 THEN 7075
7035 IF JV>0 THEN X=A(I,JV)
7040 IF JV>0 AND X=XVF THEN XF=21 : GOTO 7085
7045 IF JV>0 THEN X=INT(X)
7050 IF JV=0 THEN X=I
7055 IF X<0 THEN A$="-"
7060 IF X>=0 AND X<10 THEN A$=STR$(X)
7065 IF X>=10 AND X<35 THEN A$=MID$(C$,X-9,1)
7070 IF X>35 THEN A$="+"
7075 PRINT A$
7080 IF KB(J)=0 THEN XF=21
7085 NEXT XF
7090 NEXT J
7095 NXX=NXX+1
7100 LOCATE 23,1
7105 NEXT I
7110 LOCATE 24 : INPUT "Enter ",A$
7115 RETURN
7710 ' EST320 - Calculo del valor x para F(x)
7715 '
7720 WHILE KDI=0
7725 IP=1 : GOSUB 8005
7730 X=XMU : DI=SIG
7735 GOSUB 8005
7740 FP=FP-FPX
7745 IF ABS(FP)<=.001 THEN RETURN
7750 IF FP>0 THEN DI=-DI
7755 MX=0
7760 WHILE MX=0
7765 XY=X : FPY=FP : X=X+DI
7770 GOSUB 8005
7775 FP=FP-FPX
7780 IF ABS(FP)<=.001 THEN RETURN
7785 IF DI<0 AND FP<0 THEN XD=X : XE=XY : FPD=FP : FPE=FPY : MX=1
7790 IF DI>0 AND FP>0 THEN XD=XY : XE=X : FPD=FPY : FPE=FP : MX=1
7795 WEND
7800 WHILE ABS(FPY)>.001
7805 X=XD-FPD*(XE-XD)/(FPE-FPD)
7810 GOSUB 8005
7815 FPY=FP-FPX
7820 IF FPY>0 THEN XE=X : FPE=FPY
7825 IF FPY<0 THEN XD=X : FPD=FPY
7830 WEND
7835 RETURN
7840 WEND
7845 WHILE KDI=1
7850 IP=1 : GOSUB 8005
7855 X=INT(X) : DI=INT(SIG)
7860 GOSUB 8005
7865 FP=FP-FPX
7870 IF FP>0 THEN DI=-DI
7875 MX=0
7880 WHILE MX=0
7885 XY=X : FPY=FP : X=X+DI
7890 GOSUB 8005
7895 FP=FP-FPX
7900 IF DI<0 AND FP<0 THEN XD=X : XE=XY : FPD=FP : MX=1
7905 IF DI>0 AND FP>0 THEN XD=XY : XE=X : FPD=FPY : MX=1
7910 WEND
7915 FOR M=XD TO XE
7920 X=M
7925 GOSUB 8005
7930 FPD=FPD+FD
7935 IF FPD>=0 THEN M=XE
7940 NEXT M
7945 RETURN
7950 WEND
7953 '
8005 ' EST300 - Llamada a Rutinas Distribuciones
8010 '
8015 ON TF GOSUB 8030,8125,8245,8335,8600,8855,8970,9125,9325,9510,9640,
9785,9940,10235,10390
8020 RETURN
8025 '
8125 ' EST302 - Distribucion Normal
8130 '
8135 XMU=P(1) : SIG=P(2)
8140 ON IP GOTO 8150,8205,8225
8145 '
8150 U=(X-XMU)/SIG
8155 MXA=0 : IF U<0 THEN U=-U : MXA=1
8160 FD=.39894228#*EXP(-U*U/2)
8165 CA=1/(1+.2316419*U)
8170 FP=FD*CA*(.3193815+CA*(-.3565638+CA*(1.781478+CA*(-1.821256+1.330274*CA))))
8175 IF MXA=0 THEN FP=1-FP
8180 IF FP>1 THEN FP=1
8185 IF FP<0 THEN FP=0
8190 FD=FD/SIG
8195 RETURN
8200 '
8205 IF KSA(1)=1 THEN P(1)=PX
8210 IF KSA(2)=1 THEN P(2)=DEX
8215 RETURN
8220 '
8225 X=SIG*SQR(-2*LOG(RND))*COS(6.283185*RND)+XMU
8230 RETURN
8235 WEND
8240 '
8970 ' EST307 - Dist.Chi^2
8975 '
8980 K=P(1)
8985 ON IP GOTO 8995,9070,9090
8990 '
8995 XMU=K : SIG=SQR(2*K)
9000 IF X=0 AND K=1 THEN FD=1E+30 : FP=0 : RETURN
9005 IF X=0 AND K=2 THEN FD=.5 : FP=0 : RETURN
9010 IF X<=0 THEN FD=0 : FP=0 : RETURN
9015 XA=X
9020 X=(X/K)^(1/3)
9025 P(1)=1-2/9/K
9030 P(2)=SQR(2/9/K)
9035 GOSUB 8125
9040 XN=(K/2-1) : GOSUB 10655
9045 FD=EXP((K/2-1)*LOG(X)-X/2-.3465735*K-FA)
9050 X=XA : P(1)=K
9055 XMU=K : SIG=SQR(2*K)
9060 RETURN
9065 '
9070 IF KSA(1)=1 THEN P(1)=INT(PX+.5)
9075 IF P(1)<1 THEN P(1)=1
9080 RETURN
9085 '
9090 P(1)=1-2/9/K
9095 P(2)=SQR(2/9/K)
9100 GOSUB 8125
9105 X=(K*X)^3
9110 P(1)=K
9115 RETURN
9120 '
9125 ' EST308 - Distribucion t
9130 '
9135 K=P(1)
9140 ON IP GOTO 9150,9270,9290
9145 '
9150 WHILE K>0 AND K<250
9155 XN=(K-1)/2 : GOSUB 10655 : FD=FA
9160 XN=(K-2)/2 : GOSUB 10655 : FD=FD-FA
9165 FDZ=EXP(FD-.5*LOG(3.14159265#*K)-.5*(K+1)*LOG(1+X*X/K))
9170 'IF X=0 THEN FP=.5 : FD=FDZ : RETURN
9175 XA=X : Y=X*X
9180 XK=SQR((2/9/K)*Y^(2/3)+2/9)
9185 U=((1-2/9/K)*(Y^(1/3))-7/9)/XK
9190 X=U : P(1)=0 : P(2)=1 : GOSUB 8125
9195 X=XA : P(1)=K
9200 FP=.5+.5*FP
9205 IF X<0 THEN FP=1-FP
9210 FD=FDZ
9215 K=0
9220 WEND
9225 WHILE K>=250
9230 P(1)=0 : P(2)=1 : GOSUB 8125
9235 P(1)=K : K=0
9240 WEND
9245 K=P(1)
9250 XMU=0
9255 SIG=0 : IF K>2 THEN SIG=SQR(K/(K-2))
9260 RETURN
9265 '
9270 IF KSA(1)=1 THEN P(1)=INT(2*DEX^2/(DEX^2-1)+.5)
9275 IF KSA(1)=1 AND P(1)<3 THEN P(1)=3
9280 RETURN
9285 '
9290 P(1)=0 : P(2)=1 : GOSUB 8125
9295 U=X
9300 P(1)=K
9305 GOSUB 8970
9310 X=U/SQR(X/K)
9315 RETURN
9320 '
9325 ' EST309 - Dist. F
9330 '
9335 KM=P(1) : KN=P(2)
9340 ON IP GOTO 9350,9430,9475
9345 '
9350 XMUX=0 : SIGX=0
9355 IF KN>2 THEN XMUX=KN/(KN-2)
9360 IF KN>4 THEN XSIGX=KN*SQR(2*(KM+KN-2)/(KM*(KN-2)^2*(KN-4)))
9365 IF X<=0 THEN FD=0 : FP=0 : XMU=XMUX : SIG=SIGX : RETURN
9370 XN=(KM+KN-2)/2 : GOSUB 10655 : FDZ=FA
9375 XN=(KM-2)/2 : GOSUB 10655 : FDZ=FDZ-FA
9380 XN=(KN-2)/2 : GOSUB 10655 : FDZ=FDZ-FA
9385 FDZ=FDZ+(KM/2)*LOG(KM/KN)+.5*(KM-2)*LOG(X)-.5*(KM+KN)*LOG(1+KM*X/KN)
9390 FDZ=EXP(FDZ)
9395 XK=SQR((2/9/KN)*X^(2/3)+2/9/KM)
9400 U=((1-2/9/KN)*X^(1/3)-(1-2/9/KM))/XK
9405 XA=X : X=U : P(1)=0 : P(2)=1 : GOSUB 8125
9410 X=XA : P(1)=KM : P(2)=KN
9415 FD=FDZ : XMU=XMUX : SIG=SIGX
9420 RETURN
9425 '
9430 XA=PX : IF XA=1 THEN XA=1.001
9435 N=2*XA/(XA-1)
9440 IF KSA(1)=1 THEN P(2)=INT(N+.5)
9445 IF KSA(1)=1 AND P(2)<5 THEN P(2)=5
9450 IF KSA(2)=0 THEN 9460
9455 P(1)=INT((2*P(2)-4)/(DEX^2*(P(2)-2)^2*(P(2)-4)/P(2)^2-2)+.5)
9460 IF KSA(2)=1 AND P(1)<1 THEN P(1)=1
9465 RETURN
9470 '
9475 GOSUB 8970
9480 XX=X
9485 P(1)=KN
9490 GOSUB 8970
9495 P(1)=KM : P(2)=KN
9500 X=XX*KN/(X*KM)
9505 RETURN
9507 '
10655 ' EST320 - Calculo de Log(Factorial)
10660 '
10665 WHILE XN>=-.5 AND XN<=4 AND INT(2*XN)=2*XN
10670 IF XN=-.5 THEN FA=.57236494#
10675 IF XN=0 THEN FA=0
10680 IF XN=.5 THEN FA=-.12078224#
10685 IF XN=1 THEN FA=0
10690 IF XN=1.5 THEN FA=.28468287#
10695 IF XN=2 THEN FA=.693147181#
10700 IF XN=2.5 THEN FA=1.2009736#
10705 IF XN=3 THEN FA=1.79175947#
10710 IF XN=3.5 THEN FA=2.45373657#
10715 IF XN=4 THEN FA=3.17805383#
10720 RETURN
10725 WEND
10730 Y=1/(XN*XN)
10735 Y=(XN+.5)*LOG(XN)-XN*(1-Y*(1/12-Y*(1/360-Y*(1/1260-Y/1680))))
10740 FA=Y+.91893853#
10745 RETURN
11000 ' EST611 - Resolucion de Ecuaciones Lineales
11005 ' ------------------------------------------
11010 FOR IP=KI TO N
11015 FOR JP=KI TO N
11020 IF IP<>JP THEN TK(IP,JP)=0 ELSE TK(IP,JP)=1
11025 NEXT JP,IP
11030 FOR IP=KI TO N
11035 FOR JP= IP TO N
11040 IF TJ(IP,JP)<>0 THEN 11055
11045 NEXT JP
11047 PRINT CHR$(7) : PRINT
11050 INPUT "** NO HAY SOLUCION AL SISTEMA DE ECUACIONES LINEALES",A$ :
KE=1: RETURN
11055 IF IP=JP THEN 11080
11060 FOR J=KI TO N+1
11065 X=TJ(IP,J) : TJ(IP,J)=TJ(JP,J) : TJ(JP,J)=X
11070 X=TK(IP,J) : TK(IP,J)=TK(JP,J) : TK(JP,J)=X
11075 NEXT J
11080 PIV=TJ(IP,JP)
11085 FOR J=KI TO N+1
11090 TJ(IP,J)=TJ(IP,J)/PIV
11095 TK(IP,J)=TK(IP,J)/PIV
11100 NEXT J
11105 FOR I=KI TO N
11110 IF I=IP THEN 11140
11115 X=TJ(I,JP)
11120 FOR J=KI TO N+1
11125 TJ(I,J)=TJ(I,J)-X*TJ(IP,J)
11130 TK(I,J)=TK(I,J)-X*TK(IP,J)
11135 NEXT J
11140 NEXT I
11145 NEXT IP
11150 RETURN
11200 '