Microsoft Ekon Machine

A miscellany of modules from an Economics M. A.
in QuickBASIC 4.50 plus 82-2dall.fil

    REM POLICY MACHINE
    :
    DECLARE SUB READATA ()
    DECLARE SUB PUTMATRIX ()
    DECLARE SUB DETERMINANT (D!)
    DECLARE SUB CRAMERS ()
    DECLARE SUB IDENTITYMINUS ()
    DECLARE SUB COEFFICIENTS ()
    DECLARE SUB TABLEHELP ()
    DECLARE SUB MAKEMATRIX ()
    GOTO 0
Z:  CLS : CLEAR
    TABLEHELP
    DIM SHARED O
    CLS
    INPUT "MATRIX SIZE (eg.3)"; O
    DIM SHARED D(O - 1), X(O - 1)
    DIM SHARED A(O - 1, O - 1), B(O - 1, O - 1)
    PRINT
    INPUT "(C)OMPUTE, (R)EAD OR (E)NTER COEFFICIENTS"; Y$
    IF Y$ = "R" OR Y$ = "r" THEN READATA: GOTO 15
    IF Y$ = "E" OR Y$ = "e" THEN PUTMATRIX: GOTO 15
    MAKEMATRIX
    COEFFICIENTS
15 : IDENTITYMINUS
    CRAMERS
    :
0 :  REM FRONTEND
    CLEAR
    CLS
    FOR I = 1 TO 77
      PRINT CHR$(220);
      FOR J = 1 TO 10
      NEXT J
    NEXT I
    PRINT
    FOR I = 1 TO 210
      PRINT "  "; CHR$(179); "     ";
    NEXT I
    PRINT
    FOR I = 1 TO 77
      PRINT CHR$(219);
    NEXT I
    PRINT
    LOCATE 23, 1
    COLOR 0, 7
    PRINT "Press any key to continue"
    LOCATE 4, 36
    PRINT "MACHINE"
    COLOR 7, 0
    LOCATE 1, 1
    DO
    LOOP WHILE INKEY$ = ""
    :
A:  CLS : CLEAR
    PRINT TAB(30); "MACHINE MENU"
    PRINT TAB(30); STRING$(12, CHR$(254))
    PRINT : PRINT
    PRINT "1) MATHEMATICS"
    PRINT "2) STATISTICS"
    PRINT "3) ECONOMICS"
    PRINT "4) EXIT"
    PRINT : PRINT
    INPUT "SELECT"; N
    IF N > 4 THEN GOTO A
    ON N GOTO B, G, M, S
    GOTO A
    :
    REM MATHEMATICS MODULE
B:  CLS : CLEAR
    PRINT TAB(30); "MATHEMATICS MENU"
    PRINT TAB(30); "================"
    PRINT : PRINT
    PRINT "1) PRESENT VALUE"
    PRINT "2) TOTAL DERIVATIVE"
    PRINT "3) SUM OF INTEGRAL"
    PRINT "4) LAGRANGEAN MULTIPLIER"
    PRINT "5) I-O COEFFICIENTS"
    PRINT : PRINT
    INPUT "SELECT"; N
    IF N = 0 THEN GOTO A
    IF N > 5 THEN GOTO B
   
    ON N GOTO C, D, E, F, Z
    :
C:  CLS : CLEAR
    PRINT : PRINT TAB(25); "PRESENT VALUE OF PENSION PLAN"
    PRINT : PRINT : PRINT
    LINE INPUT "PLS ENTER NUMBER OF YEARS==> "; N$
    N = VAL(N$)
    DIM Y(N), W(N)
    LINE INPUT "TYPE BEGINNING SALARY==> "; B$
    B = VAL(B$)
    LINE INPUT "ENDING SALARY==> "; E$
    E = VAL(E$)
    LINE INPUT "PERCENT PAID INTO PENSION PLAN==> "; P$
    P = VAL(P$) / 100
    LINE INPUT "AVERAGE INTEREST PERCENTAGE EARNED==> "; R$
    R = VAL(R$) / 100
    LINE INPUT "RATE (%) OF INFLATION==> "; Q$
    Q = VAL(Q$) / 100
    PRINT : PRINT
    PRINT "SALARY        PAYMENT       FUND"
    D = INT((E - B) / N)
    G = 1 + (R - Q)
    Y(0) = B
    FOR I = 1 TO N
    Y(I) = Y(I - 1) + D
    W(I) = INT(Y(I) * P)
    T = T * G
    T = INT(T + W(I))
    PRINT Y(I), W(I), T
    NEXT I
    V = INT(T / G ^ N)
    PRINT : PRINT
    PRINT "PENSION FUND WILL BE $"; T; "IN CURRENT DOLLARS"
    PRINT "FOR WHICH PRESENT VALUE WOULD BE $"; V
    LINE INPUT Z$
    GOTO A
    :
D:  CLS : CLEAR
    PRINT : PRINT TAB(30); "TOTAL DERIVATIVE"
    PRINT : PRINT
    PRINT "Totally differentiate to solve two equations"
    PRINT "such as:  I(r,a) - S(Y,b) = 0"
    PRINT "          m(r)/P - L(r,Y) = 0"
    PRINT "for partials such as dY/da."
    PRINT : PRINT "First, take total derivatives such as"
    PRINT "@I/@r dr + @I/@a da - @S/@Y dY - @S/@b db = 0."
    PRINT : PRINT "Then, lay out matrix with dr and dY"
    PRINT "and use Cramer's Rule to solve for them."
    PRINT : PRINT "Finally, take dY with respect to da only."
    LINE INPUT Z$
    GOTO A
    :
