/* This is the Airline Passenger data originally analyzed by Box and Jenkins in their classic textbook(1970). */ /* Here we apply the Basic Structural Model (BSM) of Harvey (1989) to the data and some extensions thereof. */ data airline; input date:monyy5. pass @@; datalines; jan49 112 feb49 118 mar49 132 apr49 129 may49 121 jun49 135 jul49 148 aug49 148 sep49 136 oct49 119 nov49 104 dec49 118 jan50 115 feb50 126 mar50 141 apr50 135 may50 125 jun50 149 jul50 170 aug50 170 sep50 158 oct50 133 nov50 114 dec50 140 jan51 145 feb51 150 mar51 178 apr51 163 may51 172 jun51 178 jul51 199 aug51 199 sep51 184 oct51 162 nov51 146 dec51 166 jan52 171 feb52 180 mar52 193 apr52 181 may52 183 jun52 218 jul52 230 aug52 242 sep52 209 oct52 191 nov52 172 dec52 194 jan53 196 feb53 196 mar53 236 apr53 235 may53 229 jun53 243 jul53 264 aug53 272 sep53 237 oct53 211 nov53 180 dec53 201 jan54 204 feb54 188 mar54 235 apr54 227 may54 234 jun54 264 jul54 302 aug54 293 sep54 259 oct54 229 nov54 203 dec54 229 jan55 242 feb55 233 mar55 267 apr55 269 may55 270 jun55 315 jul55 364 aug55 347 sep55 312 oct55 274 nov55 237 dec55 278 jan56 284 feb56 277 mar56 317 apr56 313 may56 318 jun56 374 jul56 413 aug56 405 sep56 355 oct56 306 nov56 271 dec56 306 jan57 315 feb57 301 mar57 356 apr57 348 may57 355 jun57 422 jul57 465 aug57 467 sep57 404 oct57 347 nov57 305 dec57 336 jan58 340 feb58 318 mar58 362 apr58 348 may58 363 jun58 435 jul58 491 aug58 505 sep58 404 oct58 359 nov58 310 dec58 337 jan59 360 feb59 342 mar59 406 apr59 396 may59 420 jun59 472 jul59 548 aug59 559 sep59 463 oct59 407 nov59 362 dec59 405 jan60 417 feb60 391 mar60 419 apr60 461 may60 472 jun60 535 jul60 622 aug60 606 sep60 508 oct60 461 nov60 390 dec60 432 ; data airline; set airline; logpass=log(pass); title1 'Airline Passengers Jan. 1949 - Dec. 1960'; title2 '(thousands of passengers)'; axis1 label=('Year'); axis2 order=(100 to 700 by 50) label=(angle=90 'Passengers'); proc gplot data=airline; plot pass*date / haxis=axis1 vaxis=axis2; symbol1 i=join; format date year4.; run; title1 'Log of Airline Passengers Jan. 1949 - Dec. 1960'; title2 '(Log of thousands of passengers)'; axis1 label=('Year'); axis2 order=(4 to 7 by .25) label=(angle=90 'Log of Passengers'); proc gplot data=airline; plot logpass*date / haxis=axis1 vaxis=axis2; symbol1 i=join; format date year4.; run; ods html; ods graphics on; /* Here we try out the BSM and Several Extensions of BSM */ /* BSM: stochastic level, stochastic slope, stochastic dummy seasonal */ title 'BSM: stochastic level, stochastic slope, stochastic dummy seasonal'; proc ucm data = airline; id date interval = month; model logpass; irregular; level plot=smooth; slope plot=smooth; season length = 12 type=dummy plot=smooth; estimate plot=(residual normal acf); run; /* BSM2: stochastic level, fixed slope, stochastic dummy seasonal */ title 'BSM2: stochastic level, fixed slope, stochastic dummy seasonal'; proc ucm data = airline; id date interval = month; model logpass; irregular; level plot=smooth; slope var = 0 noest plot=smooth; season length = 12 type=dummy plot=smooth; estimate plot=(residual normal acf); run; /* BSM3: stochastic level, fixed slope, non-stochastic dummy seasonal */ title 'BSM3: stochastic level, fixed slope, non-stochastic dummy seasonal'; proc ucm data = airline; id date interval = month; model logpass; irregular; level; slope var = 0 noest plot=smooth; season length = 12 type=dummy var = 0 noest plot=smooth; estimate plot=(residual normal acf); run; /* BSM4: stochastic level, fixed slope, stochastic dummy seasonal, one stochastic cycle */ title1 'BSM4: stochastic level, fixed slope, stochastic dummy seasonal,'; title2 'one stochastic cycle'; proc ucm data = airline; id date interval = month; model logpass; irregular; level plot=smooth; slope var = 0 noest plot=smooth; season length = 12 type=dummy plot=smooth; cycle plot=smooth; estimate plot=(residual normal acf); run; /* BSM5: stochastic level, fixed slope, stochastic dummy seasonal, two stochastic cycles */ title1 'BSM5: stochastic level, fixed slope, stochastic dummy seasonal,'; title2 'two stochastic cycles'; proc ucm data = airline; id date interval = month; model logpass; irregular; level plot=smooth; slope var = 0 noest plot=smooth; season length = 12 type=dummy plot=smooth; cycle plot=smooth; cycle plot=smooth; estimate plot=(residual normal acf); run; /* BSM6: stochastic level, fixed slope, stochastic dummy seasonal, non-stochastic cycle */ title1 'BSM6: stochastic level, fixed slope, stochastic dummy seasonal,'; title2 'non-stochastic cycle'; proc ucm data = airline; id date interval = month; model logpass; irregular; level plot=smooth; slope var = 0 noest plot=smooth; season length = 12 type=dummy plot=smooth; cycle noest=variance var = 0 plot=smooth; estimate plot=(residual normal acf); run; /* BSM7: stochastic level, fixed slope, stochastic dummy seasonal, autoregressive component for cycle */ title1 'BSM7: stochastic level, fixed slope, stochastic dummy seasonal,'; title2 'autoregressive component for cycle'; proc ucm data = airline; id date interval = month; model logpass; irregular; level plot=smooth; slope var = 0 noest plot=smooth; season length = 12 type=dummy plot=smooth; autoreg plot=smooth; estimate plot=(residual normal acf); run; /* According to AIC and BIC and significance of components, BM4 is the best model. */ /* Now we forecast with BSM4. */ title 'Forecasts produced by BSM4'; proc ucm data = airline; id date interval = month; model logpass; irregular; level plot=smooth; slope var=0 noest plot=smooth; season length = 12 type=dummy plot=smooth; cycle plot=smooth; forecast lead=12 plot=(forecasts decomp) outfor = results; run; /* Here we are translating the log forecasts into forecasts of passengers (in thousands) and then printing them out. Also the lower and upper confidence intervals have been translated as well. */ data results; set results; passf = exp(forecast + 0.5*std**2); passlcl = exp(lcl); passucl = exp(ucl); if _n_ > 144; keep obs forecast std lcl ucl passf passlcl passucl; run; proc print data = results; run;