PROC SEVERITY returns "ERROR: Error encountered while initializing parameters" when first custom distribution parameter is constant


If PROC FCMP is used to define a custom distribution under these conditions:

then PROC SEVERITY returns:

ERROR: Error encountered while initializing parameters.
rc = 1999999
ERROR: An exception was encountered while initializing parameters.
This error also occurs with PROC HPSEVERITY under the same conditions.
 

To circumvent the problem, you need to ensure that the first parameter is not a constant parameter. You can do this by redefining the distribution in PROC FCMP with a different order of parameters in the dist_PDF, dist_CDF, and related distribution functions.


The following PROC FCMP and PROC SEVERITY steps illustrate the problem and the circumvention. This example uses a Pareto Type I distribution, where the scale parameter is constant.

Code to illustrate problem:

proc fcmp outlib=work.mydist.par1s;
   function PAR1A_DESCRIPTION() $;
      length model $64;
      model = "Pareto (Type I) Distribution (Scale first and constant)";
      return(model);
   endsub;

   subroutine PAR1A_CONSTANTPARM(Scale); /* constant scale parameter */
   endsub;

   function PAR1A_LOGPDF(x, Scale, Shape); /* scale parameter listed first */
      if (x < Scale) then
         return (.);
      else do;
         return (log(Shape) + Shape*log(Scale) - (Shape+1)*log(x));
      end;
    endsub;

    function PAR1A_CDF(x, Scale, Shape); /* scale parameter listed first */
       if (x < Scale) then
          return (0);
       else
          return (1 - (Scale/x)**Shape);
    endsub;

    subroutine PAR1A_PARMINIT(dim, x[*], nx[*], F[*], Ftype, Scale, Shape); /* scale parameter listed first */
       outargs Scale, Shape;

       Scale = x{1};
       mean = x{1};
       do i=2 to dim;
          Scale = min(Scale,x{i});
          mean = mean + x{i};
       end;

       Shape=mean/(mean-Scale); /* Method of moments estimator */
       if (Shape < 1+2.220446E-16) then
          Shape=.; /* infeasible; let optimizer conclude that */
    endsub;
quit;

options cmplib=(sashelp.svrtdist work.mydist);

 /* Exception since constant parameter is first */
proc severity data=Pareto;
   loss x;
   dist par1a;
run;

Code to illustrate circumvention:

proc fcmp outlib=work.mydist.par1s;
   function PAR1B_DESCRIPTION() $;
      length model $64;
      model = "Pareto (Type I) Distribution (Scale is not first and constant)";
      return(model);
   endsub;

   subroutine PAR1B_CONSTANTPARM(Scale); /* constant scale parameter */
   endsub;


   function PAR1B_LOGPDF(x, Shape, Scale); /* non-constant shape parameter is listed first */
      if (x < Scale) then
         return (.);
      else do;
         return (log(Shape) + Shape*log(Scale) - (Shape+1)*log(x));
      end;
   endsub;

   function PAR1B_CDF(x, Shape, Scale); /* non-constant shape parameter is listed first */
      if (x < Scale) then
         return (0);
      else
        return (1 - (Scale/x)**Shape);
   endsub;

   subroutine PAR1B_PARMINIT(dim, x[*], nx[*], F[*], Ftype, Shape, Scale); /* non-constant shape parameter is listed first */
      outargs Shape, Scale;

      Scale = x{1};
      mean = x{1};
      do i=2 to dim;
         Scale = min(Scale,x{i});
         mean = mean + x{i};
      end;

      Shape=mean/(mean-Scale); /* Method of moments estimator */
      if (Shape < 1+2.220446E-16) then
      Shape=.; /* infeasible; let optimizer conclude that */
   endsub;
quit;

options cmplib=(sashelp.svrtdist work.mydist);

/* There are no problems if a constant parameter is not first. */
proc severity data=Pareto;
   loss x;
   dist par1b;
   run;