Resources

Time Series Documentation Examples

 /****************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                 */
 /*                                                              */
 /*    NAME: TIMSEX                                              */
 /*   TITLE: Time Series Documentation Examples                  */
 /* PRODUCT: IML                                                 */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS:                                                     */
 /*   PROCS:                                                     */
 /*    DATA:                                                     */
 /*                                                              */
 /* SUPPORT: GJW                         UPDATE: APRIL 1996      */
 /*     REF:                                                     */
 /*    MISC:                                                     */
 /****************************************************************/
title 'Time Series Subroutine Documentation';
title2 'Minimum AIC Model Selection';
proc iml;
   y = { 2.430 2.506 2.767 2.940 3.169 3.450 3.594 3.774 3.695 3.411
         2.718 1.991 2.265 2.446 2.612 3.359 3.429 3.533 3.261 2.612
         2.179 1.653 1.832 2.328 2.737 3.014 3.328 3.404 2.981 2.557
         2.576 2.352 2.556 2.864 3.214 3.435 3.458 3.326 2.835 2.476
         2.373 2.389 2.742 3.210 3.520 3.828 3.628 2.837 2.406 2.675
         2.554 2.894 3.202 3.224 3.352 3.154 2.878 2.476 2.303 2.360
         2.671 2.867 3.310 3.449 3.646 3.400 2.590 1.863 1.581 1.690
         1.771 2.274 2.576 3.111 3.605 3.543 2.769 2.021 2.185 2.588
         2.880 3.115 3.540 3.845 3.800 3.579 3.264 2.538 2.582 2.907
         3.142 3.433 3.580 3.490 3.475 3.579 2.829 1.909 1.903 2.033
         2.360 2.601 3.054 3.386 3.553 3.468 3.187 2.723 2.686 2.821
         3.000 3.201 3.424 3.531 };
   call tsunimar(arcoef,ev,nar,aic) data=y opt={-1 1} print=1
        maxlag=20;

   call tsunimar(arcoef,ev,nar,aic,y,20,{-1 1},,1);

   call tsunimar(arcoef,ev,nar,aic,y,10,{-1 0},,1);


data one;
   input invest income consum @@;
cards;
 180 451  415  179 465  421   185 485  434   192 493  448
 211 509  459  202 520  458   207 521  479   214 540  487
 231 548  497  229 558  510   234 574  516   237 583  525
 206 591  529  250 599  538   259 610  546   263 627  555
 264 642  574  280 653  574   282 660  586   292 694  602
 286 709  617  302 734  639   304 751  653   307 763  668
 317 766  679  314 779  686   306 808  697   304 785  688
 292 794  704  275 799  699   273 799  709   301 812  715
 280 837  724  289 853  746   303 876  758   322 897  779
 315 922  798  339 949  816   364 979  837   371 988  858
 375 1025 881  432 1063 905   453 1104 934   460 1131 968
 475 1137 983  496 1178 1013  494 1211 1034  498 1256 1064
 526 1290 1101 519 1314 1102  516 1346 1145  531 1385 1173
 573 1416 1216 551 1436 1229  538 1462 1242  532 1493 1267
 558 1516 1295 524 1557 1317  525 1613 1355  519 1642 1371
 526 1690 1402 510 1759 1452  519 1756 1485  538 1780 1516
 549 1807 1549 570 1831 1567  559 1873 1588  584 1897 1631
 611 1910 1650 597 1943 1685  603 1976 1722  619 2018 1752
 635 2040 1774 658 2070 1807  675 2121 1831  700 2132 1842
 692 2199 1890 759 2253 1958  782 2276 1948  816 2318 1994
 844 2369 2061 830 2423 2056  853 2457 2102  852 2470 2121
 833 2521 2145 860 2545 2164  870 2580 2206  830 2620 2225
 801 2639 2235 824 2618 2237  831 2628 2250  830 2651 2271
;
proc iml;
   use one;
   read all into y var{invest income consum};
   mdel  = 1;
   maice = 2;
   misw  = 0;  /* instantaneous modeling ? */
   opt   = mdel ||  maice || misw;
   maxlag = 10;
   miss   = 0;
   print  = 1;
   call tsmulmar(arcoef,ev,nar,aic,y,maxlag,opt,miss,print);

   call tsmulmar(arcoef,ev,nar,aic) data=y maxlag=5
        opt={1 1 0} print=1;

   call tsmulmar(arcoef,ev,nar,aic) data=y maxlag=3
        opt={1 0 0} ;
print aic nar;
print arcoef;

   call tsmulmar(arcoef,ev,nar,aic) data=y maxlag=3
        opt={1 2 0};
print aic nar;
print arcoef;
title2 'Nonstationary Data Analysis';
data one;
   input y @@;
