GENSELECT Procedure

Poisson Regression for Count Data

(View the complete code for this example.)

Note: Input data must be in a CAS table that is accessible in your CAS session. You must refer to this table by using a two-level name. The first level must be a CAS engine libref, and the second level must be the table name. For more information, see the sections Using CAS Sessions and CAS Engine Librefs and Loading a SAS Data Set onto a CAS Server in Chapter 2, Shared Concepts.

This example illustrates how you can use PROC GENSELECT to perform Poisson regression for count data. The following DATA step creates the data table getStarted, which consists of 100 observations on a count response variable (Y); a continuous variable (Total) to be used in a later analysis; and five categorical variables (C1–C5), each of which has four numerical levels:

data mylib.getStarted;
  input C1-C5 Y Total;
  datalines;
0 3 1 1 3 2 28.361
2 3 0 3 1 2 39.831
1 3 2 2 2 1 17.133
1 2 0 0 3 2 12.769
0 2 1 0 1 1 29.464
0 2 1 0 2 1 4.152
1 2 1 0 1 0 0.000
0 2 1 1 2 1 20.199
1 2 0 0 1 0 0.000
0 1 1 3 3 2 53.376
2 2 2 2 1 1 31.923
0 3 2 0 3 2 37.987
2 2 2 0 0 1 1.082
0 2 0 2 0 1 6.323
1 3 0 0 0 0 0.000
1 2 1 2 3 2 4.217
0 1 2 3 1 1 26.084
1 1 0 0 1 0 0.000
1 3 2 2 2 0 0.000
2 1 3 1 1 2 52.640
1 3 0 1 2 1 3.257
2 0 2 3 0 5 88.066
2 2 2 1 0 1 15.196
3 1 3 1 0 1 11.955
3 1 3 1 2 3 91.790
3 1 1 2 3 7 232.417
3 1 1 1 0 1 2.124
3 1 0 0 0 2 32.762
3 1 2 3 0 1 25.415
2 2 0 1 2 1 42.753
3 3 2 2 3 1 23.854
2 0 0 2 3 2 49.438
1 0 0 2 3 4 105.449
0 0 2 3 0 6 101.536
0 3 1 0 0 0 0.000
3 0 1 0 1 1 5.937
2 0 0 0 3 2 53.952
1 0 1 0 3 2 23.686
1 1 3 1 1 1 0.287
2 1 3 0 3 7 281.551
1 3 2 1 1 0 0.000
2 1 0 0 1 0 0.000
0 0 1 1 2 3 93.009
0 1 0 1 0 2 25.055
1 2 2 2 3 1 1.691
0 3 2 3 1 1 10.719
3 3 0 3 3 1 19.279
2 0 0 2 1 2 40.802
2 2 3 0 3 3 72.924
0 2 0 3 0 1 10.216
3 0 1 2 2 2 87.773
2 1 2 3 1 0 0.000
3 2 0 3 1 0 0.000
3 0 3 0 0 2 62.016
1 3 2 2 1 3 36.355
2 3 2 0 3 1 23.190
1 0 1 2 1 1 11.784
2 1 2 2 2 5 204.527
3 0 1 1 2 5 115.937
0 1 1 3 2 1 44.028
2 2 1 3 1 4 52.247
1 1 0 0 1 1 17.621
3 3 1 2 1 2 10.706
2 2 0 2 3 3 81.506
0 1 0 0 2 2 81.835
0 1 2 0 1 2 20.647
3 2 2 2 0 1 3.110
2 2 3 0 0 1 13.679
1 2 2 3 2 1 6.486
3 3 2 2 1 2 30.025
0 0 3 1 3 6 202.172
3 2 3 1 2 3 44.221
0 3 0 0 0 1 27.645
3 3 3 0 3 2 22.470
2 3 2 0 2 0 0.000
1 3 0 2 0 1 1.628
1 3 1 0 2 0 0.000
3 2 3 3 0 1 20.684
3 1 0 2 0 4 108.000
0 1 2 2 1 1 4.615
0 2 3 2 2 1 12.461
0 3 2 0 1 3 53.798
2 1 1 2 0 1 36.320
1 0 3 0 0 0 0.000
0 0 3 2 0 1 19.902
0 2 3 1 0 0 0.000
2 2 2 1 3 2 31.815
3 3 3 0 0 0 0.000
2 2 1 3 3 2 17.915
0 2 3 2 3 2 69.315
1 3 1 2 1 0 0.000
3 0 1 1 1 4 94.050
2 1 1 1 3 6 242.266
0 2 0 3 2 1 40.885
2 0 1 1 2 2 74.708
2 2 2 2 3 2 50.734
1 0 2 2 1 3 35.950
1 3 3 1 1 1 2.777
3 1 2 1 3 5 118.065
0 3 2 1 2 0 0.000
;

