/* This is the famous M-Series from the Box-Jenkins (1970) textbook. This program generates several graphs showing the "leading" nature of a leading indicator (called lead) as it relates to a target variable to forecast (sales). */ options pagesize=60 linesize=74 nodate; data lead; input obs x y; /* obs lead sales */ cards; 1 10.01 200.1 2 10.07 199.5 3 10.32 199.4 4 9.75 198.9 5 10.33 199.0 6 10.13 200.2 7 10.36 198.6 8 10.32 200.0 9 10.13 200.3 10 10.16 201.2 11 10.58 201.6 12 10.62 201.5 13 10.86 201.5 14 11.20 203.5 15 10.74 204.9 16 10.56 207.1 17 10.48 210.5 18 10.77 210.5 19 11.33 209.8 20 10.96 208.8 21 11.16 209.5 22 11.70 213.2 23 11.39 213.7 24 11.42 215.1 25 11.94 218.7 26 11.24 219.8 27 11.59 220.5 28 10.96 223.8 29 11.40 222.8 30 11.02 223.8 31 11.01 221.7 32 11.23 222.3 33 11.33 220.8 34 10.83 219.4 35 10.84 220.1 36 11.14 220.6 37 10.38 218.9 38 10.90 217.8 39 11.05 217.7 40 11.11 215.0 41 11.01 215.3 42 11.22 215.9 43 11.21 216.7 44 11.91 216.7 45 11.69 217.7 46 10.93 218.7 47 10.99 222.9 48 11.01 224.9 49 10.84 222.2 50 10.76 220.7 51 10.77 220.0 52 10.88 218.7 53 10.49 217.0 54 10.50 215.9 55 11.00 215.8 56 10.98 214.1 57 10.61 212.3 58 10.48 213.9 59 10.53 214.6 60 11.07 213.6 61 10.61 212.1 62 10.86 211.4 63 10.34 213.1 64 10.78 212.9 65 10.80 213.3 66 10.33 211.5 67 10.44 212.3 68 10.50 213.0 69 10.75 211.0 70 10.40 210.7 71 10.40 210.1 72 10.34 211.4 73 10.55 210.0 74 10.46 209.7 75 10.82 208.8 76 10.91 208.8 77 10.87 208.8 78 10.67 210.6 79 11.11 211.9 80 10.88 212.8 81 11.28 212.5 82 11.27 214.8 83 11.44 215.3 84 11.52 217.5 85 12.10 218.8 86 11.83 220.7 87 12.62 222.2 88 12.41 226.7 89 12.43 228.4 90 12.73 233.2 91 13.01 235.7 92 12.74 237.1 93 12.73 240.6 94 12.76 243.8 95 12.92 245.3 96 12.64 246.0 97 12.79 246.3 98 13.05 247.7 99 12.69 247.6 100 13.01 247.8 101 12.90 249.4 102 13.12 249.0 103 12.47 249.9 104 12.47 250.5 105 12.94 251.5 106 13.10 249.0 107 12.91 247.6 108 13.39 248.8 109 13.13 250.4 110 13.34 250.7 111 13.34 253.0 112 13.14 253.7 113 13.49 255.0 114 13.87 256.2 115 13.39 256.0 116 13.59 257.4 117 13.27 260.4 118 13.70 260.0 119 13.20 261.3 120 13.32 260.4 121 13.15 261.6 122 13.30 260.8 123 12.94 259.8 124 13.29 259.0 125 13.26 258.9 126 13.08 257.4 127 13.24 257.7 128 13.31 257.9 129 13.52 257.4 130 13.02 257.3 131 13.25 257.6 132 13.12 258.9 133 13.26 257.8 134 13.11 257.7 135 13.30 257.2 136 13.06 257.5 137 13.32 256.8 138 13.10 257.5 139 13.27 257.0 140 13.64 257.6 141 13.58 257.3 142 13.87 257.5 143 13.53 259.6 144 13.41 261.1 145 13.25 262.9 146 13.50 263.3 147 13.58 262.8 148 13.51 261.8 149 13.77 262.2 150 13.40 262.7 ; proc standard data=lead out=stan mean=0 std=1 print; var x y; data stan; set stan; x = x - 1; proc gplot data=stan; symbol1 c=black v=y h=.8; symbol2 c=black v=x h=.8; title1 'Standardized Leading Indicator vs. Standardized Sales'; title2 'X=Leading Indicator Y=Sales'; axis1 order=(0 to 150 by 10) label=(f=duplex 'Obs'); axis2 order=(-3 to 2 by 1.0) label=(f=duplex 'Lead and Sales'); plot y*obs = 1 x*obs = 2 / overlay haxis=axis1 vaxis=axis2; data stan; set stan; xf1 = lag1(x); xf2 = lag2(x); yf1 = lag1(y); yf2 = lag2(y); x = (lag2(x) + lag1(x) + x + xf1 + xf2)/5; y = (lag2(y) + lag1(y) + y + yf1 + yf2)/5; xs = lag3(x); proc gplot data=stan; symbol1 c=black v=y h=.8; symbol2 c=black v=x h=.8; title1 '"Smoothed" Standardized Leading Indicator vs. "Smoothed" Standardized Sales'; title2 'X="Smoothed" Leading Indicator Y=Sales'; axis1 order=(0 to 150 by 10) label=(f=duplex 'Obs'); axis2 order=(-3 to 2 by 1.0) label=(f=duplex 'Lead and Sales'); plot y*obs = 1 x*obs = 2 / overlay haxis=axis1 vaxis=axis2; proc gplot data=stan; symbol1 c=black v=y h=.8; symbol2 c=black v=xs h=.8; title1 '"Shifted" "Smoothed" Standardized Leading Indicator vs. "Smoothed" Standardized Sales'; title2 'X="Shifted" "Smoothed" Leading Indicator Y=Sales'; axis1 order=(0 to 150 by 10) label=(f=duplex 'Obs'); axis2 order=(-3 to 2 by 1.0) label=(f=duplex 'Lead and Sales'); plot y*obs = 1 xs*obs = 2 / overlay haxis=axis1 vaxis=axis2; proc gplot data=lead; symbol c=black v=y h=.8; title1 'Sales in Out-of-Sample Period'; title2 'Y=Sales'; axis1 order=(120 to 150 by 1) label=(f=duplex 'Obs'); axis2 order=(250 to 270 by 2) label=(f=duplex 'Sales'); plot y*obs / haxis=axis1 vaxis=axis2; proc gplot data=stan; symbol c=black v=y h=.8; title1 '"Smoothed" Standardized Sales in Out-of-Sample Period'; title2 'Y="Smoothed" Standardized Sales'; axis1 order=(120 to 150 by 1) label=(f=duplex 'Obs'); axis2 order=(1 to 1.8 by 0.1) label=(f=duplex 'Standardized Sales'); plot y*obs / haxis=axis1 vaxis=axis2; run;