home *** CD-ROM | disk | FTP | other *** search
- !! Program Regdem
- INCLUDE 'stdhdr.for'
- REAL see, rsq, r
- INTEGER numiv, numobs
- LOGICAL errr
- REAL storedata(0:maxr, 0:maxc), sales(0:maxr)
- REAL eqncoef(0:maxc), coefsig(0:maxc), yest(0:maxr)
- REAL resid(0:maxr)
-
- !Begin mulreg example
-
- !setup independent variable matrix
-
- !income population
- storedata(0, 0) = 305.0
- storedata(0, 1) = 35.0
- storedata(1, 0) = 130.0
- storedata(1, 1) = 98.0
- storedata(2, 0) = 189.0
- storedata(2, 1) = 83.0
- storedata(3, 0) = 175.0
- storedata(3, 1) = 76.0
- storedata(4, 0) = 101.0
- storedata(4, 1) = 93.0
- storedata(5, 0) = 269.0
- storedata(5, 1) = 77.0
- storedata(6, 0) = 421.0
- storedata(6, 1) = 44.0
- storedata(7, 0) = 195.0
- storedata(7, 1) = 57.0
- storedata(8, 0) = 282.0
- storedata(8, 1) = 31.0
- storedata(9, 0) = 203.0
- storedata(9, 1) = 92.0
-
- !{setup dependent variable matrix}
-
- !{sales}
- sales(0) = 20.0
- sales(1) = 15.0
- sales(2) = 17.0
- sales(3) = 9.0
- sales(4) = 16.0
- sales(5) = 27.0
- sales(6) = 35.0
- sales(7) = 7.0
- sales(8) = 22.0
- sales(9) = 23.0
-
-
- numobs = 10
- numiv = 2
-
- CALL MultipleReg(storedata, sales, numiv, numobs,
- + eqncoef, yest, resid, see, coefsig, rsq, r, errr)
-
- CALL DisplayRegData(storedata, sales, numobs,
- + eqncoef, yest, resid, see, coefsig, rsq, r )
-
- END
-
- SUBROUTINE DisplayRegData(storedata, sales, numobs,
- + eqncoef, yest, resid, see, coefsig, rsq, r)
- INCLUDE 'STDHDR.FOR'
- REAL storedata(0:maxr,0:maxc),sales(0:maxr), eqncoef(0:maxc)
- REAL yest(0:maxr), resid(0:maxr), coefsig(0:maxc),see,r,rsq
- INTEGER numobs, i
- CHARACTER varstring(0: 3) * 10
- !setup string array with names of variables}
-
- varstring(0) = 'sales'
- varstring(1) = 'constant'
- varstring(2) = 'income'
- varstring(3) = 'population'
-
-
- PRINT 10, 'Multiple regression - store sales vs district',
- + 'income and population'
- 6 FORMAT (A35)
- PRINT 7, 'actual district district estimated'
- 7 FORMAT (12X,A45 )
- PRINT 10, 'index sales income population ',
- + ' sales residuals'
- PRINT 10, '===== ===== ====== ========== ',
- + ' ===== ========='
- 10 FORMAT (1X, A47, A24 )
- DO i = 0, numobs - 1
- PRINT 20, i, sales(i), storedata(i, 0), storedata(i, 1),
- + yest(i), resid(i)
- 20 FORMAT (2X, I2, 5(6X F7.2))
- END DO
- PRINT *, 'Estimated regression equation is: '
- PRINT 24, varstring(0),
- + ' (y) = variable x coefficient error '
- 24 FORMAT (1X, A5,A47)
- PRINT 25,' ======== =========== ====='
- 25 FORMAT (12X, A40)
- DO i = 0, 2
- PRINT 30, i, varstring(i), eqncoef(i), coefsig(i)
- 30 FORMAT (' x(',I2,') ', 2X, A10, 2( 10X F6.2))
- END DO
- PRINT 35, 'Correlation coef (r) = ', r
- PRINT 35, 'Coefficient of determination rsqr = ', rsq
- PRINT 35, 'Standard error of estimate (see) = ', see
- 35 FORMAT (A37, F8.4)
- READ(*,*)
-
- END !SUB DisplayReg Data
-