The CSSM Procedure
Example 13.19 Scenario Analysis Using Scoring
In many data analyses, after you identify and fit a suitable state space model, you need to use the fitted model to predict the response series under different predictor scenarios in the future. You can easily accomplish this by using the scoring functionality that the SCORE statement provides. This example uses the data and the model discussed in the section Getting Started: CSSM Procedure to demonstrate this type of scenario analysis. Recall that the data set, Cigar, contains information about yearly per capita cigarette sales for 46 geographic regions in the United States over the period 1963–1992. The variables lsales, lprice, lndi, and lpimin denote the per capita cigarette sales, price per pack of cigarettes, per capita disposable income, and minimum price in adjoining regions per pack of cigarettes, respectively (all in the natural log scale). The variable year contains the observation year, and the variable region contains an integer from 1 to 46 that serves as the unique identifier of the region. The goal of the analysis is to study the impact of the regressors on smoking behavior and to understand the changes in smoking patterns in different regions over those years. The following model for lsales is fitted:
This example uses this model to predict lsales in the years 1993 and 1994 for three different settings of the predictors lprice, lpimin, and lndi. The first step in this type of scenario analysis is to create a score store in which the necessary context information is saved. The following statements specify and fit this model and also create the required score store:
proc cssm data=mycas.Cigar;
id year interval=year;
obsindex region;
array RegionArray{46} region1-region46;
do i=1 to 46;
RegionArray[i] = (region=i);
end;
trend IrwTrend(ll) cross(matchparm)=(RegionArray) levelvar=0;
irregular wn;
model lsales = lprice lndi lpimin IrwTrend wn;
eval TrendPlusReg = IrwTrend + lprice + lndi + lpimin;
score out=mycas.store;
run;
The score store is specified in the OUT= option of the SCORE statement (score out=mycas.store;). This score store, mycas.store, saves all the context information that is needed for continuing the forecasting process for the years after 1992, based on the fitted model and the history up to 1992.
The score store mycas.store is used to predict lsales in 1993 and 1994 for the following three scenarios:
- Same price:
In this scenario, the predictors retain their values from years 1991 and 1992; that is, the predictor values for 1991 are copied for 1993, and the predictor values for 1992 are copied for 1994. The data table to be scored is named
mycas.same.- Low price:
-
In this scenario, the predictor settings are as follows:
For the year 1993, the values of disposable income (
lndi) are the same as for 1991, and the values oflpriceandlpiminare set to 3.15 for all regions.For the year 1994, the values of disposable income (
lndi) are the same as for 1992, and the values oflpriceandlpiminare set to 3.0 for all regions.
The data table to be scored is named
mycas.low. - High price:
-
In this scenario, the predictor settings are as follows:
For the year 1993, the values of disposable income (
lndi) are the same as for 1991, and the values oflpriceandlpiminare set to 5.5 for all regions.For the year 1994, the values of disposable income (
lndi) are the same as for 1992, and the values oflpriceandlpiminare set to 6.0 for all regions.
The data table to be scored is named
mycas.high.
The following statements create the data tables mycas.same, mycas.low, and mycas.high:
data mycas.same;
set Cigar(where=(year >= '1jan1991'd));
lsales = .;
if year = '1jan1991'd then year = '1jan1993'd;
else year = '1jan1994'd;
run;
data mycas.low;
set Cigar(where=(year >= '1jan1991'd));
lsales = .;
if year = '1jan1991'd then do;
year = '1jan1993'd;
lprice = 3.15;
lpimin = 3.15;
end;
else do;
year = '1jan1994'd;
lprice = 3.0;
lpimin = 3.0;
end;
run;
data mycas.high;
set Cigar(where=(year >= '1jan1991'd));
lsales = .;
if year = '1jan1991'd then do;
year = '1jan1993'd;
lprice = 5.5;
lpimin = 5.5;
end;
else do;
year = '1jan1994'd;
lprice = 6.0;
lpimin = 6.0;
end;
run;
The following statements show how to score these data tables by using the score store mycas.store:
proc cssm data=mycas.same;
score in=mycas.store;
output out=mycas.scoreSame;
run;
proc cssm data=mycas.low;
score in=mycas.store;
output out=mycas.scoreLow;
run;
proc cssm data=mycas.high;
score in=mycas.store;
output out=mycas.scoreHigh;
run;
In each case, the following are true:
The data table to be scored is specified in the DATA= option in the PROC statement.
The score store is specified by using the IN= option in the SCORE statement.
An output table to save the scored rows is specified in the OUT= option in the OUTPUT statement.
Output 13.19.1 shows the forecasts for lsales for the first three regions (Alabama, Arkansas, and Arizona). This table is produced by merging the three output tables (mycas.scoreSame, mycas.scoreLow, and mycas.scoreHigh), by renaming the forecast variables, and by subsetting the rows suitably. As expected, the sales forecasts increase as the prices decrease.
Output 13.19.1: Forecasts under Different Price Settings
| Cigarette Sales Forecasts under Different Price Settings |
| region | year | sales_highPrice | sales_samePrice | sales_lowPrice |
|---|---|---|---|---|
| Alabama | 1993 | 4.59 | 4.73 | 5.26 |
| Arizona | 1993 | 4.19 | 4.33 | 4.87 |
| Arkansas | 1993 | 4.74 | 4.88 | 5.41 |
| Alabama | 1994 | 4.47 | 4.71 | 5.33 |
| Arizona | 1994 | 4.02 | 4.27 | 4.87 |
| Arkansas | 1994 | 4.65 | 4.87 | 5.50 |