E:  CLS : CLEAR
    PRINT : PRINT TAB(30); "INTEGRATION"
    PRINT : PRINT
    PRINT "FUNCTION TO BE INTEGRATED"
    PRINT "OF FORM Y = aX^2 + bX + c"
    PRINT
    LINE INPUT "a ==> "; A$
    A = VAL(A$)
    LINE INPUT "b ==> "; B$
    B = VAL(B$)
    LINE INPUT "c ==> "; C$
    C = VAL(C$)
    PRINT
    LINE INPUT "PLS ENTER NUMBER OF PARTITIONS==> "; N$
    N = VAL(N$)
    PRINT
    LINE INPUT "ENTER LOWER LIMIT==> "; L$
    L = VAL(L$)
    LINE INPUT "ENTER UPPER LIMIT==> "; U$
    U = VAL(U$)
    PRINT
    D = (U - L) / N
    X = L
    FOR I = 0 TO N
    M = 2
    IF I = 0 OR I = N THEN M = 1
    Y = A * X ^ 2 + B * X + C
    T = T + Y * M
    X = X + D
    NEXT I
    T = T / 2 * D
    PRINT "SUM ="; T
    PRINT
    LINE INPUT Z$
    GOTO A
    :
F:  CLS : CLEAR
    PRINT : PRINT TAB(25); "LAGRANGEAN MULTIPLIER"
    PRINT : PRINT : PRINT
    PRINT "Maximize y = f(x1, x2)"
    PRINT "but g(x1, x2) = 0."
    PRINT
    PRINT "L = f(x1, x2) + lamda g(x1, x2)"
    PRINT
    PRINT "@L/@x1 = f1 + lamda g1 = 0"
    PRINT "@L/@x2 = f2 + lamda g2 = 0"
    PRINT "@L/@lamda = g(x1, x2) = 0"
    PRINT
    PRINT "Solve for x1, x2 and lamda."
    PRINT : PRINT "Lamda is common benefit-cost ratio for all X's."
    PRINT : PRINT : PRINT TAB(50); "(Continued)"
    LINE INPUT Z$
    CLS
    PRINT : PRINT : PRINT "Maximize y = -x^2 + 2x - z^2 + 4z + 5"
    PRINT "but x + z = 1"
    PRINT "(1 - x - z = 0)."
    PRINT
    PRINT "L = -x^2 + 2s - z^2 + 4z + 5 + lamda(1 - x - z)"
    PRINT
    PRINT "@L/@x = -2x + 2 - lamda = 0"
    PRINT "@L/@z = -2z + 4 - lamda = 0"
    PRINT "@L/@lamda = 1 - x - z = 0"
    PRINT
    PRINT "-2 x + 0 z - 1 lamda = -2"
    PRINT " 0 x - 2 z - 1 lamda = -4"
    PRINT "-1 x - 1 z + 0 lamda = -1"
    PRINT
    PRINT "By Cramer's Rule:  x = 1, z = 0, lamda = 2."
    LINE INPUT Z$
    GOTO A
    :
    REM STATISTICS MODULE
G:  CLS : CLEAR
    PRINT TAB(30); "STATISTICS MENU"
    PRINT TAB(30); "==============="
    PRINT : PRINT
    PRINT "1) CHISQR INDEPENDENCE TEST"
    PRINT "2) 2-VARIABLE CORRELATION"
    PRINT "3) MULTIPLE REGRESSION"
    PRINT "4) STUDENT'S T-TEST"
    PRINT "5) OLS ANALYSIS PROBLEMS"
    PRINT
    INPUT "SELECT"; N
    IF N = 0 THEN GOTO A
    IF N > 5 THEN GOTO G
    ON N GOTO H, I, J, K, L
    :
H:  CLS : CLEAR
    PRINT : PRINT TAB(30); "CHI-SQUARE TEST"
    DIM I(30), M(30, 30), E(30, 30)
    PRINT : PRINT
    FOR J = 1 TO 30
    READ I(J)
    NEXT J
    LINE INPUT "ENTER NUMBER OF CATEGORIES ON DIMENSION X==> "; H$
    H = VAL(H$)
    LINE INPUT "ENTER NUMBER OF CATEGORIES ON DIMENSION Y==> "; V$
    V = VAL(V$)
    PRINT : PRINT
    PRINT "FOR THE FOLLOWING, PLS ENTER SAMPLE SUB-TOTALS:"
    FOR Y = 1 TO V
    FOR X = 1 TO H
    PRINT "X ="; X; "; Y ="; Y; "==>  ";
    LINE INPUT M$
    M(X, Y) = VAL(M$)
    M(H + 1, Y) = M(H + 1, Y) + M(X, Y)
    M(X, V + 1) = M(X, V + 1) + M(X, Y)
    NEXT X
    T = T + M(H + 1, Y)
    NEXT Y
    PRINT : PRINT
    FOR Y = 1 TO V
    FOR X = 1 TO H
    E(X, Y) = M(H + 1, Y) * M(X, V + 1) / T
    E = E + E(X, Y)
    W = (M(X, Y) - E(X, Y)) ^ 2 / E(X, Y)
    Q = Q + W
    NEXT X
    NEXT Y
    D = (H - 1) * (V - 1)
    IF Q <= I(D) THEN PRINT "INDEPENDENT" ELSE PRINT "NOT INDEPENDENT"
    DATA 3.84146,5.99147,7.81473,9.48773,11.0705
    DATA 12.5916,14.9671,15.5073,16.9190,18.3070
    DATA 19.6751,21.0261,22.3621,23.6848,24.9958
    DATA 26.2962,27.5871,28.8693,30.1435,31.4104
    DATA 32.6705,33.9244,35.1725,36.4151,37.6525
    DATA 38.8852,40.1133,41.3372,42.5569,43.7729
    LINE INPUT Z$
    GOTO A
    :