cards;
  .21232e1   .47451    -.171e-2  -.84434    -.10876e1
 -.84429    -.15320e1  -.21097e1 -.28282e1 -.30424e1
 -.31714e1  -.25042e1  -.40406e1  -.37741e1 -.24557e1
 -.14803e1  -.11456e1  -.19861e1 -.24899e1  -.10926e1
  .76909     .44457    -.98272   -.60115    -.51100e-2
 -.75129     .14737     .25100e1  .28413e1   .22882
 -.14294e1  -.22658e1  -.20462e1 -.17189e1  .31475
  .49432e1  .74404e1    .60316e1  .44300e1  .25392e1
  .88116    .99908      .20893e1  .14615e1 -.15465e1
 -.39071e1 -.41050e1  -.45899e1  -.36374e1  -.25623e1
 -.28320e1 -.22083e1  -.12521e1  -.60346    .15296e1
  .27190e1  .22839e1   .21644e1   .22284e1  .18323e1
  .10191e1  .53627     .14400e1   .27485e1  .23344e1
  .29678e1  .44569e1   .44449e1   .47612e1  .57645e1
  .48988e1  .24701e1   .30355e1   .45397e1  .25237e1
  .85361    .37475     .61676     .38774    .24211e1
  .50219e1  .59801e1   .51236e1   .41791e1  .32537e1
  .74290e-1 -.90402    .11527e1   .19298   -.38438e1
 -.52842e1 -.44210e1 -.42358e1   -.35756e1 -.68584
  .22025e1  .67884    -.51910e-1 -.26841  -.14454e1
 -.27263e1 -.10642e1  -.22906     .14353e1  .44310e1
  .56587e1  .57044e1   .49740e1   .35969e1  .32536e1
  .15313e1 -.54363     .17246e1   .22281e1  .11698e1
  .31331e1  .37619e1   .18702e1  -.63447   -.16734e1
 -.78362    .18155     .81437     .29880e1  .42316e1
  .27936e1  .14584e1   .69219     .92169    .50336
 -.14576    .28626    -.21177   -.18325    .83773
  .21403e1  .32151e1   .39073e1  .17564e1 -.40430e-1
 -.14468e1 -.30978e1  -.45090e1 -.34477e1 -.11195e1
  .69229    -.44579   -.81135    .16924e1  .16261e1
 -.40439   .44632      .25005e1  .10500e1 .18656e1
  .29493e1  .38990e-1 -.21080e1  -.23002e1 -.51056e1
 -.70257e1 -.67368e1  -.71630e1 -.67029e1  -.35206e1
 -.91048   -.14017    .21923e1   .41561e1   .35830e1
 .11135e1  .10722e1   .56274    -.60720e-1 .10540e1
  .14742e1  .87608   -.50290e-1 -.46292   -.10444e1
 -.15323e1 -.19734e1 -.19980e1 -.14040e1 -.98567
 -.13120e1 -.20757e1 -.89996   -.10235e1 -.86877
 -.58291   -.16572    .28356   -.13699e1 -.20766e1
 -.25061e1 -.34979e1 -.30414e1 -.22379e1 -.14656e1
  .16544e1  .27433e1  .18284e1  .19546e1  .17829e1
  .28038e1  .14874e1 -.18358   -.20454e1 -.51580e1
 -.59216e1 -.42272e1 -.31347e1 -.11411e1  .74276
  .69111    .17371    .30344   -.96847   -.11461e1
  .73357    .19426e1  .40275e1  .56222e1  .60117e1
  .64635e1  .57200e1  .31722e1  .14605e1 -.14047e1
 -.33388e1 -.19739e1  .75048    .37720e1  .57080e1
  .56570e1  .27987e1 -.26068   -.10693e1 -.12593e1
 -.91699    .16950e1  .33184e1  .37526e1  .28199e1
  .52852    .44112    .18226    .43381    .16512e1
  .19047e1  .41794   -.74695   -.12674e1 -.11783e1
 -.23962   -.36487   -.10150e1 -.25589e1 -.32584e1
 -.16839e1 -.20363e1 -.33336e1 -.38013e1 -.48810e1
 -.70115e1 -.66677e1 -.53179e1 -.39982e1 -.27593e1
 -.76430    .61031    .16508e1  .27397e1  .21227e1
  .82413    .17823e1  .31185e1  .10319e1  .44284
  .20106e1 -.29711   -.17797e1 -.26535e1 -.44488e1
 -.49930e1 -.13722e1  .28765e1  .40531e1  .41888e1
  .37341e1  .10123e1 -.48490e-1 .11352e1  .13888e1
  .10163e1  .13922e1  .10181e1 -.12706e1  .49050e-1
  .28326e1  .26521e1  .36238e1  .47693e1  .99788
 -.37782e1 -.55912e1 -.57962e1 -.47187e1 -.82419
  .30362e1  .38098e1  .34193e1  .30633e1  .10207
  -.13569e1 -.57315    .17041   -.13010   .46305
  .57370e-1 -.89257  -.69259    .41210e-1 .10538e1
  .28650e1  .31371e1  .17423e1  .33408e1  .35503e1
  .17936e1  .18962e1  .37921e1  .40597e1  .21531e1
  .11832e1  .20175   -.17523    .45884   -.33998
 -.34732    .70966    .28029   -.81689   -.17065e1
 -.23841e1 -.45573e1 -.43359e1 -.39757e1 -.28036e1
 -.72917   -.21099   -.33812    .38755    .73656
  .15580e-1 .29561    .24164e1  .27155e1  .22664e1
  .25401e1  .29552e1  .16478e1  .67895    .15853e1
 -.20539   -.22975e1 -.15602e1  .16891    .87486
  .58779    .13468e1  .48464   -.10825e1 -.19219e1
 -.32107e1 -.45300e1 -.19356e1  .86894    .32397
 -.78359    -.70134   -.25998e1 -.44587e1 -.13451e1
  .24063e1  .39978e1  .66603e1  .52073e1  .10280e-1
 -.29285e1 -.42959e1 -.53644e1 -.29264e1  .16018e1
  .25112e1  .30417e1  .40855e1  .20552e1 -.91705
 -.17546e1 -.23059e1 -.28742e1 -.24611e1 -.19649e1
 -.29445e1 -.49109e1 -.66890e1 -.60487e1 -.40107e1
 -.27389e1 -.25226e1 -.16680e1 -.12292    .15090e1
  .13531e1  .96067    .65678   -.14941    .40654
  .11915e1  .12979e1  .27594e1  .38072e1  .82062
 -.14616    .56445   -.15341e1 -.29392e1 -.34430e-1
  .13394e1 -.34905    .96274    .18512e1 -.19664
 -.18437e1 -.63209   -.12943e1 -.23742e1 -.44357
 -.38785   -.28229e1 -.12464e1  .20253e1  .24906e1
  .14951e1  .31615e1  .14374e1 -.20224e1 -.17221e1
 -.93806   -.23118e1 -.20556e1 -.89757   -.12143e1
 -.20192e1 -.55518   -.98174   -.90652    .15837e1
 .10687e1  .14387e1  .43464e1   .50423e1  .30744e1
 .41017e1  .15820e1 -.19788e1 -.14845e1  -.72114
 -.17572e1 -.78170e-1 .38380e-1 -.19383e1 -.11083e1
  .20812e1  .23072e1  .19481e1  .23170e1   .23319
 -.15642e1 -.25626e1 -.25176e1 -.38839e1 -.49541e1
 -.35618e1 -.25752e1 -.17620e1 -.13164e1 -.14521e1
 -.15164e1 -.12435e1 -.33419    .10726e1  .31957
 -.17817   -.44265   -.17533e1  -.27862e1 -.73801
  .19937e1  .27335   -.44323     .61213   -.96147
 -.24286e1  .10454e1  .49832e1  .58430e1   .67043e1
  .49056e1 -.11115   -.42396e1  -.45509e1 -.28420e1
 -.33752    .11703e1  .20529e1  .14217e1  .71480e-1
 -.16108   -.10602e1 -.26509    .29849e1  .23934e1
 -.76810e-1 .24055     .54719    .36336   .44682e1
 .74858e1  .56569e1  .37605e1   .40142e1  .17751e1
 -.79662   -.19207e1 -.26013e1 -.34211e1  -.22944e1
 -.96203   -.12799e1 -.14749e1 -.24096e1 -.31221e1
 -.27273e1 -.28865e1 -.29953e1 -.12526e1  .10931e1
  .25173e1   .18346e1  .28224   .18124    .31400e-1
  .20074e1  .40952e1   .30277e1 .14903e1  .70693
 -.23821e1 -.25325e1 -.20123e1  -.41759e1 -.41776e1
 -.97520e-1 .24124e1  .22578e1  .33899e1   .34843e1
  .73408   -.89786    .63628    .76202    .58840e-1
  .13951e1 -.32835   -.51255e1 -.63345e1 -.40460e1
 -.33949e1  -.13638e1 .19268e1 .19616e1  -.91085
 -.16167e1 -.28469e1  -.47148e1 -.48544e1 -.31744e1
 -.15196e1 -.78010e-1 .20722e1   .35228e1  .41356e1
  .36124e1  .51169   -.39315e1 -.48369e1  -.27785e1
 -.33760    .26125e1  .39145e1  .13366e1  -.38579e1
 -.69886e1 -.75886e1 -.39628e1 -.42750e-1 .31792e1
  .27930e1   .18711e1 -.44628  -.18752e1 -.23678e1
  -.22431e1  .63020    .32844e1  .35382e1 .41680e1
  .56101e1  .35509e1  .21272e1   .13487e1 -.71070e-1
  .13370e-1 .99203   -.19809   -.25806e1  -.26215e1
 -.14092e1 -.10503e1 -.11943e1 -.92094    -.10811e1
 -.32402e1 -.49259e1 -.40744e1 -.49960e1  -.41957e1
 -.22334e1 -.32103e1 -.55951e1 -.58428e1  -.50155e1
 -.27862e1 -.41900e-2 .38169   -.78261    -.10571e1
 -.50592   -.20864    .22935e1  .45191e1   .31465e1
  .85198   -.95016   -.22236e1 -.20255e1   .13620e-1
  .24389e1  .16594e1 -.74627   -.18741e1  -.23120e1
 -.26552e1 -.18580e1 -.20596    .68591     .26157
 -.20700   -.76957    .52308    .24229e1   .36764e1
  .21684e1  .53821    .10316e1  .10136e1   .13441
  .12428e1  .18857e1  .10108   -.70357     .29082
 -.18591   -.10524e1 -.12246e1 -.78411    -.10854e1
 -.10594e1 -.14190e1 -.25085e1 -.31476e1  -.49120
  .32557e1  .53657e1  .60382e1  .50940e1   .21251e1
 -.21401e1 -.45844e1 -.37850e1 -.21558e1  -.11368e1
  .19739e1  .47841e1  .64890e1  .65086e1   .44846e1
  .10576e1 -.31490e1 -.57643e1 -.51850e1  -.12196e1
  .27302e1  .44350e1  .48051e1  .27548e1  -.13549e1
 -.64529e1 -.73481e1 -.50199e1 -.31592e1   .14520e1
  .48652e1  .34957e1  .21484e1  .12023e1   .38030
  .93560    .37393e1  .39898e1  .18933e1  -.18009
 -.22540e1 -.43827e1 -.46953e1 -.28134e1  -.95769
  .87180e-1 .18364e1  .19586e1 -.13363e1  -.35681e1
 -.26424e1 -.17582e1 -.34898    .28429e1   .48649e1
  .26546e1 -.68844   -.26299e1 -.50732e1  -.58248e1
 -.35492e1 -.13342e1 -.11452e1 -.10793     .14729e1
  .50836    .32454    .28779e1  .48740e1   .35516e1
  .44744e1  .35415e1 -.30018   -.73467e1  -.80053e1
 -.76780e1 -.40052e1  .22489e1  .61895e1   .80277e1
  .71266e1  .32113e1 -.24635e1 -.67759e1  -.77120e1
 -.51839e1 -.12510e1  .26397e1  .56783e1   .51853e1
  .87452   -.26642e1 -.28083e1 -.27995e1  -.11743e1
  .51120   -.61972   -.28518e1 -.31683e1  -.23815e1
 -.80850    .20733e1  .44195e1  .41069e1   .22232e1
  .35531   -.28055e1 -.38599e1 -.20310e1  -.75040
  .11734    .27131e1  .28551e1  .13469e1   .17174e1
  .33616e1  .37837e1  .50780e1  .37710e1   .72495
 -.77142   -.79002    .92667    .23868e1   .44050e1
  .61124e1  .44085e1  .31815e1  .99798    -.18387e1
 -.30464e1 -.32050e1 -.45968e1 -.42617e1  -.14815e1
 -.19642    .15521    .14765e1  .31298e1   .21396e1
  .12621    .66210    .23339e1  .14315e1   .18642e1
  .22715e1 -.30368e1 -.67664e1 -.77819e1  -.91200e1
 -.79972e1 -.33746e1 -.17698e1 -.31900e-2 -.18810e-1
 -.27065e1 -.53475e1 -.50109e1 -.40961e1  -.37508e1
 -.20028e1 -.11467   -.70140   -.12557e1   .53770
  .10623e1  .12848e1  .17672e1  .20020e1   .21832e1
  .26821e1  .30058e1  .35388e1  .43613e1   .32381e1
 -.11110e1 -.50051e1 -.60840e1 -.44107e1  -.11380e1
  .24261e1  .73555e1  .88091e1  .47620e1   .16492e1
 -.47100   -.32299e1 -.33735e1  .40121     .45407e1
  .67417e1  .87958e1  .74124e1  .23042e1  -.30663e1
 -.67998e1 -.99142e1 -.91043e1 -.54271e1  -.27894e1
 -.64066   -.15821   -.22627     .35440e-1 .10151
  .35576    .12378e1  .69906   -.23062    -.20765e1
 -.26094e1 -.27639e1 -.41822e1 -.43207e1  -.27278e1
 -.22371e1 -.95365    .96700    .29827e1   .45331e1
  .56392e1  .71368e1  .52588e1  .14579e1  -.15655e1
 -.42760e1 -.61568e1 -.47034e1 -.15898e1   .78518
  .17392e1  .21600e1  .11484e1 -.98559    -.16395e1
 -.21925e1 -.26096e1 -.18653e1 -.10710e-1  .96932
  .82964    .19314e1  .13027e1 -.19428e1   -.37536e1
 -.61020e1 -.85213e1 -.66229e1 -.27024e1   -.17156e1
 -.32903    .55055   -.21043   -.12342e1  -.19926e1
 -.33864   -.34073e1 -.15925e1  .11302     .14315e1
  .18899e1  .17847e1  .11641e1 -.66153    -.57238
 -.82557   -.17608e1 -.23833e1 -.19450e1  -.16931e1
 -.31799    .30429e1  .73039e1  .90978e1   .77165e1
  .49446    .12464e1 -.31597e1 -.46957e1  -.31438e1
 -.44870e-1 .37553e1  .71687e1  .72806e1   .30138e1
 -.10553e1 -.20069e1 -.21633e1 -.62533     .24722e1
  .61732e1  .68225e1  .36901e1  .22859    -.28079e1
 -.39519e1 -.40152e1 -.23398e1 -.28602     .25187e1
  .45845e1  .48295e1  .29352e1 -.14695e1  -.66874e1
