CSSM Procedure

Getting Started: CSSM Procedure

This example illustrates how you can use the CSSM procedure to analyze a panel of time series. The following 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 between 1 to 46 that serves as the unique identifier for the region. For additional data description see Baltagi and Levin (1992); Baltagi (1995).

data cigar;
    input year region lsales lprice lndi lpimin;
    label lsales = 'Log cigarette sales in packs per capita';
    label lprice = 'Log price per pack of cigarettes';
    label lndi = 'Log per capita disposable income';
    label lpimin = 'Log minimum price in adjoining regions
                     per pack of cigarettes';
    year = intnx( 'year', '1jan63'd, year-63 );
    format year year.;
datalines;
63 1 4.54223 3.35341 7.3514 3.26194
63 2 4.82831 3.17388 7.5729 3.21487
63 3 4.63860 3.29584 7.3000 3.25037
63 4 4.95583 3.23080 7.9288 3.17388
63 5 5.05114 3.28840 7.9772 3.26576

   ... more lines ...   

The following statements load the Cigar data into the table mylib.Cigar:

/* Load data into mylib */
data mylib.Cigar;
   set Cigar;
run;

The goal of the analysis is to study the impact of the regressors on the smoking behavior and to understand the changes in the smoking patterns in different regions over the years. Consider the following model for lsales:

sans-serif l sans-serif s sans-serif a sans-serif l sans-serif e sans-serif s Subscript i comma t Baseline equals mu mu Subscript i comma t Baseline plus sans-serif l sans-serif p sans-serif r sans-serif i sans-serif c sans-serif e beta beta 1 plus sans-serif l sans-serif n sans-serif d sans-serif i beta beta 2 plus sans-serif l sans-serif p sans-serif i sans-serif m sans-serif i sans-serif n beta beta 3 plus epsilon epsilon Subscript i comma t

This model represents lsales in a region i and in a year t as a sum of region-specific trend components mu mu Subscript i comma t, the regression effects due to lprice, lndi, and lpimin, and the observation noise epsilon epsilon Subscript i comma t. Different variations of this model are obtained by considering different models for the trend component mu mu Subscript i comma t. Proper modeling of the trend component is important because it captures differences between the regions that result from unrecorded factors such as demographic changes over time, results of anti-smoking campaigns, and so on. The following statements specify and fit one such model:

 proc cssm data=mylib.Cigar  plots=residual;
    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;
    output out=mylib.forCigar pdv press;
 run;

The PROC CSSM statement specifies the input table, mylib.Cigar, which contains analysis variables such as the response variable, lsales, and the predictor variables, lprice, lndi, and lpimin. The PLOTS=RESIDUAL option in the PROC CSSM statement produces residual diagnostic plots. The ID statement specifies a numeric index variable (often a SAS date or datetime variable), which is year in this case. The INTERVAL=YEAR option in the ID statement indicates that the measurements are collected yearly. In this example, the ID variable (year) by itself is not enough to uniquely index each observation in the input table. In such cases, in order to ensure the repeatability of the analysis, you must supply a variable by using the OBSINDEX statement (obsindex region;) that, together with the ID variable, uniquely indexes each observation in the input table.

The next few statements define a 46-dimensional array of dummy variables, RegionArray, such that RegionArray[i] is 1 if region is i and is 0 otherwise. The next three statements, TREND, IRREGULAR, and MODEL, constitute the model specification part of the program:

  • trend IrwTrend(ll) cross(matchparm)=(RegionArray) levelvar=0; defines a trend, named IrwTrend, of local linear type (which is signified by the keyword ll used within the parenthesis after the name). A local linear trend—a trend with time-varying level and time-varying slope—depends on two parameters: the disturbance variance of the level equation and the disturbance variance of the slope equation (see the section Local Linear Trend for more information). The LEVELVAR=0 specification fixes the disturbance variance of the level equation to 0, which results in a trend model called an integrated random walk (IRW). An IRW model tends to produce a smoother trend than a general local linear trend. In the limiting case, if the disturbance variance of the slope equation is also 0, the IRW trend reduces to a straight line (with a fixed intercept and slope). In addition, because of the use of the 46-dimensional array, RegionArray, in the CROSS= option (cross(matchparm)=(RegionArray)), this trend specification amounts to fitting a separate IRW trend for each region. This is because, as a result of the CROSS= option, IrwTrend is treated as a linear combination of 46 (the number of variables in RegionArray) stochastically independent, integrated random walks,

    IrwTrend Subscript t Baseline equals sigma-summation Underscript i equals 1 Overscript 46 Endscripts RegionArray left-bracket i right-bracket mu mu Subscript i comma t Baseline

    where each mu mu Subscript i comma t is an integrated random walk. Note that since RegionArray[i] is a binary variable, IrwTrend equals mu mu Subscript i comma t when region is i. Lastly, the use of MATCHPARM option specifies that the different IRW trends mu mu Subscript i comma t use the same disturbance variance parameter for their slope equation. This is done mainly for parsimony. Based on the model diagnostics shown later, this appears to be a reasonable model simplification.

  • irregular wn; defines the observation noise epsilon epsilon Subscript i comma t, named wn, as a sequence of independent, identically distributed, zero-mean, Gaussian variables—a white noise sequence.

  • model lsales = lprice lndi lpimin IrwTrend wn; defines the model for lsales as a sum of regression effects that involve lprice, lndi, and lpimin, a trend term, IrwTrend, and the observation noise wn.