I:  CLS : CLEAR
    PRINT : PRINT TAB(30); "LINEAR REGRESSION"
    PRINT : PRINT
    DEFDBL A-Z
    DEFSNG I
    DIM M(60), X(50), Y(50), U(50)
    INPUT "NUMBER OF KNOWN POINTS (MUST BE 3 OR MORE)"; N
    PRINT
    FOR I = 1 TO N
    PRINT "X,Y OF POINT"; I;
    INPUT X, Y
    X(I) = X
    Y(I) = Y
    J = J + X
    K = K + Y
    L = L + X ^ 2
    M = M + Y ^ 2
    R2 = R2 + X * Y
    NEXT I
    PRINT
    FOR I = 1 TO 60
    READ M(I)
    NEXT I
    B = (N * R2 - K * J) / (N * L - J ^ 2)
    A = (K - B * J) / N
    PRINT "Y ="; CSNG(A); "+ ("; CSNG(B); "* X )"
    J = B * (R2 - J * K / N)
    M = M - K ^ 2 / N
    K = M - J
    PRINT
    R2 = J / M
    PRINT "COEFFICIENT OF DETERMINATION (R^2) ="; CSNG(R2)
    PRINT
    SE = M - J
    ME = SE / (N - 2)
    F = J / ME
    N = N + 30
    IF F <= M(N - 2) THEN
      PRINT "NOT SIGNIFICANT AT .05"
    ELSE
      PRINT "SIGNIFICANT AT .05"
    END IF
    PRINT
    PRINT "INTERPOLATION:  (ENTER 0 TO END PROGRAM)"
1 : INPUT "X = "; X
    IF X = 0 THEN GOTO A
    PRINT "Y ="; CSNG(A + B * X)
    PRINT : PRINT
    GOTO 1
    DATA 161.4,18.51,10.13,7.71,6.61,5.99
    DATA 5.59,5.32,5.12,4.96,4.84,4.75
    DATA 4.67,4.6,4.54,4.49,4.45,4.41
    DATA 4.38,4.35,4.32,4.3,4.28,4.26
    DATA 4.24,4.23,4.21,4.2,4.18,4.17
    :
J:  CLS : CLEAR
    PRINT : PRINT TAB(25); "MULTIPLE LINEAR REGRESSION"
    DEFDBL A-Z: DEFSNG I: DEFINT J-L
    PRINT : PRINT
    DIM S(30), T(91), A(30, 30)
    INPUT "NUMBER OF KNOWN POINTS"; N
    INPUT "NUMBER OF INDEPENDENT VARIABLES"; V
    PRINT
    X(1) = 1
    FOR I = 1 TO N
    PRINT "POINT"; I
    FOR J = 1 TO V
    PRINT "VARIABLE"; J;
    INPUT X(J + 1)
    NEXT J
    INPUT "  DEPENDENT VARIABLE"; X(V + 2)
    FOR K = 1 TO V + 1
    FOR L = 1 TO V + 2
    A(K, L) = A(K, L) + X(K) * X(L)
    S(K) = A(K, V + 2)
    NEXT L
    NEXT K
    S(V + 2) = S(V + 2) + X(V + 2) ^ 2
    NEXT I
    FOR I = 2 TO V + 1
    T(I) = A(1, I)
    NEXT I
    FOR I = 1 TO V + 1
    J = I
2 : IF A(J, I) <> 0 THEN GOTO 3
    J = J + 1
    IF J <= V + 1 THEN GOTO 2
    PRINT "NO UNIQUE SOLUTION"
    LINE INPUT Z$
    GOTO A
3 : FOR K = 1 TO V + 2
    B = A(I, K)
    A(I, K) = A(J, K)
    A(J, K) = B
    NEXT K
    Z = 1 / A(I, I)
    FOR K = 1 TO V + 2
    A(I, K) = Z * A(I, K)
    NEXT K
    FOR J = 1 TO V + 1
    IF J = I THEN GOTO 4
    Z = -A(J, I)
    FOR K = 1 TO V + 2
    A(J, K) = A(J, K) + Z * A(I, K)
    NEXT K
4 : NEXT J
    NEXT I
    PRINT
    PRINT "EQUATION COEFFICIENTS:"
    PRINT "  CONSTANT:"; CSNG(A(1, V + 2))
    FOR I = 2 TO V + 1
    PRINT "  VARIABLE("; I - 1; "):"; CSNG(A(I, V + 2))
    NEXT I