;

proc iml;
   use one;
   read all var{y};

   mdel = -1;
   lspan = 300; /* local span of data */
   maice = 1;
   opt = mdel || lspan || maice;
   call tsmlocar(arcoef,ev,nar,aic,first,last)
                data=y maxlag=10 opt=opt print=2;

proc iml;
  rudder = {
  515  553  544  512  583  544  512  514
  609  648  712  686  704  736  704  713
  750  772  774  801  782  803  780  773
  736  803  768  783  803  768  771  768
  774  804  780  780  806  768  768  771
  768  776  832  819  769  798  784  804
  778  780  656  467  408  364  273  256
  291  320  294  296  278  259  225  278
  288  291  309  275  246  278  272  288
  303  298  301  270  272  274  256  296
  313  271  241  400  542  589  584  679
  647  653  710  681  704  707  744  654
  681  672  679  680  712  680  680  677
  708  675  710  715  676  677  704  708
  736  813  866  896  876  900  896  899
  960  906  864  896  868  875  930  910
  905  927  808  952  916  947  913  894
  950  900  944  886  914  912  928  816
  900  896  928  849  916  800  768  772
  630  488  394  360  384  403  408  352
  391  353  386  389  398  391  344  374
  372  424  390  332  324  384  367  326
  300  228  264  260  236  232  258  256
  192  236  256  261  236  224  256  230
  259  256  239  256  256  259  230  231
  268  263  264  384  484  618  649  679
  673  672  707  716  738  696  697  660
  746  748  740  768  690  726  696  732
  760  740  729  734  728  712  697  768
  742  696  768  732  704  752  743  723
  742  680  740  729  740  720  736  743
  768  718  720  708  711  706  711  736
  736  704  682  704  647  590  481  418
  390  331  328  323  330  357  362  397
  357  359  324  330  352  416  359  329
  320  384  326  355  384  357  384  388
  360  296  299  364  358  353  352  363
  294  355  352  304  291  161  159   80
  122  123   72  139  118  116  124  107
  102   82   95  148  140  103  114  114
  120  104  168  116  128  112   81   86
   80  127  113  136  112   96  115  100
  102  124  131  144  143  142  200  228
  192  258  416  544  621  676  716  704
  711  744  776  744  768  743  718  705
  712  779  808  740  778  740  676  776
  742  749  711  710  718  736  768  769
  783  768  740  674  679  682  653  692
  697  752  683  704  712  688  678  712
  727  707  694  582  482  472  435  484
  368  299  256  195   44   27   40   40
   84   26   -3   20  -13   30    0   15
   48   39   15  -16    3  -24   29   31
   48   11   64  172  199  224  225  200
  204  227  256  256  224  228  195  197
  226  257  228  232  204  226  166  229
  258  224  195  204  256  232  256  233
  192  232  232  230  238  226  192  128
  109   98  102   32   43   90  137   78
   69   74   24   96   79   68   58   57
   73   75   91  116   66   64  101  122
   88   96  148  257  438  499  476  470
  423  396  392  530  576  567  626  691
  723  686  668  695  704  656  644  618
  646  617  645  608  579  488  448  396
  361  384  416  492  552  584  617  608
  640  618  615  614  618  610  612  620
  616  615  648  652  619  613  612  616
  615  619  616  640  654  649  614  623
  613  613  605  620  692  728  749  762
  736  768  724  750  752  751  738  773
  720  732  779  728  725  768  652  555
  599  624  698  669  724  722  711  656
  590  535  515  557  555  524  588  568
  568  598  569  472  304  160   64    0
    0   15  -29   34  128  192  172  230
  206  165  108  138  101   96  195  200
  228  234  265  288  264  320  320  271
  226  256  262  269  231  296  263  267
  256  290  335  454  523  548  608  570
  648  544  358  344  301  388  422  461
  442  421  410  385  392  407  482  486
  496  561  528  567  550  572  546  592
  607  480  448  395  384  382  392  389
  360  363  364  370  377  408  482  452
  498  512  483  525  494  524  515  548
  524  517  512  514  520  448  513  494
  512  544  525  522  513  512  512  488
  491  520  514  488  488  460  480  484
  516  514  513  524  578  512  519  526
  554  524  518  493  483  512  519  480
  458  503  512  517  512  512  512  549
  548  528  564  544  506  512  528  538
  527  490  513  531  512  514  562  555
  568  592  607  612  592  613  556  542
  553  548  576  528  544  520  530  512
  545  480  522  512  521  576  545  576
  554  521  490  424  399  389  324  225
  199  168  140  160    0  131  161  192
  164  203  225  164  166  164  163  201
  195  202  193  192  232  324  331  357
  362  330  368  376  372  342  352  366
  352  367  384  421  402  408  421  466
  440  448  429  416  416  424  472  454
  485  419  332  347  316  416  442  496
  466  393  380  406  432  356  398  425
  448  473  486  490  553  548  552  423
  260  256  195  289  388  454  426  416
  298  321  387  328  421  416  418  461
  416  327  258  195  237  262  360  397
  480  481  484  458  427  454  384  292
  399  392  384  389  459  458  521  -183};

  yawing = {
  -96  -56  -57  -61    8  -20    0  -32
    6  -56    2  -60  -20   34    2    1
    0  -54  -32   32    6   74   64   32
  -50    0  -64  -90  -30  -24  -32    0
  -32  -32  -57  -96  -28  -32  -64  -52
  -62  -86  -56  -23  -80  -14 -119  -32
  -88  -96 -105  -96 -159  -96  -83 -112
  -94 -112 -155 -148 -112 -103 -140 -114
 -150 -149 -143 -101  -83  -53  -60  -48
  -58  -57  -20  -38  -51  -57 -126  -83
  -31   22   16   44   59  -32  -96  -19
    4    0   40    9    2    0   72    6
   33    9   14    5    2    8   32   14
   66   43   36    8    8   72  104  136
   64    8   38   64   46   44    3   45
   78   43   96   68    1  -23   32   15
   96   97   40  115   89  154   84   -8
   53    0  106   65   99   64   52  -25
   16   18   10  -28  -28  -27  -94  -77
 -112  -96  -74 -124  -83  -55  -64  -80
  -60 -125 -176 -131 -116 -128 -148  -96
  -84  -33  -80  -89 -126 -150 -150 -188
 -150 -128  -85  -89  -90  -59  -20  -95
 -160 -160 -160 -160 -125  -96  -53  -64
  -88  -92  -96  -93  -64  -64  -84  -56
  -32    4   13    8    2    5  -32  -20
  -24    8    1   64   67   56   34   32
   97   73   31   17  -32   15   26   48
   96   51    3   10   16    0 -104   -9
  -16  -36   41   40   14   -2  -48  -48
   26  -48   52    3  -21  -64  -80 -100
  -72 -112  -75 -117 -104 -112 -158 -121
 -148 -160 -192 -160 -214 -221 -248 -247
 -212 -224 -212 -216 -186 -155 -181 -192
 -284 -244 -288 -372 -288 -241 -224 -276
 -256 -251 -284 -307 -320 -316 -285 -316
 -276 -288 -312 -288 -315 -288 -346 -320
 -371 -320 -287 -268 -247 -256 -217 -268
 -261 -256 -304 -268 -304 -316 -256 -253
 -224 -239 -240 -174 -208 -217 -214 -192
 -196 -224 -204 -256 -223 -217 -177 -162
 -183 -201 -214 -192 -256 -219 -179 -180
 -156 -115 -140 -160 -135 -120  -91  -64
  -96  -57  -90 -124 -160 -117  -92  -86
  -58  -60  -92 -128  -96  -92  -83 -116
  -96  -51    0  -52   42  -28 -128  -96
 -122  -96 -128  -96  -57  -64  -57  -92
 -120 -128 -120 -118 -115 -127 -128 -118
 -166 -126 -176 -128 -120 -145 -168 -156
 -196 -160 -160 -168 -158 -135 -160 -176
 -236 -280 -256 -248 -293 -272 -256 -252
 -219 -282 -279 -234 -233 -206 -252 -246
 -224 -280 -269 -283 -264 -266 -256 -226
 -200 -153 -164 -180 -249 -224 -187 -224
 -177 -160 -179 -192 -189 -160 -221 -184
 -213 -244 -180 -149 -128 -128 -223 -249
 -318 -287 -285 -244 -213 -192 -192 -181
 -221 -212 -223 -245 -256 -256 -252 -286
 -248 -224 -159 -223 -184 -143  -80 -168
 -144 -192 -208 -192 -192 -144  -87  -63
  -80  -80  -84  -64  -83  -72  -56  -30
   12    0   36   -2  -32  -36  -40  -13
   14   20   92  128  128  128  109   83
   40    8   68   80  174  186  201  126
  135   67   32   42   78  100  134  136
  140  138  142  102   96   96  108   68
  132   96   98  128  142  105  102  136
  104  103  160  136  141  137  136  163
  143  136  129  132  160  137   96   68
   98  131  139  179  172  154  156  132
   84  124  112  124  155  128  103  128
   86  135  120   96   27   66  122   79
  124  128  137   -9    0  -24    0   -6
   17    9   -6   52   48   56   52   32
  -70  -80 -171 -104 -102 -120  -88  -59
  -93  -64  -91  -63  -88 -147 -180 -160
 -156 -115  -86  -30  -23  -56  -64 -128
  -88 -117 -115  -53  -64    4  -28  -32
  -56  -61  -27  -30  -56  -64  -60  -96
  -62    2    5   32   32   13   32  -84
  -16   -9  -78   37   45   60   18   39
   19    1   11   77   68   56   50   53
   33   92   56   83  112  114   68   72
   71   38   62  108  113  115   60   51
   35    0   24   30   83   72  148  119
  147  112   64   46   44    8   36   64
   75   96  102  102  128   75  139   98
  101  102   72   44   66   96   77  108
  108  160  136  101   79   38   40   15
   99   96  128  111  128   72    6   33
    0    0    8    2    4   -7   42   24
   31   39   50   76   67   48   17   65
   35    0   52   -6  -53    5   14   16
   32    4   24   66   60   81  109   53
   17   -4   -8  -12  -60   -7   -8   -1
   20   14   16  -29   -7  -32  -29  -38
  -31  -64  -64  -96 -118  -50  -96  -86
  -92 -123  -64  -83  -64 -122 -121 -128
 -117 -116 -127 -121    0 -119  -84  -94
  -82  -54  -64  -64  -82  -86  -88  -87
  -32  -24  -55  -64  -26  -32  -21  -56
  -32  -86  -64  -76   43   -6   22  -14
   16    0    0   68   34   32   22    0
    5   20   77   64   68   24    7  -32
  -51  -30  -30   32    4    0   -8   16
   -8    0  -12  -12  -10   22   24   54
  108   80   72    8   -7  -86 -128  -96
  -52    3    8    4  -24  -32  -58  -64
  -64  -53   72  -32   40  -20  -82  -59
  -96  -64  -55  -58  -20   14    3  -24
    0  -30   38    2  -23    0  -56  -64
  -49   32   34   73   66   64   33  -20};

   y = rudder` || yawing`;
   c = {0.01795 0.02419};
   n=nrow(y);
  /*-- calibration of data --*/
   y = y # (c @ j(n,1,1));
   mdel = -1;
   lspan = 300; /* local span of data */
   maice = 1;
   call tsmlomar(arcoef,ev,nar,aic,first,last) data=y maxlag=10
        opt = (mdel || lspan || maice) print=1;