The last two statements, EVAL and OUTPUT, control certain aspects of the procedure output. The following EVAL statement defines a linear combination, named TrendPlusReg, of selected terms in the MODEL statement:

  eval TrendPlusReg = IrwTrend + lprice + lndi + lpimin;

This EVAL statement causes the CSSM procedure to produce an estimate of TrendPlusReg (and its standard error), which can then be printed or output to a data set. TrendPlusReg contains all the terms in the model except for the observation noise and thus can be regarded as the explanatory part of the model. In the OUTPUT statement, you can specify an output data set that stores all the component estimates that are produced by the procedure. The following OUTPUT statement specifies mylib.forCigar as the output data set:

output out=mylib.forCigar pdv press;

The PDV option causes variables such as region1–region46, which are defined by the DATA step statements within the CSSM procedure, also to be included in the output data set. The PRESS option causes the printing of fit measures that are based on the delete-one cross validation errors (see the section Delete-One Cross Validation and Structural Breaks for more information).

All the models that are specified in the CSSM procedure possess a state space representation. For more information, see the section State Space Model and Notation. The CSSM procedure output begins with a table (not shown here) of the input data set that provides the name and other information. Next, the "Model Summary" table, shown in Figure 1, provides basic model information, such as the following:

  • the dimension of the underlying state equation, 92 (because each of the 46 IRW trends mu mu Subscript i comma t contributes two elements to the state)

  • the diffuse dimension of the model, 95 (which is equal to the three regressors plus the 92 diffuse initial states of mu mu Subscript i comma t)

  • the number of model parameters, 2 (which is the common disturbance variance of the slope equation in IrwTrend and the variance of the noise term wn)

This information is very useful in determining the computational complexity of the model (the larger state size, 92, explains the relatively long computing time—as much as two minutes on some desktops—for this example).

Figure 1: Summary of the Underlying State Space Model

Model Summary
Number of Model Equations1
State Dimension92
Dimension of the Diffuse Initial Condition95
Number of Parameters2


The index variable information is shown in Figure 2. Among other things, it categorizes the data to be of the type Regular with Replication, which implies that the data are regularly spaced with respect to the ID variable and at least some observations have the same ID value. This is clearly true in this example: the data are yearly without any gaps, and there are 46 observations in each year—one per region.

Figure 2: Index Variable Information

ID Variable Information
NameStartEndMaximum
Delta
Distinct
Values
Type
year196319921.000030Regular with Replication


Figure 3 provides simple summary information about the response variable. It shows that lsales has no missing values and no induced missing values because the predictors in the model, lprice, lndi, and lpimin, do not have any missing values either.

Figure 3: Response Variable Summary

Response Variable Information
NameNumber of ObservationsMinimumMaximumMeanStandard
Deviation
TotalMissingInduced
Missing
lsales1380003.9785.6974.7930.2246


The regression coefficients of lprice, lndi, and lpimin are shown in Figure 4. As expected, the coefficient of lprice is negative and the coefficients of lndi and lpimin are positive, all being statistically significant. This is consistent with the expectation that the cigarette sales are adversely affected by the price and are positively correlated with the disposable income. The estimated effect of lpimin, called the bootlegging effect by Baltagi and Levin (1992), is statistically significant but smaller than the effects of lprice and lndi.

Figure 4: Estimated Regression Coefficients