5 : PRINT
    PRINT "INTERPOLATION: (ENTER 0 TO END PROGRAM)"
    P = A(1, V + 2)
    FOR J = 1 TO V
    PRINT "VARIABLE"; CSNG(J);
    INPUT X
    IF X = 0 THEN GOTO A
    P = P + A(J + 1, V + 2) * X
    NEXT J
    PRINT "DEPENDENT VARIABLE ="; CSNG(P)
    GOTO 5
    :
K:  CLS : CLEAR
    PRINT : PRINT TAB(30); "STUDENT'S T-TEST"
    PRINT : PRINT
    PRINT "T-STAT(calculated) = COEFFICIENT / STD. ERROR"
    PRINT : PRINT "i) B = Sum(Xt - Xave)(Yt - Yave) / Sum(Xt - Xave)^2"
    PRINT "ii) Yt - Yest = Ut"
    PRINT "iii) S^2 = Sum(Ut^2) / (n - k)"
    PRINT "iv) Sb = Sqrt(S^2 / Sum(Xt - Xave)^2)."
    PRINT
    FOR I = 1 TO 91
    READ T(I)
    NEXT I
    INPUT "Sample size"; N
    INPUT "Number independent variables"; K
    I = N - K
    I = I + 60
    IF I > 91 THEN I = 91
    PRINT "T-STAT(critical) = "; T(I)
    PRINT
    PRINT "If T-STAT(calculated) > T-STAT(critical)"
    PRINT "then variable B is significant at .05."
    PRINT : PRINT
    PRINT "Confidence interval is B +- (Tcrit * Sb)."
    DATA 12.706,4.303,3.182,2.776,2.571
    DATA 2.447,2.365,2.306,2.262,2.228
    DATA 2.201,2.179,2.16,2.145,2.131
    DATA 2.12,2.11,2.101,2.093,2.086
    DATA 2.08,2.074,2.069,2.064,2.06
    DATA 2.056,2.052,2.048,2.045,2.042,1.96
    LINE INPUT Z$
    GOTO A
    :
L:  CLS : CLEAR
    PRINT : PRINT TAB(30); "ANALYSIS PROBLEMS"
    PRINT : PRINT : PRINT
    PRINT "     MULTICOLLINEARITY"
    PRINT "     AUTOCORRELATION"
    PRINT "     HETEROSCEDASTICITY"
    PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT
    PRINT TAB(50); "(Continued)"
    LINE INPUT Z$
    CLS
    PRINT : PRINT TAB(30); "Multicollinearity"
    PRINT : PRINT
    PRINT "DEFINITION - a linear relationship exists between"
    PRINT "             two or more independent variables"
    PRINT : PRINT "DETECTION"
    PRINT ".high correlation between any two independent variables"
    PRINT " or high R^2 regressing on an independent variable"
    PRINT ".high R^2 and F-statistic together with a low t-statistic"
    PRINT : PRINT
    PRINT "TREATMENT"
    PRINT ".ignore multicollinearity if t-values are significant"
    PRINT ".convert data into difference form, percentage form,"
    PRINT " per capita form, log form, dummy variables"
    PRINT : PRINT : PRINT TAB(50); "(Continued)"
    LINE INPUT Z$
    CLS
    PRINT : PRINT TAB(28); "Autocorrelation"
    PRINT : PRINT
    PRINT "DEFINITION - an interdependence exists among successive"
    PRINT "             values of the disturbance term"
    PRINT
    PRINT "DETECTION"
    PRINT ".Durbin-Watson statistic should be > d(u) and < (4 - d(u))"
    PRINT " with k' = k - 1, i.e. approximately 2.0"
    PRINT ".Durbin-h statistic should be approximately 2.0 in models"
    PRINT " with lagged dependent variable as an independent variable"
    PRINT : PRINT
    PRINT "TREATMENT"
    PRINT ".convert the data into a different form"
    PRINT ".respecify the model"
    PRINT : PRINT : PRINT TAB(50); "(Continued)"
    LINE INPUT Z$
    CLS
    PRINT : PRINT TAB(25); "Heteroscedasticity"
    PRINT : PRINT
    PRINT "DEFINITION - the disturbance terms have nonconstant variance"
    PRINT : PRINT
    PRINT "DETECTION"
    PRINT ".look for cone-like dispersion in residual plot"
    PRINT ".calculate F-statistic = SSR(top 40%) / SSR(bottom 40%)"
    PRINT " and compare with F(critical)"
    PRINT : PRINT
    PRINT "TREATMENT"
    PRINT ".convert the data into a different form"
    PRINT ".divide every term in the model by the scale factor."
    LINE INPUT Z$
    GOTO A
    :
    REM ECONOMICS MODULE
M:  CLS : CLEAR
    PRINT TAB(30); "ECONOMICS MENU"
    PRINT TAB(30); "=============="
    PRINT : PRINT
    PRINT "1) GRID"
    PRINT "2) ELASTICITY"
    PRINT "3) IS-LM MODEL"
    PRINT "4) INTERNATIONAL MACRO"
    PRINT "5) I-O DATA"
    PRINT : PRINT
    INPUT "SELECT"; N
    IF N = 0 THEN GOTO A
    IF N > 5 THEN GOTO M
    ON N GOTO N, O, P, Q, R
    :