proc iml;
   y = { 116.8 120.1 123.2 130.2 131.4 125.6 124.5 134.3
         135.2 151.8 146.4 139.0 127.8 147.0 165.9 165.5
         179.4 190.0 189.8 190.9 203.6 183.5 169.3 144.2
         141.5 154.3 169.5 193.0 203.2 192.9 209.4 227.2
         263.7 297.8 337.1 361.3 355.2 312.6 309.9 323.7
         324.1 355.3 383.4 395.1 412.8 406.0 438.0 446.1
         452.5 447.3 475.9 487.7 497.2 529.8 551.0 581.1
         617.8 658.1 675.2 706.6 724.7 };
   y = y`; /*-- convert to column vector --*/
   mdel  = 0;
   trade = 0;
   tvreg = 0;
   year  = 0;
   period= 0;
   log   = 0;
   maxit = 100;
   update = .; /* use default update method      */
   line   = .; /* use default line search method */
   sigmax = 0; /* no upper bound for variances   */
   back = 100;
   opt = mdel || trade || year || period || log || maxit ||
         update || line || sigmax || back;
   call tsdecomp(cmp,coef,aic) data=y order=2 sorder=0 nar=2
        npred=5 opt=opt icmp={1 3} print=1;
   y = y[52:61];
   cmp = cmp[52:66,];
   print y cmp;


title2 'Seasonal Adjustment';
proc iml;
   y =
     { 5447 5412 5215 4697 4344 5426
       5173 4857 4658 4470 4268 4116
       4675 4845 4512 4174 3799 4847
       4550 4208 4165 3763 4056 4058
       5008 5140 4755 4301 4144 5380
       5260 4885 5202 5044 5685 6106
       8180 8309 8359 7820 7623 8569
       8209 7696 7522 7244 7231 7195
       8174 8033 7525 6890 6304 7655
       7577 7322 7026 6833 7095 7022
       7848 8109 7556 6568 6151 7453
       6941 6757 6437 6221 6346 5880     };
   y = y`;

   call tsbaysea(trend,season,series,adj,abic)
        data=y order=2 sorder=1 npred=12 print=2;
   print trend season series adj abic;
