home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / MCAD254.ZIP / STAT / FORECAST.MCD < prev    next >
Encoding:
Text File  |  1988-11-26  |  3.2 KB  |  132 lines

  1. .MCD 20000 0
  2. .CMD PLOTFORMAT logs=0,0 subdivs=1,1 size=5,15 type=l
  3. .CMD FORMAT  rd=d ct=10 im=i et=3 zt=15 pr=3 mass length time charge
  4. .CMD SET ORIGIN 0
  5. .CMD SET TOL 0.001000
  6. .CMD MARGIN 0
  7. .CMD LINELENGTH 78
  8. .CMD SET PRNCOLWIDTH 8
  9. .CMD SET PRNPRECISION 4
  10. .TXT 0 39 1 39 
  11. a1,38,42,37
  12. Copyright (c) 1988 by MathSoft, Inc.
  13. .TXT 1 43 1 39 
  14. a1,38,78,37
  15. /EQUATIONS FOR EXPONENTIAL SMOOTHING
  16. .TXT 1 -63 1 39 
  17. a1,38,76,37
  18. FORECASTING BY EXPONENTIAL SMOOTHING
  19. .TXT 1 63 2 77 
  20. a2,76,78,117
  21. These equations generate a time series x with normally distributed random 
  22. shocks superimposed on a changing trend. 
  23. .TXT 1 -81 2 80 
  24. a2,79,77,149
  25. This application uses double exponential smoothing to forecast a time series. 
  26. The plot shows the series x, the smoothed series p, and the errors e.
  27. .EQN 2 81 1 12 
  28. i~1;30
  29. .EQN 0 21 1 12 
  30. ORIGIN~1
  31. .TXT 1 -102 1 46 
  32. a1,45,76,44
  33. Choose smoothing constants between 0 and 1:
  34. .EQN 0 48 1 8 
  35. α~.3
  36. .EQN 0 13 1 8 
  37. ß~.1
  38. .EQN 0 41 3 38 
  39. d[i~\(-2*ln(rnd(1)))*cos(2*π*rnd(1))
  40. .TXT 1 -21 1 19 
  41. a1,18,78,17
  42. normal deviates:
  43. .TXT 1 -81 1 16 
  44. a1,15,77,14
  45. Read in data:
  46. .EQN 0 18 1 20 
  47. x~READPRN(FDATA)
  48. .TXT 0 24 1 36 
  49. a1,35,35,34
  50. components of prediction s and b:
  51. .EQN 2 -43 11 41 
  52. 6&-2&x[i,p[i,e[i,0{1,1,10,28,l}@&1&i
  53. .EQN 0 43 2 36 
  54. s[n~α*x[n+(1-α)*(s[(n-1)+b[(n-1))
  55. .TXT 0 39 1 15 
  56. a1,14,78,13
  57. time series:
  58. .EQN 0 21 2 36 
  59. x[i~1+.1*i+sin(.1*i)+.5*d[i
  60. .EQN 3 -60 2 36 
  61. b[n~ß*(s[n-s[(n-1))+(1-ß)*b[(n-1)
  62. .TXT 0 39 2 77 
  63. a2,76,76,111
  64. The initial values for smoothing use the average value and the trend over 
  65. the first 5 elements of the series.
  66. .TXT 3 -39 1 33 
  67. a1,32,32,31
  68. forecast for one period ahead:
  69. .EQN 0 39 1 11 
  70. k~1;5
  71. .EQN 0 23 2 9 
  72. h[k~x[k
  73. .EQN 0 19 2 8 
  74. v[k~k
  75. .EQN 2 -75 2 17 
  76. p[(n+1)~s[n+b[n
  77. .EQN 1 33 2 17 
  78. b[1~slope(v,h)
  79. .EQN 0 23 2 21 
  80. s[1~mean(h)-2*b[1
  81. .TXT 2 -62 1 21 
  82. a1,20,76,19
  83. squared error sum:
  84. .EQN 0 23 1 9 
  85. E=?
  86. .TXT 1 -65 1 15 
  87. a1,14,76,13
  88. [Ctrl][PgDn]
  89. .TXT 0 80 1 15 
  90. a1,14,78,13
  91. [Ctrl][PgDn]
  92. .TXT 1 0 1 67 
  93. a1,66,78,65
  94. These equations iterate the smoothing simultaneously on a and b:
  95. .TXT 1 -79 5 75 
  96. a5,74,74,351
  97. The sum of the squared prediction errors is one possible measure of the 
  98. success of the prediction method.  You can test the effect of using 
  99. different smoothing constants by changing the values for α and ß and 
  100. recalculating s and E.  The plot of a tracking signal based on mean 
  101. absolute deviations is shown below, with control limits at +6 and -6.
  102. .EQN 1 79 1 19 
  103. n~2;length(x)
  104. .EQN 2 0 4 42 
  105. ({2,1}÷b[n÷s[n)~({2,1}÷α*ß*(x[n-(s[(n-1)+b[(n-1)))+b[(n-1)÷α*x[n+(1-α)*(s[(n-1)+b[(n-1)))
  106. .EQN 3 -64 7 40 
  107. 10&-10&T[j,6,-6{1,1,6,30,l}@&1&j
  108. .TXT 2 64 1 72 
  109. a1,71,78,70
  110. These equations define the squared error sum E and tracking signal T:
  111. .EQN 1 -66 1 3 
  112. 
  113. .EQN 1 66 2 9 
  114. p[1~s[1
  115. .EQN 0 16 2 18 
  116. p[n~s[(n-1)+b[(n-1)
  117. .EQN 0 24 1 11 
  118. e~x-p
  119. .EQN 2 -40 3 11 
  120. E~{55}(e^2){49}
  121. .TXT 3 -79 2 78 
  122. a2,77,76,119
  123. This application is based on material in the book Time Series Forecasting, 
  124. by Bowerman and O'Connell (Duxbury Press).
  125. .TXT 1 78 1 15 
  126. a1,14,78,13
  127. [Ctrl][PgDn]
  128. .EQN 2 1 1 19 
  129. j~1;length(x)
  130. .EQN 2 0 9 26 
  131. T[n~n*(j$(j≤n)*e[j)/(j$(j≤n)*|e[j)
  132.