N:  CLS : CLEAR
    SCREEN 11
    VIEW (100, 15)-(575, 300)
    WINDOW (0, 0)-(100, 100)
    FOR I = 1 TO 22
      LOCATE I, 12
      PRINT CHR$(219);
    NEXT I
    PRINT STRING$(55, 220)
    LINE (10, 10)-(90, 90)
    LINE (10, 90)-(90, 10)
    LOCATE 1, 5
    PRINT "Price";
    LOCATE 24, 60
    PRINT "Quantity";
    LINE (10, 85)-(43, 52)
    LINE (43, 52)-(10, 52)
    LINE (10, 52)-(10, 85)
    PAINT (11, 83)
    DO
    LOOP WHILE INKEY$ = ""
    SCREEN 0
    GOTO A
    :
O:  CLS : CLEAR
    PRINT : PRINT TAB(30); "ELASTICITY"
    PRINT : PRINT : PRINT
    PRINT "DEMAND FUNCTION TO BE EVALUATED"
    PRINT "OF FORM Q = y - xP"
    PRINT
    LINE INPUT "y ==> "; Y$
    Y = VAL(Y$)
    LINE INPUT "x ==> "; X$
    X = VAL(X$)
    PRINT
    LINE INPUT "PLS ENTER PRICE==> "; Z$
    PRINT : PRINT
    Z = VAL(Z$)
    P = Z - .01
6 : Q = Y - X * P
    IF F = 1 THEN GOTO 7
    X1 = Q
    Y1 = P
    F = 1
    P = Z + .01
    GOTO 6
7 : X2 = Q
    Y2 = P
    E = ((X2 - X1) / (Y2 - Y1)) * ((Y1 + Y2) / (X1 + X2))
    PRINT "PRICE ELASTICITY OF DEMAND = ";
    PRINT USING "##.##"; E
    PRINT
    LINE INPUT Z$
    GOTO A
    :
P:  CLS : CLEAR
    PRINT : PRINT TAB(30); "OPEN MODEL"
    PRINT : PRINT : PRINT
    PRINT "Y = C(r,Y,T) + I(r,Y,T) + G + x(e,Y*) - M(e,Y)"
    PRINT : PRINT : PRINT : PRINT "IS = IS(r,Y,G,T,P,P*,e,Y*)"
    PRINT : PRINT "LM = LM(r,Y,M,P)"
    PRINT
    LINE INPUT Z$
    GOTO A
    :
Q:  CLS : CLEAR
    PRINT TAB(25); "TRADE AND FINANCE"
    PRINT : PRINT : PRINT
    PRINT "     COMPARATIVE ADVANTAGE"
    PRINT : PRINT "     TRANSMISSION EFFECTS"
    PRINT : PRINT "     POLICY INDICATIONS"
    PRINT : PRINT : PRINT : PRINT : PRINT TAB(50); "(Continued)"
    LINE INPUT Z$
    CLS
    PRINT : PRINT TAB(25); "Comparative Advantage"
    PRINT : PRINT
    PRINT ".Kansas can produce either 6 units of wheat"
    PRINT " or 2 units of cloth."
    PRINT : PRINT ".Nebraska can only produce either 1 unit of wheat"
    PRINT " or 1 unit of cloth."
    PRINT : PRINT ".In Kansas the opportunity cost of wheat"
    PRINT " is 3 units of cloth,"
    PRINT " and of cloth is 1/3 units of wheat."
    PRINT : PRINT ".In Nebraska the opportunity cost of wheat"
    PRINT " is 1 unit of cloth,"
    PRINT " and of cloth is 1 unit of wheat."
    PRINT : PRINT ".Therefore, Kansas should produce only cloth,"
    PRINT " and Nebraska should produce only wheat."
    PRINT : PRINT TAB(50); "(Continued)"
    LINE INPUT Z$
    CLS
    PRINT : PRINT TAB(25); "Transmission Effects"
    PRINT : PRINT : PRINT
    PRINT "IS-LM/ Fiscal ==> IS same, LM same"
    PRINT : PRINT "IS-LM/ Monetary ==> IS opposite, LM same"
    PRINT : PRINT
    PRINT "AS-AD/ Fiscal ==> AS opposite, AD same"
    PRINT : PRINT "AS-AD/ Monetary ==> AS opposite, AD opposite"
    PRINT : PRINT : PRINT TAB(50); "(Continued)"
    LINE INPUT Z$
    CLS
    PRINT : PRINT TAB(25); "Policy Indications"
    PRINT : PRINT : PRINT
    PRINT "For country to be in trade balance..."
    PRINT
    PRINT : PRINT "DEFICIT + INFLATION ==> REDUCE ABSORPTION"
    PRINT : PRINT "DEFICIT + UNEMPLOYMENT ==> DEVALUE CURRENCY"
    PRINT : PRINT "SURPLUS + INFLATION ==> APPRECIATE CURRENCY"
    PRINT : PRINT "SURPLUS + UNEMPLOYMENT ==> INCREASE ABSORPTION."
    LINE INPUT Z$
    GOTO A
    :