title2 'Miscellaneous Time Series Analysis Tools';
proc iml;
   c = { 264 235 239 239 275 277 274 334 334 306
         308 309 295 271 277 221 223 227 215 223
         241 250 270 303 311 307 322 335 335 334
         309 262 228 191 188 215 215 249 291 296 };
   f = { 690 690 688 690 694 702 702 702 700 702
         702 694 708 702 702 708 700 700 702 694
         698 694 700 702 700 702 708 708 710 704
         704 700 700 694 702 694 710 710 710 708 };
   t = { 1152 1288 1288 1288 1368 1456 1656 1496 1744 1464
         1560 1376 1336 1336 1296 1296 1280 1264 1280 1272
         1344 1328 1352 1480 1472 1600 1512 1456 1368 1280
         1224 1112 1112 1048 1176 1064 1168 1280 1336 1248 };
   p = { 254.14 253.12 251.85 250.41 249.09 249.19 249.52 250.19
         248.74 248.41 249.95 250.64 250.87 250.94 250.96 251.33
         251.18 251.05 251.00 250.99 250.79 250.44 250.12 250.19
         249.77 250.27 250.74 250.90 252.21 253.68 254.47 254.80
         254.92 254.96 254.96 254.96 254.96 254.54 253.21 252.08 };

   y = c` || f` || t` || p`;
   ar = {  .82028   -.97167    .079386   -5.4382,
          -.39983    .94448    .027938   -1.7477,
          -.42278  -2.3314    1.4682    -70.996,
           .031038  -.019231  -.0004904   1.3677,
          -.029811   .89262   -.047579    4.7873,
           .31476    .0061959 -.012221    1.4921,
           .3813    2.7182    -.52993    67.711,
          -.020818   .01764    .00037981  -.38154 };
   ma = {  .083035 -1.0509     .055898   -3.9778,
          -.40452    .36876    .026369    -.81146,
           .062379 -2.6506     .80784   -76.952,
           .03273   -.031555  -.00019776  -.025205 };
   coef = ar // ma;
   ev = { 188.55   6.8082    42.385   .042942,
          6.8082   32.169    37.995  -.062341,
          42.385   37.995    5138.8  -.10757,
          .042942  -.062341  -.10757  .34313 };

   nar = 2; nma = 1;
   call tspred(forecast,impulse,mse,y,coef,nar,nma,ev,
               5,nrow(y),-1);

   observed  = y[,{1 2}];
   predicted = forecast[,{1 2}];
   cname  = {y1 y2};
   cname1 = {p1 p2};
   print  observed[colname=cname format= 5.0]
          predicted[colname=cname1 format= 8.3];