Regression Parameter Estimates
ResponseRegressorEstimateStandard
Error
t ValuePr > |t|
lsaleslprice-0.34800.0232-15.01<.0001
lsaleslndi0.14250.03444.15<.0001
lsaleslpimin0.06190.02692.300.0214


Figure 5: Estimated Model Parameters

Model Parameter Estimates
ComponentTypeParameterEstimateStandard
Error
t Value
IrwTrendLL TrendSlope Variance0.00020.00007.72
wnIrregularVariance0.00060.000017.29


Figure 5 shows the estimates of the disturbance variance of the slope equation in IrwTrend and the variance of the noise term wn.

Figure 6 shows a panel of residual normality diagnostic plots. These plots show that the residuals are symmetrically distributed but contain slightly larger than expected number of extreme residuals. Figure 7 shows the plot of residuals versus time. There the residuals do not exhibit any obvious pattern; however, the plot does show that more extreme residuals appear before 1970 and after 1989. On the whole, however, these plots do not exhibit serious violations of model assumptions.

Figure 6: Residual Normality Check

Residual Normality Check


Figure 7: Standardized Residuals Plotted against Time

Standardized Residuals Plotted against Time


Figure 8 shows the details of the likelihood computations such as the number of nonmissing response values used and the likelihood of the fitted model. For more information, see the section Likelihood Computation and Model-Fitting Phase. Figure 8 shows the likelihood-based information criteria in lower-is-better format, which are useful for model comparison.

Figure 8: Likelihood Computation Details

Likelihood Computation Summary
Nonmissing Response Values Used1380
Estimated Parameters2
Initialized Diffuse State Elements95
Normalized Residual Sum of Squares1285
Diffuse Log Likelihood2246
Profile Log Likelihood2170


Figure 9: Information Criteria

Information Criteria
StatisticDiffuse LikelihoodProfile Likelihood
AIC (lower is better)-4488-4145
BIC (lower is better)-4478-3638
AICC (lower is better)-4488-4130
HQIC (lower is better)-4484-3955
CAIC (lower is better)-4476-3541


In addition to the regression estimates, it is useful to analyze the estimates of different model components such as the trend component IrwTrend and the linear combination TrendPlusReg. These estimates can be printed by using the PRINT= option provided in the TREND and EVAL statements, or they can be output to a data set (as it is done in this illustration). This latter option is particularly useful for graphical exploration of these components by standard graphical procedures such as SGPLOT and SGPANEL procedures. The following statements produce a panel of plots that shows how well the proposed model fits the observed cigarette sales in the first three regions, which correspond to Alabama, Arizona, and Arkansas. The output data set, mylib.forCigar, contains all the needed information: Smoothed_TrendPlusReg contains the smoothed (full-sample) estimate of TrendPlusReg, and Smoothed_Lower_TrendPlusReg and Smoothed_Upper_TrendPlusReg contain its 95% lower and upper confidence limits. In addition, for easy readability, a user-defined format (RegionFormat), which is created by using the FORMAT procedure (not shown), is used to associate the region names to region values.

proc sgpanel data=mylib.forCigar noautolegend;
   where region <= 3;
   format region RegionFormat.;
   title 'Region-Specific Sales Patterns with 95% Confidence Band';
   panelby region / columns=3;
   band x=year lower=Smoothed_Lower_TrendPlusReg
   upper=Smoothed_Upper_TrendPlusReg;
   scatter x=year y=lsales;
   series x=year y= Smoothed_TrendPlusReg;
run;

Figure 10: Cigarette Sales Patterns for the First Three Regions

Cigarette Sales Patterns for the First Three Regions


Figure 10 seems to indicate that the model fits the data reasonably well. It also shows that Arizona differs markedly from Alabama and Arkansas in its cigarette sales pattern over the years. The following statements produce a similar panel of plots that show the estimate of trend without the regression effects:

proc sgpanel data=mylib.forCigar noautolegend;
   where region <= 3;
   format region RegionFormat.;
   title 'Region-Specific Trend Estimates';
   panelby region / columns=3;
   series x=year y= smoothed_IrwTrend;
run;

Figure 11: Estimate of IrwTrend for the First Three Regions

Estimate of  for the First Three Regions


The trend patterns, shown in Figure 11, seem to suggest that after accounting for the regression effects, per capita cigarette sales were on the rise in Alabama and Arkansas while they were declining in Arizona.

Last updated: November 24, 2025