R:  REM INPOUT
    CLEAR
    CLS
    OPEN "82-2DALL.FIL" FOR INPUT AS #1
    DIM S$(97)
    FOR K = 1 TO 91
      READ Z$
    NEXT K
    FOR J = 1 TO 22
      READ W$
      PRINT W$
    NEXT J
    LINE INPUT Z$
    CLS
    PRINT
    LINE INPUT "Enter Year's f/1982 (1992 = 1.924)==> "; F$
    F = VAL(F$)
    PRINT
    FOR I = 1 TO 97
      IF I = 21 OR I = 41 OR I = 61 OR I = 81 THEN
        LINE INPUT Z$
        CLS
        PRINT : PRINT
      END IF
      READ S$(I)
      FOR J = 1 TO LEN(S$(I))
        IF MID$(S$(I), J, 1) = ";" THEN
          S$(I) = LEFT$(S$(I), J - 1) + "," + MID$(S$(I), J + 1)
        END IF
      NEXT J
      FOR J = 1 TO 100
        FOR K = 1 TO 1000
        NEXT K
      NEXT J
      PRINT S$(I)
    NEXT I
    PRINT
11 : IF N = 1 THEN N = 0: CLS : PRINT : PRINT
    PRINT "Pls Enter 'Input' Target Key==> ";
12 : LINE INPUT T$
    IF T$ = "" THEN GOTO 11
    T$ = UCASE$(T$)
    PRINT
    FOR I = 1 TO 97
      A$ = S$(I)
      FOR J = 4 TO LEN(A$) - LEN(T$) + 1
        Y$ = UCASE$(MID$(A$, J, LEN(T$)))
        IF Y$ = T$ THEN
          FOR K = 1 TO LEN(A$)
            IF MID$(A$, K, 1) = ";" THEN
              A$ = LEFT$(A$, K - 1) + "," + MID$(A$, K + 1)
            END IF
          NEXT K
          IF B$ <> A$ THEN PRINT A$
          B$ = A$
        END IF
      NEXT J
    NEXT I
    IF N = 1 THEN GOTO 13
    N = 1
    B$ = ""
    PRINT
    PRINT "Enter 'Output' Target Key==> ";
    GOTO 12
13 : PRINT
    LINE INPUT "Select I-O Query of form '01 02'==> "; Q$
    IF Q$ = "" THEN GOTO A
    PRINT "*Working*"
    DO
      LINE INPUT #1, A$
      IF LEFT$(A$, 5) = Q$ THEN
        B$ = MID$(A$, 6, 15)
        G = VAL(B$)
        G = F * G
        G = INT(G)
        B$ = RIGHT$(STRING$(15, " ") + STR$(G), 17)
        A$ = LEFT$(A$, 5) + B$ + MID$(A$, 21)
        PRINT
        PRINT A$
        N = 0
        EXIT DO
      END IF
    LOOP UNTIL EOF(1)
    IF N = 0 THEN N = 1: GOTO 14
    PRINT
    PRINT "Coefficient is Zero"
