如何使用R中的给定参数对SARIMA模型进行采样

时间:2015-06-26 17:53:24

标签: r time-series sampling forecasting

我在R中有一个名为jj的时间序列。

    > jj
     Jan       Feb       Mar       Apr       May       Jun       Jul
  1  2.5625072 2.6864995 2.7760495 2.6864995 2.6176149 2.8472302 2.8889086
  2  2.4733998 2.5853644 2.3614352 2.5548286 2.2392920 2.2698278 2.3614352
  3  2.5833333 1.9444444 2.0092593 2.2222222 2.2222222 2.0092593 2.5446500
  4  2.0092593 1.6666667 1.4351852 2.2222222 2.5000000 2.2962963 2.6260788
  5  2.8703704 2.2222222 1.7222222 1.6666667 1.6666667 1.7222222 2.2222222
  6  2.5259259 1.8333333 1.8944444 1.5277778 2.7500000 2.8897045 2.8703652
  7  2.8703704 1.9444444 2.0092593 1.9444444 1.9444444 2.5833333 2.7288827
  8  2.0092593 1.3888889 1.1481481 1.1111111 1.1111111 1.1481481 2.2222222
  9  1.3777778 1.1111111 0.9185185 0.8888889 1.1111111 1.3777778 0.6666667
  10 1.1481481 1.1111111 1.4351852 1.1111111 1.3888889 1.1481481 1.3888889
  11 1.7222222 1.3888889 1.1481481 1.3888889 1.3888889 1.4351852 2.2222222
  12 2.0092593 1.1111111 0.8611111 1.3888889 1.3888889 1.7222222 2.8286329
  13 1.7222222 2.9517940 2.9416154 2.6666667 2.9517940 2.9517940 2.9416154
  14 2.9517940 2.7777778 2.2962963 2.5000000 1.9444444 1.7222222 2.2222222
  15 2.2962963 1.9444444 2.0092593 2.2222222 1.9444444 2.2962963 2.9426333
  16 2.5833333 1.9444444 1.7222222 1.9444444 1.9444444 2.0092593 2.5000000
  17 1.7222222 1.3888889 1.4351852 1.3888889 1.1111111 1.1481481 1.9444444
  18 1.7222222 1.6666667 1.7222222 2.7777778 2.7777778 2.6861325 2.7604363
  19 2.5833333 1.9444444 1.7222222 2.8286329 2.5000000 2.5833333 2.9253296
  20 2.8703704 2.5000000 1.7222222 1.6666667 2.2222222 2.2962963 2.7237934
  21 2.9277778 2.8968296 2.9517940 2.9517940 2.7777778 2.9314368 2.9416154
  22 2.5833333 1.6666667 2.0092593 1.6666667 1.6666667 2.0092593 2.9049724
  23 2.0092593 1.3888889 2.8703652 2.7807935 2.7064897 2.9039546 2.9273654
  24 2.8703704 1.6666667 2.2962963 2.2222222 2.5000000 2.2962963 2.9517940
  25 2.5833333 1.3888889 2.0092593 2.2222222 1.9444444 2.5833333 2.8388115
  26 2.8703704 1.3888889 2.0092593 1.6666667 1.6666667 2.0092593 2.9517940
  27 2.2962963 1.3888889 2.6861325 1.9444444 1.9444444 2.5833333 2.9517940
  28 2.8703704 1.3888889 2.0092593 2.8286329 2.9202403 2.9517940 2.9517940
  29 2.8703704 1.6666667 1.7222222 1.3888889 1.6666667 1.4351852 2.9517940
  30 1.4351852 1.1111111 0.8611111 1.1111111 1.1111111 1.4351852 2.9517940
  31 1.4351852 1.1111111 0.8611111 1.1111111 1.3888889 1.4351852 2.7777778
  32 1.4351852 1.3888889 0.8611111 2.2222222 2.2222222 2.5833333 2.8479723
  33 2.2962963 1.3888889 2.0092593 2.5000000 2.2222222 2.8703704 2.8347401
  34 2.1513000 2.4921000 2.5453500 2.5027500 2.5347000 2.1300000 2.2684500
  35 1.7892000 2.3430000 2.3749500 2.2258500 2.5134000 1.8744000 2.1726000
  36 1.4590500 2.4921000 2.4814500 2.1619500 1.8424500 2.0341500 1.7253000
  37 1.8424500 1.5549000 1.0330500 0.9904500 0.9265500 0.5751000 0.7668000
  38 0.7348500 0.9904500 2.3749500 2.3004000 2.8222500 2.8648500 2.9500500
  39 2.3536500 2.1513000 2.2684500 1.5229500 0.8946000 0.7774500 1.1715000
  40 0.7029000 1.1608500 0.8839500 0.7881000 0.9478500 2.0448000 1.9276500
  41 1.0330500 1.6507500 2.0235000 2.6092500 2.4388500 2.5666500 2.8861500
  42 1.7679000 2.1300000 2.0661000 2.1832500 2.4175500 2.4388500 2.8435500
  43 1.3845000 2.0661000 2.8861500 2.9517940 2.6518500 2.5453500 2.7370500
  44 2.0874000 2.1087000 2.0661000 2.7051000 1.8531000 1.2673500 2.1619500
  45 1.7276389 2.1373656 1.9451389 1.9963710 1.9757930 1.6044444 1.3500000
  46 0.9780556 1.9094086 2.4434722 2.4868280 2.3836022 2.6620833 2.6272849
  47 2.2038889 2.3560484 2.1755556 2.1993280 1.9193548 2.2468056 2.5161290
  48 1.6276389 1.8481183 2.0204167 2.2172043 1.9631720 1.4890278 1.6551075
  49 0.9380556 1.2758065 2.3233333 2.4397849 2.4451613 2.4405556 2.5103495
  50 1.4444444 2.2043011 1.9166667 1.9086022 1.9489247 2.1111111 1.8682796
  51 2.0139072 2.2568109 2.4786743 1.9108121 2.2756334 1.4880000 1.6814920
     Aug       Sep       Oct       Nov       Dec
  1  2.8828206 2.9262278 2.9162662 2.9030509 2.7553841
  2  2.6973290 2.9262278 2.9162662 2.9030509 2.7553841
  3  2.2962963 2.9517940 2.9517940 2.9517940 2.7777778
  4  2.8416667 2.9517940 2.9517940 2.9517940 2.8703652
  5  2.8129630 2.9517940 2.9517940 2.9517940 2.7777778
  6  2.8642580 2.9517940 2.9517940 2.9517940 2.8622223
  7  2.8713831 2.9517940 2.9517940 2.9517940 2.7777778
  8  2.2962963 2.9517940 2.9517940 2.9517940 1.9444444
  9  1.3777778 1.3333333 2.0000000 1.9682540 1.5555556
  10 2.9436511 2.9517940 2.9517940 2.9517940 2.5000000
  11 2.9182046 2.9517940 2.7777778 2.7678571 1.6666667
  12 2.8754545 2.9517940 2.9517940 2.9517940 1.9444444
  13 2.9314368 2.9517940 2.9517940 2.9009010 2.8296508
  14 2.7879185 2.9517940 2.9517940 2.9517940 2.8286329
  15 2.9416154 2.9517940 2.9517940 2.9517940 2.9120975
  16 2.9039546 2.9517940 2.9517940 2.9216270 2.2222222
  17 2.9517940 2.9517940 2.9517940 2.9517940 2.2222222
  18 2.8703704 2.9517940 2.9517940 2.9517940 2.9314368
  19 2.9517940 2.9517940 2.9517940 2.9517940 2.9517940
  20 2.9416154 2.9517940 2.9517940 2.9517940 2.9517940
  21 2.9517940 2.9517940 2.9517940 2.9517940 2.9517940
  22 2.9517940 2.9517940 2.9517940 2.9517940 2.7777778
  23 2.9517940 2.9517940 2.9517940 2.9517940 2.9517940
  24 2.9517940 2.9517940 2.9517940 2.9517940 2.9517940
  25 2.9467047 2.9517940 2.9517940 2.9517940 2.9131153
  26 2.9517940 2.9517940 2.9517940 2.9517940 2.9517940
  27 2.9517940 2.9517940 2.9517940 2.9517940 2.9517940
  28 2.9517940 2.9517940 2.9517940 2.9517940 2.9517940
  29 2.9517940 2.9517940 2.9517940 2.9517940 2.5000000
  30 2.9517940 2.9517940 2.9517940 2.9517940 2.5000000
  31 2.9517940 2.9517940 2.9517940 2.9517940 2.5000000
  32 2.9517940 2.9517940 2.9517940 2.9517940 2.7838471
  33 2.9517940 2.9517940 2.9500500 2.9500500 2.6518500
  34 2.8755000 2.9500500 2.9500500 2.7690000 2.2791000
  35 2.8009500 2.9500500 2.9500500 2.7477000 2.0022000
  36 2.9181000 2.9500500 2.4814500 2.0874000 1.7146500
  37 0.9372000 1.1608500 1.6827000 1.4590500 1.0543500
  38 2.8968000 2.8542000 2.8755000 2.8861500 2.5773000
  39 1.6294500 2.1406500 2.1406500 1.9170000 1.2034500
  40 2.7157500 2.9074500 2.9517940 2.0874000 1.1928000
  41 2.7903000 2.9074500 2.9074500 2.9074500 2.7370500
  42 2.9517940 2.9517940 2.9517940 2.9517940 2.3110500
  43 2.9517940 2.9517940 2.9517940 2.9517940 2.9517940
  44 2.9517940 2.9517940 2.9517940 2.7690000 1.8105000
  45 1.9430556 2.5471774 2.4963710 1.8916667 1.4965054
  46 2.6363889 2.6645161 2.6932796 2.6964286 2.6544355
  47 2.6268056 2.6650403 2.5970430 2.5544643 2.1424731
  48 2.2509722 2.2399194 2.2094086 1.8453869 1.3264785
  49 2.6687500 2.8084677 2.8376344 2.7081845 1.9912634
  50 2.4583333 2.8360215 2.8763441 2.6636905 2.0833333
  51 2.0464437 2.0434435 1.8343226 1.7039880 1.3593448

我已经确定最好的SARIMA适合SARIMA(1,0,0)x(0,1,2)12。所以我使用(来自astsa包)sarima(jj,1,0,0,0,1,2,12)来拟合模型。我得到以下结果:

    Coefficients:
             ar1     sma1     sma2  constant
          0.7456  -0.7469  -0.1032    -6e-04
    s.e.  0.0272   0.0405   0.0429     8e-04

    sigma^2 estimated as 0.1201:  log likelihood = -223.17,  aic = 456.33

    $AIC
    [1] -1.106286

    $AICc
    [1] -1.102856

    $BIC
    [1] -2.077418

现在我想生成一个新的SARIMA(1,0,0)x(0,1,2)12模型,给我刚刚找到的方差和参数,加上我的时间序列的前几个值,然后模拟500个值,以便在平均值,方差,偏度等方面将模拟数据与实际数据进行比较.R中是否有一个函数可以做到这一点?或者我是以错误的方式处理事情的?我考虑过使用预测包中的Arima来创建模型,然后为它提供新的起始值(比如我原始时间序列数据的前24个值),然后让它预测未来值。但我担心这不会保留我的方差,我想这样做,好像我没有所有的数据,只有24个起始值和模型的参数。谢谢!

0 个答案:

没有答案