The HPGENSELECT Procedure

Example 53.3 Tweedie Model

(View the complete code for this example.)

The following HPGENSELECT statements examine the data set getStarted used in the section Getting Started: HPGENSELECT Procedure, but they request that a Tweedie model be fit by using the continuous variable Total as the response instead of the count variable Y. The following statements fit a log-linked Tweedie model to these data by using classification effects for variables C1–C5. In an insurance underwriting context, Y represents the total number of claims in each category that is defined by C1–C5, and Total represents the total cost of the claims (that is, the sum of costs for individual claims). The CODE statement requests that a text file named "Scoring Parameters.txt" be created. This file contains a SAS program that contains information from the model that allows scoring of a new data set based on the parameter estimates from the current model.

proc hpgenselect data=getStarted;
   class C1-C5;
   model Total = C1-C5 / Distribution=Tweedie Link=Log;
   code File='ScoringParameters.txt';
run;

The "Optimizations Stage Details" table in Output 53.3.1 shows the stages used in computing the maximum likelihood estimates of the parameters of the Tweedie model. Stage 1 uses quasi-likelihood and all of the data to compute starting values for stage 2, which uses all of the data and the Tweedie log likelihood to compute the final estimates.

Output 53.3.1: Optimization Stage Details

The HPGENSELECT Procedure

Optimization Stage Details
Optimization
Stage
Optimization
Type
Sampling
Percentage
Observations
Used
1Quasilikelihood100.00100
2Full Likelihood100.00100


The "Parameter Estimates" table in Output 53.3.2 shows the resulting regression model parameter estimates, the estimated Tweedie dispersion parameter, and the estimated Tweedie power.

Output 53.3.2: Parameter Estimates

Parameter Estimates
ParameterDFEstimateStandard
Error
Chi-SquarePr > ChiSq
Intercept13.8889040.43532579.8044<.0001
C1 01-0.0724000.2406130.09050.7635
C1 11-1.3584560.32436317.5400<.0001
C1 210.1547110.2373940.42470.5146
C1 300...
C2 011.3505910.28989721.7050<.0001
C2 111.1592420.27545917.7106<.0001
C2 210.0339210.3032040.01250.9109
C2 300...
C3 01-0.2177630.2724740.63870.4242
C3 11-0.2894250.2597511.24150.2652
C3 21-0.1319610.2767230.22740.6335
C3 300...
C4 01-0.2580690.2888400.79830.3716
C4 11-0.0570420.2875660.03930.8428
C4 210.2196970.2720640.65210.4194
C4 300...
C5 01-1.3146570.25780626.0038<.0001
C5 11-0.9969800.23688117.7138<.0001
C5 21-0.4811850.2356144.17080.0411
C5 300...
Dispersion15.2969660.773401..
Power11.4256250.048981..


Now suppose you want to compute predicted values for some different data. If is a vector of explanatory variables that might not be in the original data and is the vector of estimated regression parameters from the model, then is the predicted value of the mean, where g is the log link function in this case. The following data contain new values of the regression variables C1–C5, from which you can compute predicted values based on information in the SAS program that is created by the CODE statement. This is called scoring the new data set.

data ScoringData;
   input C1-C5;
   datalines;
3 3 1 0 2
1 1 2 2 0
3 2 2 2 0
1 1 2 3 2
1 1 2 3 3
3 1 1 0 1
0 2 1 0 0
2 1 3 1 3
3 2 3 2 0
3 0 2 0 1
;

The following SAS DATA step creates the new data set Scores, which contains a variable P_Total that represents the predicted values of Total, along with the variables C1–C5. The resulting data are shown in Output 53.3.3.

data Scores;
   set ScoringData;
   %inc 'ScoringParameters.txt';
run;
proc print data=Scores;
run;

Output 53.3.3: Predicted Values for Scoring Data

ObsC1C2C3C4C5P_Total
13310217.465
21122011.737
33222014.819
41123221.683
51123335.083
63110133.237
7021007.303
821313171.711
93232016.909
103020147.110