proc iml;
   y = { 2.430 2.506 2.767 2.940 3.169 3.450 3.594 3.774 3.695 3.411
         2.718 1.991 2.265 2.446 2.612 3.359 3.429 3.533 3.261 2.612
         2.179 1.653 1.832 2.328 2.737 3.014 3.328 3.404 2.981 2.557
         2.576 2.352 2.556 2.864 3.214 3.435 3.458 3.326 2.835 2.476
         2.373 2.389 2.742 3.210 3.520 3.828 3.628 2.837 2.406 2.675
         2.554 2.894 3.202 3.224 3.352 3.154 2.878 2.476 2.303 2.360
         2.671 2.867 3.310 3.449 3.646 3.400 2.590 1.863 1.581 1.690
         1.771 2.274 2.576 3.111 3.605 3.543 2.769 2.021 2.185 2.588
         2.880 3.115 3.540 3.845 3.800 3.579 3.264 2.538 2.582 2.907
         3.142 3.433 3.580 3.490 3.475 3.579 2.829 1.909 1.903 2.033
         2.360 2.601 3.054 3.386 3.553 3.468 3.187 2.723 2.686 2.821
         3.000 3.201 3.424 3.531 };

   call tsunimar(ar,v,nar,aic) data=y maxlag=5
        opt=({-1 1}) print=1;
   /*-- set up complex coefficient matrix --*/
   ar_cx = ar || j(nrow(ar),1,0);
   call tsroot(root) matin=ar_cx nar=nar
                       nma=0 print=1;

   call tsroot(ar_cx) matin=root nar=nar qcoef=1
                       nma=0 print=1;

title; title2;