14 : CLOSE
    OPEN "82-2DALL.FIL" FOR INPUT AS #1
    GOTO 13
    :
    DATA "                        Welcome to Inpout!"
    DATA
    DATA "When you run INPOUT, you will first see the following prompt:"
    DATA "Enter Year's f/1982 (1992 = 1.924)==>"
    DATA "'F' is a factor encompassing growth and inflation.  The base year"
    DATA "1982 was used as a benchmark by the U.S. Bureau of Labor Statistics."
    DATA "Then INPOUT will type..."
    DATA "97 Nondefense"
    DATA "98 Education"
    DATA "99 Other"
    DATA "Pls Enter 'Input' Target Key==>"
    DATA "At this and at, Enter 'Output' Target Key==> the user may enter any"
    DATA "string or part of string, e.g. 'edu' and get back '98 Education.'"
    DATA "Last, INPOUT will display,"
    DATA "Select I-O Query of form '01 02'==>"
    DATA "If you type anything up to some '99 99,' you would see:"
    DATA "*Working*"
    DATA "01 02      3030343000     .0165034"
    DATA "The first statistic, $3.030343 billion, is the amount of input"
    DATA "from Industry 1 to Commodity 2 (or Industry 2) in 1982 or 1992."
    DATA "The second statistic, .0165034, is the fraction of output"
    DATA "of Commodity 2 (or Industry 2) attributable to Industry 1."
    :
    REM  AGRICULTURE; FORESTRY; AND FISHERIES
    DATA 1  Livestock and livestock products
    DATA 2  Other agricultural products
    DATA 3  Forestry and fishery products
    DATA 4  Agricultural; forestry; and fishery services
    REM  MINING
    DATA 5  Iron and ferroalloy ores mining
    DATA 6  Nonferrous metal ores mining
    DATA 7  Coal mining
    DATA 8  Crude petroleum and natural gas
    DATA 9  Stone and clay mining and quarrying
    REM  CONSTRUCTION
    DATA 10 Chemical and fertilizer mineral mining
    DATA 11 New construction
    DATA 12 Maintenance and repair construction
    REM  MANUFACTURING
    DATA 13 Ordnance and accessories
    DATA 14 Food and kindred products
    DATA 15 Tobacco manufactures
    DATA 16 Broad and narrow fabrics; yarn and thread mills
    DATA 17 Miscellaneous textile goods and floor coverings
    DATA 18 Apparel
    DATA 19 Miscellaneous fabricated textile products
    DATA 20 Lumber and wood products; except containers
    DATA 21 Wood containers
    DATA 22 Household furniture
    DATA 23 Other furniture and fixtures
    DATA 24 Paper and allied products; except containers
    DATA 25 Paperboard containers and boxes
    DATA 26 Printing and publishing
    DATA 27 Chemicals and selected chemical products
    DATA 28 Plastics and synthetic materials
    DATA 29 Drugs; cleaning and toilet preparations
    DATA 30 Paints and allied products
    DATA 31 Petroleum refining and related products
    DATA 32 Rubber and miscellaneous plastics products
    DATA 33 Leather tanning and finishing
    DATA 34 Footwear and other leather products
    DATA 35 Glass and glass products
    DATA 36 Stone and clay products
    DATA 37 Primary iron and steel manufacturing
    DATA 38 Primary nonferrous metals manufacturing
    DATA 39 Metal containers
    DATA 40 Heating; plumbing; and fabricated structural metal products
    DATA 41 Screw machine products and stampings
    DATA 42 Other fabricated metal products
    DATA 43 Engines and turbines
    DATA 44 Farm and garden machinery
    DATA 45 Construction and mining machinery
    DATA 46 Materials handling machinery and equipment
    DATA 47 Metalworking machinery and equipment
    DATA 48 Special industry machinery and equipment
    DATA 49 General industrial machinery and equipment
    DATA 50 Miscellaneous machinery; except electrical
    DATA 51 Office; computing; and accounting machines
    DATA 52 Service industry machines
    DATA 53 Electric industrial equipment and apparatus
    DATA 54 Household appliances
    DATA 55 Electric lighting and wiring equipment
    DATA 56 Radio; TV; and communication equipment
    DATA 57 Electronic components and accessories
    DATA 58 Miscellaneous electrical machinery and supplies
    DATA 59 Motor vehicles and equipment
    DATA 60 Aircraft and parts
    DATA 61 Other transportation equipment
    DATA 62 Scientific and controlling instruments
    DATA 63 Optical; ophthalmic; and photographic equipment
    DATA 64 Miscellaneous manufacturing
    REM  TRANSPORTATION; COMMUNICATIONS; AND UTILITIES
    DATA 65 Transportation and warehousing
    DATA 66 Communications; except radio and TV
    DATA 67 Radio and TV broadcasting
    DATA 68 Electric; gas; water; and sanitary service
    REM  WHOLESALE AND RETAIL TRADE
    DATA 69 Wholesale and retail trade
    REM  FINANCE; INSURANCE; AND REAL ESTATE
    DATA 70 Finance and insurance
    DATA 71 Real estate and rental
    REM  SERVICES
    DATA 72 Hotels; personal and repair services (except autos)
    DATA 73 Business and professional services; except medical
    DATA 74 Eating and drinking places
    DATA 75 Automobile repair and services
    DATA 76 Amusements
    DATA 77 Health; educational; and social services and nonprofit organizations
    REM  GOVERNMENT ENTERPRISES
    DATA 78 Federal Government enterprises
    DATA 79 State and local government enterprises
    REM  SPECIAL INDUSTRIES
    DATA 80 Noncomparable imports
    DATA 81 Scrap; used and secondhand goods
    DATA 82 Government industry
    DATA 83 Rest of the world industry
    DATA 84 Household industry
    DATA 85 Inventory valuation adjustment
    REM  TOTAL INTERMEDIATE USE
    DATA 88 Compensation of employees
    DATA 89 Indirect business taxes
    DATA 90 Other value added (Property-type income)
    DATA 91 Personal consumption expenditures
    DATA 92 Gross private fixed investment
    DATA 93 Change in business inventories
    DATA 94 Exports
    DATA 95 Imports
    REM  FEDERAL GOVERNMENT PURCHASES
    DATA 96 National defense
    DATA 97 Nondefense
    REM  STATE AND LOCAL GOVERNMENT PURCHASES
    DATA 98 Education
    DATA 99 Other
    REM  GNP
    REM  TOTAL COMMODITY OUTPUT
    :
S:  CLS
    END

DEFSNG A-H, J-Z
SUB COEFFICIENTS
  OPEN "TEMP.DAT" FOR OUTPUT AS #1
  FOR I = 0 TO O - 1
    FOR J = 0 TO O - 1
      X(I) = X(I) + A(I, J)
    NEXT J
    X(I) = X(I) + D(I)
  NEXT I
  PRINT
  FOR I = 0 TO O - 1
    FOR J = 0 TO O - 1
      A(I, J) = A(I, J) / X(I)
      PRINT USING "####.##"; A(I, J);
      PRINT #1, A(I, J)
    NEXT J
  PRINT
  NEXT I
  PRINT
  CLOSE
END SUB

SUB CRAMERS
  DIM Y(O - 1)
  DETERMINANT C
  GOSUB 25
  FOR M = 0 TO O - 1
    FOR I = 0 TO O - 1
      FOR J = 0 TO O - 1
        IF J = M THEN A(I, J) = D(I)
      NEXT J
    NEXT I
    DETERMINANT Y(M)
    GOSUB 25
  NEXT M
  FOR T = 0 TO O - 1
    X(T) = Y(T) / C
    IF X(T) < 0 THEN
      PRINT
      PRINT "IMPOSSIBILITY"
      PRINT
      LINE INPUT Z$
      END
    END IF
    PRINT "INPUT"; T + 1; " = ";
    PRINT USING "####.##"; X(T)
  NEXT T
  PRINT
  LINE INPUT Z$
  EXIT SUB
25 : FOR I = 0 TO O - 1
    FOR J = 0 TO O - 1
      A(I, J) = B(I, J)
    NEXT J
  NEXT I
  RETURN
END SUB

