How to sample a SARIMA model with given parameters in R

385 views Asked by At

I have a time series in R called 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

I have decided that the best SARIMA fit is SARIMA(1, 0, 0)x(0, 1, 2)12. So I used (from astsa package) sarima(jj, 1, 0, 0, 0, 1, 2, 12) to fit the model. I get the following results:

    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

Now I would like to generate a new SARIMA(1, 0, 0)x(0, 1, 2)12 model, feed it the variance and parameters I just found, plus the first few values of my time series, then simulate say 500 values, in order to compare the simulated data to the real data in terms of mean, variance, skewness, etc. Is there a function in R to do this? Or am I going about things the wrong way? I thought about using Arima from the forecast package to create the model, then feeding it new starting values (say the first 24 values of my original time series data), then having it predict future values. But I am concerned this does not preserve my variance, and I want to do it as if I didn{t have all the data, just the 24 starting values and the parameters of the model. Thanks!

0

There are 0 answers