Resources

Scale Regression with Rich Regression Effects

/*--------------------------------------------------------------------------

                    SAS Sample Library

        Name: sevex09.sas
 Description: Example Program from SAS/ETS User's Guide,
              The SEVERITY Procedure
       Title: Scale Regression with Rich Regression Effects
     Product: SAS/ETS Software
        Keys: Severity Distribution Modeling
        PROC: SEVERITY
       Notes:

----------------------------------------------------------------------------*/


proc format;
   value genderFmt 1='Female'
                   2='Male';
run;

data losses(keep=gender carType education carSafety income
                 lossAmount deductible limit);
   call streaminit(12345);
   array sx{8} _temporary_;
   array sbeta{9} _TEMPORARY_ (5 0.6 0.4 -0.75 -0.3 0.4 0.7 -0.5 -0.3);

   length carType $8 education $16;
   format gender genderFmt.;

   sigma = 0.5;
   do lossEventId=1 to 2500;
      /* simulate policyholder and vehicle attributes */
      do i=1 to dim(sx);
         sx(i) = 0;
      end;

      if (rand('UNIFORM') < 0.5) then do;
         gender = 1; * female;
         sx(2) = 1;
      end;
      else do;
         gender = 2; * male;
      end;

      if (rand('UNIFORM') < 0.7) then do;
         carInt = 1;
         carType = 'Sedan';
      end;
      else do;
         carInt = 2;
         carType = 'SUV';
         sx(1) = 1;
      end;

      educationLevel = rand('UNIFORM');
      if (educationLevel < 0.5) then do;
         eduInt = 1;
         education = 'High School';
      end;
      else if (educationLevel < 0.85) then do;
         eduInt = 2;
         education = 'College';
         if (carInt=1) then
            sx(8) = 1;
         else
            sx(6) = 1;
      end;
      else do;
         eduInt = 3;
         education = 'AdvancedDegree';
         if (carInt=1) then
            sx(7) = 1;
         else
            sx(5) = 1;
      end;

      carSafety = rand('UNIFORM'); /* scaled to be between 0 & 1 */
      sx(3) = carSafety;

      income = MAX(15000,int(rand('NORMAL', eduInt*30000, 50000)))/100000;
      sx(4) = income;

      /* simulate lognormal severity */
      Mu = sbeta(1);
      do i=1 to dim(sx);
         Mu = Mu + sx(i) * sbeta(i+1);
      end;
      lossAmount = exp(Mu) * rand('LOGNORMAL')**Sigma;
      loglossAmount = log(lossAmount);

      deductible = lossAmount * rand('UNIFORM');
      if (rand('UNIFORM') < 0.25) then
         limit = lossAmount;

      output;
   end;
run;

/* Fit scale regression model with different types of regression effects */
proc severity data=losses outstore=eststore
     print=all plots=none;
   loss lossAmount / lt=deductible rc=limit;
   class carType gender education;
   scalemodel carType gender carSafety income education*carType
              income*gender carSafety*income;
   dist logn;
run;