These statements assume that your libref is named mylib, but you can substitute any appropriately defined libref.

The following statements fit a log-linked Poisson model to these data by using classification effects for the variables C1–C5:

proc genselect data=mylib.getStarted;
   class C1-C5;
   model Y = C1-C5 /  Distribution=Poisson Link=Log;
run;

The output from this analysis is presented in Figure 1 through Figure 7.

Figure 1 displays the "Model Information" table. The variable Y is an integer-valued variable that is modeled by using a Poisson probability distribution, and the mean of Y is modeled by using a log link function. The GENSELECT procedure uses a Newton-Raphson algorithm to fit the model. The CLASS variables C1–C5 are parameterized by using GLM parameterization, which is the default.

Figure 1: Model Information

The GENSELECT Procedure

Model Information
Data SourceGETSTARTED
Response VariableY
DistributionPoisson
Link FunctionLog
Optimization TechniqueNewton-Raphson with Ridging


Each of the CLASS variables C1–C5 has four unique formatted levels, which are displayed in the "Class Level Information" table in Figure 2.

Figure 2: Class Level Information

Class Level Information
ClassLevelsValues
C140 1 2 3
C240 1 2 3
C340 1 2 3
C440 1 2 3
C540 1 2 3


Figure 3 displays the "Number of Observations" table. All 100 observations in the data set are used in the analysis.

Figure 3: Number of Observations

Number of Observations Read100
Number of Observations Used100


Figure 4 displays the "Dimensions" table for this model. This table summarizes some important sizes of various model components. For example, it shows that there are 21 columns in the design matrix bold upper X: 1 column for the intercept and 20 columns for the effects that are associated with the classification variables C1–C5. However, the rank of the crossproducts matrix is only 16. Because the classification variables C1–C5 use GLM parameterization and because the model contains an intercept, there is one singularity in the crossproducts matrix of the model for each classification variable. Consequently, only 16 parameters enter the optimization.

Figure 4: Dimensions in Poisson Regression

Dimensions
Columns in Design21
Number of Effects6
Max Effect Columns4
Rank of Design16
Parameters in Optimization16


Figure 5 displays the final convergence status of the Newton-Raphson algorithm. The FCONV= convergence criterion is satisfied.

Figure 5: Convergence Status

Convergence criterion (FCONV=1E-7) satisfied.


The "Fit Statistics" table is shown in Figure 6. The –2 log likelihood at the converged estimates is 290.16169. You can use this value to compare the model to nested model alternatives by means of a likelihood ratio test. To compare models that are not nested, information criteria such as AIC (Akaike’s information criterion), AICC (Akaike’s bias-corrected information criterion), and BIC (Schwarz Bayesian information criterion) are used. These criteria penalize the –2 log likelihood for the number of parameters.

Figure 6: Fit Statistics

Fit Statistics
-2 Log Likelihood290.16169
AIC (smaller is better)322.16169
AICC (smaller is better)328.71590
SBC (smaller is better)363.84441


The "Parameter Estimates" table in Figure 7 shows that many parameters have fairly large p-values, indicating that one or more of the model effects might not be necessary.

Figure 7: Parameter Estimates

Parameter Estimates
ParameterDFEstimateStandard
Error
Chi-SquarePr > ChiSq
Intercept10.8819040.3827305.30950.0212
C1 01-0.1960020.2114820.85900.3540
C1 11-0.6051610.2635085.27420.0216
C1 21-0.0684580.2107760.10550.7453
C1 300...
C2 010.9611170.25548514.15210.0002
C2 110.7081880.2467688.23600.0041
C2 210.1617410.2663650.36870.5437
C2 300...
C3 01-0.2270160.2525610.80790.3687
C3 11-0.0947750.2295190.17050.6797
C3 210.0448010.2381270.03540.8508
C3 300...
C4 01-0.2804760.2635891.13220.2873
C4 110.0281570.2496520.01270.9102
C4 210.0478030.2403780.03950.8424
C4 300...
C5 01-0.8179360.21990113.83510.0002
C5 11-0.7105950.20626511.86840.0006
C5 21-0.6020800.2177247.64710.0057
C5 300...


Last updated: September 22, 2026