제2장 인구 추정

인구추정을 (1) 등차급수법(arithmetical)에 의한 추정, (2) 등비급수법(geometric)에 의한 추정, (3) 회귀직선식(linear)에 의한 추정, (4) 지수곡선식(exponential)에 의한 추정, (5) 이론곡선(logistic)식에 의한 추정을 fortran으로 전산화한 내용을 소개하면 다음과 같다. C C **** REAL P0(100), PX(100), X(100), X2(100), PXX(100), LX(100), LX2(100), A PY1(100), PS(100), YL(100), XYL(100), XL0(100), XL02(100), A KY(100), LPX(100), LKY(100), LLY(100), MXY(100) REAL SPX, SX, SX2, SPXX, SLX, SLX2, SYL, SXYL, A SXLP, SXLP2, SLLY, SMXY, E, K,A,B CHARACTER*5 S1,S2,S3,S4,S5,AA,BB,TIN,TOTAL,C INTEGER I,N1,FY,TY,N,OY,SY,IFLAG CHARACTER PUSH C **** C **** 220 WRITE(*,221) 221 FORMAT('**** PROGRAMED BY PROFESSOR SUNG KI SUK ****') 200 WRITE(*,30) 30 FORMAT('**** POPULATION PROGRAM ****') OPEN(1,FILE='SUNG2.OUT',STATUS='NEW') C C WRITE(*,31) 31 FORMAT('*** INPUT EACH YEAR ****') C C WRITE(*,32) 32 FORMAT(' FROM YEAR ') C C READ(*,10) FY 10 FORMAT(I4) c C WRITE(*,33) 33 FORMAT(//,' TO YEAR ') READ(*,10) TY N0=TY-FY N=TY - FY+1 C C WRITE(*,34) 34 FORMAT(' INPUT K VALUE ') READ(*,20) K 20 FORMAT(F10.0) E=2.7182 DO 99 I = 1, 100, 1 I1=0 P0(I) = I1 PX(I) = I1 X(100) = I1 X2(100) = I1 PXX(100) = I1 LX(I) = I1 LX2(I) = I1 PY1(I) = 0.0 PS(I) = 0.0 YL(I) = 0.0 XYL(I) = 0 XL0(I) = 0 XL02(I) = 0 KY(I) = 0 LPX(I) = 0 LKY(I) = 0 LLY(I) = 0 MXY(I) = 0 SPX = 0 SX = 0 SX2 = 0 SPXX = 0 SLX = 0 SLX2 = 0 SXYL = 0 SXL0 = 0 SXL02 =0 SLLY = 0 SMXY = 0 99 CONTINUE C WRITE(*,*)' Key in OR File to input data ( K / F ? )' WRITE(*,*) WRITE(*,*) WRITE(*,*) WRITE(*,*) READ(*,721) PUSH 721 format(a1) IF ( PUSH.EQ.'K') THEN 950 DO 100 I = 1, N, 1 P0(I) = FY + I -1 WRITE(*,35) 35 FORMAT(' INPUT DATA') READ(*,60)PX(I) 60 FORMAT(F10.0) SPX = SPX + PX(I) X(I) = I - 1 SX = SX + X(I) X2(I) = X(I) * X(I) SX2 = SX2 + X2(I) PXX(I) = PX(I) * X(I) 100 SPXX = SPXX + PXX(I) C ELSE I=1 OPEN(2,FILE='sung2.dat',STATUS='OLD') 722 READ(2,720,END=730) PX(I) 720 FORMAT(F10.0) P0(I) = FY + I -1 SPX = SPX + PX(I) X(I) = I - 1 SX = SX + X(I) X2(I) = X(I) * X(I) SX2 = SX2 + X2(I) PXX(I) = PX(I) * X(I) SPXX = SPXX + PXX(I) I=I+1 GOTO 722 730 CLOSE(2) ENDIF DO 150 I=1,N-1,1 LX(I + 1) = ALOG10(X(I+1)) 150 SLX=SLX+LX(I+1) C DO 155 I=1,N-1,1 LX2(I + 1) = LX(I + 1) * LX(I + 1) 155 SLX2 = SLX2 + LX2(I + 1) c IFLAG=100 DO 156 I=1,N,1 156 PY1(I) = (PX(I) / PX(N)) * 100.0 c DO 157 I=1,N,1 157 PS(I + 1) =PY1(I+1)-PY1(1) DO 403 I=1,N-1,1 IF(PY1(I + 1).LE. PY1(1)) THEN IFLAG= -100 ELSE CONTINUE ENDIF 403 CONTINUE C IF(IFLAG.EQ.100) THEN DO 159 I=1,N-1,1 YL(I + 1) = ALOG10(PS(I+1)) 159 SYL=SYL+YL(I+1) ELSE CONTINUE ENDIF C DO 165 I=1,N,1 IF(IFLAG.EQ.100) THEN XYL(I+1)=LX(I + 1) * YL(I + 1) SXYL = SXYL + XYL(I+1) ELSE CONTINUE ENDIF c XL0(I) = X(I) * ALOG10(E) SXL0 = SXL0 + XL0(I) c XL02(I) = XL0(I) * XL0(I) SXL02 = SXL02 + XL02(I) c KY(I) = K - PX(I) c LPX(I) = ALOG10(PX(I)) c LKY(I) = ALOG10(KY(I)) c LLY(I) = LPX(I) - LKY(I) SLLY = SLLY + LLY(I) c c MXY(I) = XL0(I) * LLY(I) SMXY = SMXY + MXY(I) 165 CONTINUE WRITE(1,737) 737 FORMAT('YEAR',T8,'HUMAN(y)',T17,'x(n)',T24,'x*x',t32,'x*y', - t41,'X=LOG x',t53,'X*X',T59,'P0=y/yn',t67,'P1=Pn-P0',T76, - 'Y=LOGP1',T86,'X*Y',T91,'X0=XLOGE',T103,'X0*X0',T111,'P2=K-y', - T120,'P3=LOGy',t129,'P4=LOGP2',T140,'P5=P3-P4',T153,'X0*P5') C C DO 735 I=1,N 735 WRITE(1,733)P0(I),PX(I),X(I),X2(I),PXX(I),LX(I),LX2(I), - PY1(I) - ,PS(I),YL(I),XYL(I),XL0(I),XL02(I),KY(I),LPX(I),LKY(I),LLY(I), - MXY(I) 733 FORMAT(f5.0,T6,f10.0,T17,f4.0,T23,f4.0,T29,f9.0,T40,F7.5, - T49,F8.5,T58,F7.2,T67,F5.2,T73,F8.5,T82,F8.5,T91,F8.5,T100, - f9.5,T110,F8.0,T119,F8.5,T128,F9.5,T138,F10.5,T149,F10.5) WRITE(1,740)SPX,SX,SX2,SPXX,SLX,SLX2,SYL,SXYL,SXL0,SXL02,SLLY, - SMXY 740 FORMAT('TOTAL',T6,f10.0,T17,f4.0,T22,f5.0,T28,f10.0,T39,F8.5, - T49,F8.5,T73,F8.5,T82,F8.5,T91,F8.5,T100, - f9.5,T138,F10.5,T149,F10.5) c c 110 WRITE(*,36) 36 FORMAT(/,' 1 = ARITHMETICAL',/,' 2 = GEOMETRICAL ', A /,' 3 = LINEAR ',/,' 4 = EXPONENTIAL',/,' 5 = LOGISTIC ', A //,' SELECT FROM 1 TO 5 ',/) C READ(*,10) SY WRITE(*,37) 37 FORMAT(//,' OBJECT YEAR ',//) READ(*,10) OY N1 = OY - FY c c IF(SY .EQ. 1) GOTO 101 IF(SY .EQ. 2) GOTO 201 IF(SY .EQ. 3) GOTO 301 IF(SY .EQ. 4) GOTO 401 IF(SY .EQ. 5) GOTO 501 c c WRITE(*,38) 38 FORMAT(//,' SELECT ERROR ',/,' AGAIN(Y/N) ',/) READ(*,280)AA IF(AA .EQ. 'Y') GOTO 110 WRITE(*,39) 39 FORMAT(/,' TO INPUT DATA? (Y/N) ',/) READ(*,280)TIN IF(TIN .EQ. 'Y') GOTO 200 GOTO 800 c c 101 WRITE(*,41) 41 FORMAT(/,' PN = P0 + N * Q',/) 51 WRITE(*,42) 42 FORMAT(' START?(Y/N) ',/) READ(*,280)S1 IF(S1 .NE. 'Y') GOTO 51 c c Q = (PX(N) - PX(1)) / X(N) PX(N1) = PX(1) + (N1 * Q) c c 900 IPPX=PX(N1) IF(IPPX.LT.PX(N1)) THEN IPPX=IPPX+1 ENDIF IYY1=OY WRITE(*,88) IYY1, IPPX 88 FORMAT(//,5X,I6, ' YEAR POPULATION = ',I8) IF(SY .EQ. 1) THEN WRITE(1,743) IYY1, IPPX 743 FORMAT(//,5X, '1.',2X,I6,2X,'YEAR POPULATION(ARITHMETICAL) = ',I8) ELSE IF(SY .EQ. 2) THEN WRITE(1,744) IYY1, IPPX 744 FORMAT(//,5X, '2.',2X,I6,2X,'YEAR POPULATION(GEOMETRICAL) = ',I8) ELSE IF(SY .EQ. 3) THEN WRITE(1,745) IYY1, IPPX 745 FORMAT(//,5X, '3.',2X,I6,2X,'YEAR POPULATION(LINEAR) = ',I8) ELSE IF(SY .EQ. 4) THEN WRITE(1,746) IYY1, IPPX 746 FORMAT(//,5X, '4.',2X,I6,2X,'YEAR POPULATION(EXPONENTIAL) = ',I8) ELSE WRITE(1,747) IYY1, IPPX 747 FORMAT(//,5X, '5.',2X,I6,2X,'YEAR POPULATION(LOGISTIC) = ',I8) ENDIF ENDIF ENDIF ENDIF WRITE(*,44) 44 FORMAT(//, ' AGAIN OR STOP?(A/S) ',/) READ(*,280)BB IF(BB .EQ. 'S') GOTO 600 GOTO 110 c c 201 WRITE(*,45) 45 FORMAT(/, ' PN = P0 * (1 + R) **N ',/) 250 WRITE(*,46) 46 FORMAT(/, ' START?(Y/N) ',/) READ(*,280)C IF (C .EQ. 'N') GOTO 250 c c R = ((PX(N) / PX(1)) ** (1.0 / X(N))) - 1 PX(N1) = PX(1) * ((1 + R) **N1) GOTO 900 c c 301 WRITE(*,47) 47 FORMAT(/,' Y = A * X + B ',/) 350 WRITE(*,48) 48 FORMAT(' START?(Y/N) ',/) READ(*,280)S3 280 FORMAT(A1) IF(S3 .EQ. 'N') GOTO 350 A = ((N * SPXX) - (SX * SPX)) / ((N * SX2) - (SX * SX)) B = ((SX2 * SPX) - (SX * SPXX)) / ((N* SX2) - (SX * SX)) PX(N1) = (A * N1) + B GOTO 900 c c 401 IF(IFLAG.EQ.-100) THEN WRITE(*,402) 402 FORMAT(/,5X,'*** YOU CAN NOT USE THIS METHODS ***',/) GOTO 110 ELSE CONTINUE ENDIF WRITE(*,49) 49 FORMAT(/,'PN = P0 + A * N**a ',/) 450 WRITE(*,61) 61 FORMAT(' START?(Y/N) ',/) C READ(*,280)S4 IF(S4 .EQ. 'N') GOTO 450 A1 = ((N0 * SXYL) - (SLX * SYL)) / ((N0 * SLX2) - (SLX * SLX)) B1 = ((SLX2 * SYL) - (SLX * SXYL)) / ((N0 * SLX2) - (SLX * SLX)) A = 10 ** B1 PXA1 = (PY1(1) + A * (N1 **A1)) / 100 PX(N1) = PX(N) * PXA1 GOTO 900 c c 501 WRITE(*,62) 62 FORMAT(/,' PN = K /(1 + ESP(A - (B * N))') 550 WRITE(*,63) 63 FORMAT(/, ' START ?(Y/N) ') READ(*,280)S5 IF(S5 .EQ. 'N') GOTO 550 A = (1.0 / ALOG10(E)) * (((SXL0 * SMXY) - * (SXL02 * SLLY)) / ((N * SXL02) -(SXL0 * SXL0))) B = ((N * SMXY) - (SXL0 * SLLY)) / ((N * SXL02) - (SXL0 * SXL0)) PX(N1) = K / (1 + E**(A - (B *N1))) GOTO 900 C 600 CONTINUE 800 WRITE(1,811) 811 FORMAT(//,5X,'***** THIS PROGRAM IS PROGRAMED' * ' BY PROF. SUNG GI SUK *****') CLOSE(1) STOP END 상기의 프로그램을 fortran program에서 실행파일을 만든후 다음의 예제를 가지고 실행해 보기로 한다. (예제) 1988년부터 1995년까지 인구의 통계자료가 각각 55000명, 60000명, 64500명, 71100명, 77800명, 84800명, 92000명, 98900명 일 때 2000년의 인구를 상기의 5가지 방법에 의하여 추정하시오.(단, 포화인구 K=200000으로 한다.) 자료를 입력할 때 다음을 유의하기 바랍니다. 1. Caps Lock(대문자) 상태에서 입력한다. 2. Key OR File to input data(K/F?)에서 K를 선택하고 Key board에서 자료를 일일이 입력하며,다음과 같이 실행한다. 3. K값과 INPUT DATA값은 반드시 .(소숫점)을 빠뜨리지 말것 4. 임의의 인구자료치 중에서 첫 년도의 인구자료치보다 감소하는 경우가 있을 때는 (4)의 지수곡선식에 의한 방법으로는 구할 수가 없고 (1), (2), (3), (5)의 4가지 방법만으로 구할 수 있는 점 유의하기 바랍니다. 이 때는 (4)의 지수곡선에 의한 방법을 선택 하면 "YOU CAN NOT USE THID METHOD"라고 표시된다. C:\FORTRAN>SUNG2 *** PROGRAMED BY PROFESSOR SUNG KI SUK *** *** POPULATION PROGRAM *** ** INPUT EACH YEAR ** FROM YEAR 1988 TO YEAR 1995 INPUT K VALUE 200000. Key in OR File to input data ( K/F? ) K INPUT DATA 55000. INPUT DATA 60000. INPUT DATA 64500. INPUT DATA 71100. INPUT DATA 77800. INPUT DATA 84800. INPUT DATA 92000. INPUT DATA 98900. 1 = ARITHMETICAL 2 = GEOMETRICAL 3 = LINEAR 4 = EXPONENTIAL 5 = LOGISTIC SELECT FROM 1 TO 5 1 OBJECT YEAR 2000 PN = P0 + N * Q START?(Y/N) Y 2000 YEAR POPULATION = 130257 AGAIN OR STOP?(A/S) A 1 = ARITHMETICAL 2 = GEOMETRICAL 3 = LINEAR 4 = EXPONENTIAL 5 = LOGISTIC SELECT FROM 1 TO 5 2 OBJECT YEAR 2000 PN = P0 * (1 + R) **N START?(Y/N) Y 2000 YEAR POPULATION = 150390 AGAIN OR STOP?(A/S) A 1 = ARITHMETICAL 2 = GEOMETRICAL 3 = LINEAR 4 = EXPONENTIAL 5 = LOGISTIC SELECT FROM 1 TO 5 3 OBJECT YEAR 2000 Y = A * X + B START?(Y/N) Y 2000 YEAR POPULATION = 129639 AGAIN OR STOP?(A/S) A 1 = ARITHMETICAL 2 = GEOMETRICAL 3 = LINEAR 4 = EXPONENTIAL 5 = LOGISTIC SELECT FROM 1 TO 5 4 OBJECT YEAR 2000 N = P0 + A * N**a START?(Y/N) Y 2000 YEAR POPULATION = 134913 AGAIN OR STOP?(A/S) A 1 = ARITHMETICAL 2 = GEOMETRICAL 3 = LINEAR 4 = EXPONENTIAL 5 = LOGISTIC SELECT FROM 1 TO 5 5 OBJECT YEAR 2000 pN = k/(1 + esp(A - (B * N)) START?(Y/N) Y 2000 YEAR POPULATION = 131569 AGAIN OR STOP?(A/S) s Stop - Program terminated. 한편 Key in OR File to input data(K/F?)에서 F로 하여 파일을 이용하고자 할 때에는 먼저 다음과 같이 fortran program 에서 자료를 입력하고 file명을 sung2.dat로 저장하고 실행방법은 K로 했을 때와 같다. 55000.0 60000.0 64500.0 71100.0 77800.0 84800.0 92000.0 98900.0 계산 결과는 다음과 같다. c:\FORTRAN>type sung2.out>prn YEAR HUMAN(y) x(n) x*x x*y X=LOG x X*X P0=y/yn P1=Pn-P0 Y=LOGP1 X*Y X0=XLOGE X0*X0 P2=K-y P3=LOGy P4=LOGP2 P5=P3-P4 X0*P5 1988. 55000. 0. 0. 0. .00000 .00000 55.61 .00 .00000 .00000 .00000 .00000 145000. 4.74036 5.16137 -.42101 .00000 1989. 60000. 1. 1. 60000. .00000 .00000 60.67 5.06 .70377 .00000 .43428 .18860 140000. 4.77815 5.14613 -.36798 -.15981 1990. 64500. 2. 4. 129000. .30103 .09062 65.22 9.61 .98253 .29577 .86856 .75440 135500. 4.80956 5.13194 -.32238 -.28001 1991. 71100. 3. 9. 213300. .47712 .22764 71.89 16.28 1.21163 .57809 1.30284 1.69740 128900. 4.85187 5.11025 -.25838 -.33663 1992. 77800. 4. 16. 311200. .60206 .36248 78.67 23.05 1.36274 .82045 1.73713 3.01761 122200. 4.89098 5.08707 -.19609 -.34064 1993. 84800. 5. 25. 424000. .69897 .48856 85.74 30.13 1.47902 1.03379 2.17141 4.71501 115200. 4.92840 5.06145 -.13306 -.28892 1994. 92000. 6. 36. 552000. .77815 .60552 93.02 37.41 1.57301 1.22404 2.60569 6.78961 108000. 4.96379 5.03342 -.06964 -.18145 1995. 98900. 7. 49. 692300. .84510 .71419 100.00 44.39 1.64727 1.39210 3.03997 9.24142 101100. 4.99520 5.00475 -.00955 -.02905 TOTAL 604100. 28. 140. 2381800. 3.70243 2.48901 8.95996 5.34424 12.15988 26.40405 -1.77808 -1.61650 1. 2000 YEAR POPULATION(ARITHMETICAL) = 130257 2. 2000 YEAR POPULATION(GEOMETRICAL) = 150390 3. 2000 YEAR POPULATION(LINEAR) = 129639 4. 2000 YEAR POPULATION(EXPONENTIAL) = 134913 5. 2000 YEAR POPULATION(LOGISTIC) = 131569 ***** THIS PROGRAM IS PROGRAMED BY PROF. SUNG KI SUK *****