Resources

Lung Function Analysis of an Asthma Patient

/*--------------------------------------------------------------
                    SAS Sample Library

       Name: ssmex15.sas
       Description: Example program from SAS/ETS User's Guide,
              The SSM Procedure
       Title: Lung Function Analysis of an Asthma Patient
       Product: SAS/ETS Software
        Keys: Multivariate Modeling, Factor Model
        PROC: SSM
        Notes:

--------------------------------------------------------------*/

data asth;
   input time y @@;
   datalines;
   8  520
  10  500
  12  540
  14  520
  16  500
  18  500
  20  510
  22  500
  32  480
  34  510
  36  500
  38  500
  40  520
  42  540
  44  520
  46  520
  56  500
  58  480
  60  480
  62  520
  64  540
  66  560
  68  520
  70  500
  80  460
  82  470
  84  500
  86  480
  88  520
  90  500
  92  500
  94  510
 104  480
 106  480
 108  510
 110  480
 112  500
 114  520
 116  540
 118  520
 130  470
 132  500
 134  510
 136  520
 138  510
 140  530
 142  520
 154  500
 156  520
 158  500
 160  480
 162  500
 164  520
 166  500
 176  460
 178  450
 180  480
 182  500
 184  520
 186  500
 188  510
 190  510
 200  480
 202  510
 204  500
 206  520
 208  520
 210  520
 212  540
 224  500
 226  520
 228  510
 230  500
 232  520
 234  530
 236  520
 238  520
 248  480
 250  470
 252  480
 254  460
 256  460
 258  500
 260  520
 262  500
 272  470
 274  480
 276  500
 278  500
 280  480
 282  520
 284  500
 296  450
 298  470
 300  460
 302  480
 304  500
 306  520
 308  520
 310  520
 320  480
 322  500
 324  510
 326  500
 328  520
 330  540
 332  560
 334  520
 344  460
 346  480
 348  500
 350  480
 352  520
 354  500
 356  520
 358  500
 368  470
 370  480
 372  470
 374  500
 376  480
 378  520
 380  500
 392  440
 394  460
 396  480
 398  460
 400  480
 402  500
 404  520
 406  520
 416  480
 418  500
 420  520
 422  520
 424  550
 426  530
 428  520
 430  500
 440  500
 442  520
 444  500
 446  530
 448  520
 450  500
 452  520
 454  500
 464  480
 466  470
 468  500
 470  500
 472  500
 474  520
 476  540
 478  520
 488  460
 490  460
 492  480
 494  500
 496  530
 498  500
 500  520
 502  500
 512  450
 514  430
 516  460
 518  460
 520  480
 522  500
 524  480
 536  460
 538  420
 540  450
 542  500
 544  480
 546  460
 548  500
 550  520
 584  420
 586  440
 588  480
 590  460
 592  440
 594  460
 596  480
 608  470
 610  480
 612  500
 614  520
 616  520
 618  500
 620  540
 622  520
 632  480
 634  500
 636  430
 638  520
 640  520
 642  530
 644  540
 646  530
 656  470
 658  480
 660  470
 662  480
 664  500
 666  520
 668  560
 670  520
;
data append(keep=time y);
   do i=1 to 30 by 2;
   time = 670+i;
   y = .;
   output;
   end;
run;

proc append base=asth data=append; run;
title;

proc ssm data=asth;
   id time;
   state s1(1) type=cycle(CT) cov(g);
   comp c1 = s1[1];
   intercept = 1;
   irregular wn;
   model y= intercept time c1 wn;
   output out=for1 press;
   eval pattern=intercept+time+c1;
run;

proc sgplot data=for1;
   title "Estimated Stochastic Cycle";
   title2 "(Period = 24.78 Hours and Damping Factor = 0.97)";
   series x=time y=smoothed_c1;
   refline 0 / axis=y lineattrs=(pattern=dash);
run;
title;

proc sgplot data=for1;
   where time > 300;
   title "Estimated Pattern: Time Trend + Stochastic Cycle";
   series x=time y=smoothed_pattern;
   scatter x=time y=y;
   refline 671 / axis=x lineattrs=GraphReference(pattern = Dash)
       name="RefLine"   label="Start of multistep forecasts";
run;
title;