SUB DETERMINANT (D)
  FOR K = 0 TO O - 2
    Z = K
    Y = ABS(A(K, K))
    FOR I = K + 1 TO O - 1
      IF ABS(A(I, K)) <= Y THEN GOTO 21
      Z = I
      Y = ABS(A(I, K))
21 : NEXT I
    IF Y > 10 ^ -7 THEN GOTO 22
    D = 0
    GOTO 24
22 : IF Z = K THEN GOTO 23
    FOR J = K TO O - 1
      T = A(K, J)
      A(K, J) = A(Z, J)
      A(Z, J) = -T
    NEXT J
23 : FOR I = K + 1 TO O - 1
      FOR J = K + 1 TO O - 1
        A(I, J) = A(I, J) - A(K, J) * A(I, K) / A(K, K)
      NEXT J
    NEXT I
  NEXT K
  D = 1
  FOR I = 0 TO O - 1
    D = D * A(I, I)
  NEXT I
24 : FOR J = 0 TO O - 1
    FOR K = 0 TO O - 1
      A(J, K) = B(J, K)
    NEXT K
  NEXT J
END SUB

SUB IDENTITYMINUS
  FOR I = 0 TO O - 1
    FOR J = 0 TO O - 1
      IF I = J THEN
        B(I, J) = 1
      ELSE
        B(I, J) = 0
      END IF
      A(I, J) = B(I, J) - A(I, J)
      B(I, J) = A(I, J)
    NEXT J
  NEXT I
END SUB

SUB MAKEMATRIX
  PRINT
  FOR I = 0 TO O - 1
    FOR J = 0 TO O - 1
      PRINT "HOW MUCH  X"; I + 1; " PRODUCTION TO  X"; J + 1; " PRODUCERS";
      INPUT A(I, J)
    NEXT J
    PRINT "HOW MUCH FINAL DEMAND FOR  X"; I + 1;
    INPUT D(I)
    PRINT
  NEXT I
END SUB

SUB PUTMATRIX
  OPEN "TEMP.DAT" FOR OUTPUT AS #1
  PRINT
  FOR I = 0 TO O - 1
    FOR J = 0 TO O - 1
      PRINT "ROW"; I + 1; "COLUMN"; J + 1;
      INPUT A(I, J)
      PRINT #1, A(I, J)
    NEXT J
    PRINT
  NEXT I
  FOR I = 0 TO O - 1
    PRINT "FINAL DEMAND FOR  X"; I + 1;
    INPUT D(I)
  NEXT I
  PRINT
  CLOSE
END SUB

SUB READATA
  OPEN "TEMP.DAT" FOR INPUT AS #1
  PRINT
  FOR I = 0 TO O - 1
    FOR J = 0 TO O - 1
      INPUT #1, A(I, J)
      X(I) = X(I) + A(I, J)
    NEXT J
    PRINT "HOW MUCH FINAL DEMAND FOR X"; I + 1;
    INPUT D(I)
    X(I) = X(I) + D(I)
  NEXT I
  PRINT
  CLOSE
END SUB

SUB TABLEHELP
  CLS
  PRINT : PRINT TAB(30); "INPUT-OUTPUT"
  PRINT : PRINT
  PRINT "Fundamental equation of I-O:  (I - A)x = d"
  PRINT
  PRINT "                  1  0  0"
  PRINT "Identity Matrix = 0  1  0"
  PRINT "                  0  0  1"
  PRINT : PRINT "                     a11  a12  a13"
  PRINT "Input coefficients = a21  a22  a23"
  PRINT "                     a31  a32  a33"
  PRINT
  PRINT "x1, x2, x3 = inputs of each intermediate good (j)"
  PRINT : PRINT "d1, d2, d3 = final demand or production targets"
  PRINT : PRINT "If d changes, then what will happen to x?"
  PRINT : PRINT : PRINT TAB(37); "(Continued)"
  LINE INPUT Z$
  CLS
  PRINT
  PRINT "ROW 1 OUTPUTS"
  PRINT
  PRINT
  PRINT "X11 + X12 + X13 + C1 + I1 + G1 + E1 = X1"
  PRINT
  PRINT
  PRINT "Purchasing Sectors: X11 + X12 + X13"
  PRINT
  PRINT "Local Final Demand: C1 + I1 + G1"
  PRINT "Households: C1"
  PRINT "Private Investment: I1"
  PRINT "Government: G1"
  PRINT
  PRINT "Exports: E1"
  PRINT
  PRINT "Total Gross Output: X1"
  PRINT
  PRINT
  PRINT
  PRINT
  PRINT TAB(37); "(Continued)"
  LINE INPUT Z$
  CLS
  PRINT "COLUMN 1 INPUTS"
  PRINT
  PRINT
  PRINT "X11 +"
  PRINT "X21 +"
  PRINT "X31 +"
  PRINT "L1 +"
  PRINT "V1 +"
  PRINT "M1 ="
  PRINT "X1"
  PRINT
  PRINT
  PRINT "Producing Sectors: X11 + X21 + X31"
  PRINT
  PRINT "Labor: L1"
  PRINT "Other Value Added: V1"
  PRINT
  PRINT "Imports: M1"
  PRINT
  PRINT "Total Gross Outlays: X1"
  PRINT
  PRINT
  PRINT "Xn1 + Xn2 + Xn3 + C + I + G + E = X1n + X2n + X3n + L + V + M = X."
  LINE INPUT Z$
END SUB