The GENMOD Procedure

Example 45.12 Tweedie Regression

(View the complete code for this example.)

The following SAS statements simulate 250 observations, which are based on an underlying Tweedie generalized linear model (GLM) that exploits its connection with the compound Poisson distribution. A natural logarithm link function is assumed for modeling the response variable (yTweedie), and there are five categorical variables (C1–C5), each of which has four numerical levels and two continuous variables (D1 and D2). By design, two of the categorical variables, C3 and C4, and one of the two continuous variables, D2, have no effect on the response. The dispersion parameter is set to 0.5, and the power parameter is set to 1.5.

%let nObs = 250;
%let nClass = 5;
%let nLevs = 4;
%let seed = 100;

data tmp1;
   array c{&nClass};

   keep c1-c&nClass yTweedie d1 d2;

   /* Tweedie parms */
   phi=0.5;
   p=1.5;

   do i=1 to &nObs;

      do j=1 to &nClass;
         c{j} = int(ranuni(1)*&nLevs);
      end;

      d1 = ranuni(&seed);
      d2 = ranuni(&seed);

      xBeta   =  0.5*((c2<2) - 2*(c1=1) + 0.5*c&nClass + 0.05*d1);
      mu      =  exp(xBeta);

      /* Poisson distributions parms */
      lambda = mu**(2-p)/(phi*(2-p));
      /* Gamma distribution parms */
      alpha = (2-p)/(p-1);
      gamma = phi*(p-1)*(mu**(p-1));

      rpoi = ranpoi(&seed,lambda);
      if rpoi=0 then yTweedie=0;
      else do;
         yTweedie=0;
         do j=1 to rpoi;
         yTweedie = yTweedie + rangam(&seed,alpha);
         end;
         yTweedie = yTweedie * gamma;
      end;
      output;
   end;
run;

The following SAS statements invoke PROC GENMOD to fit the Tweedie GLM with the log link using all of the categorical and continuous variables. A Type III analysis is requested by the TYPE3 option in the MODEL statement.

proc genmod data=tmp1;
   class C1-C5;
   model yTweedie = C1-C5 D1 D2 / dist=Tweedie type3;
run;

The "Criteria For Assessing Goodness Of Fit" table is displayed in Output 45.12.1. The scaled Pearson is close to 1, indicating that the specified model fits the data well.

Output 45.12.1: Tweedie Goodness of Fit Criteria

The GENMOD Procedure

Criteria For Assessing Goodness Of Fit
CriterionDFValueValue/DF
Pearson Chi-Square232101.91240.4393
Scaled Pearson X2232251.58261.0844
Log Likelihood -297.2106 
Full Log Likelihood -297.2106 
AIC (smaller is better) 634.4212 
AICC (smaller is better) 638.0893 
BIC (smaller is better) 704.8504 


The "LR Statistics For Type 3 Analysis" table is displayed in Output 45.12.2. As expected, the p-values for C3, C4, and d2 are not statistically significant at the level.

Output 45.12.2: Type III Analysis of Covariate Effects

LR Statistics For Type 3 Analysis
SourceDFChi-SquarePr > ChiSq
c1385.46<.0001
c2348.18<.0001
c330.560.9050
c439.380.0247
c5347.76<.0001
d110.000.9595
d211.310.2518


You can fix the power parameter for fitting the Tweedie GLM by using the P= option. The following SAS statements fit the model for C1, C2 and D1, while holding the power parameter at 1.5:

proc genmod data=tmp1;
   class C1 C2;
   model yTweedie = C1 C2 D1 / dist=Tweedie(p=1.5) type3;
run;

The parameter estimates are displayed in Output 45.12.3.

Output 45.12.3: Tweedie Maximum Likelihood Parameter Estimates

The GENMOD Procedure

Analysis Of Maximum Likelihood Parameter Estimates
Parameter DFEstimateStandard
Error
Wald 95% Confidence LimitsWald Chi-SquarePr > ChiSq
Intercept 10.34400.13470.08010.60806.530.0106
c101-0.07220.1101-0.28800.14360.430.5120
c111-0.89520.1196-1.1296-0.660756.01<.0001
c1210.07700.1073-0.13340.28730.510.4733
c1300.00000.00000.00000.0000..
c2010.61380.11610.38620.841427.93<.0001
c2110.51030.11500.28490.735619.70<.0001
c2210.10010.1215-0.13800.33810.680.4099
c2300.00000.00000.00000.0000..
d1 1-0.02110.1493-0.31360.27140.020.8876
Dispersion 10.49510.03980.41720.5731  
Power 01.50000.00001.50001.5000  

Note:The Tweedie dispersion parameter was estimated by maximum likelihood.
Note:The Tweedie power parameter was held fixed.