Resources

Model Definition for Burr Distribution

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

                    SAS Sample Library

        Name: svrtburr.sas
 Description: Example Program from SAS/ETS User's Guide,
              The SEVERITY Procedure
       Title: Model Definition for Burr Distribution
     Product: SAS/ETS Software
        Keys: fitting continuous distributions
        PROC: SEVERITY
       Notes: If you run this sample program without any modification, then
              the Sasuser.Svrtdist library contains functions and subroutines
              that are identical to those in the Sashelp.Svrtdist library.
              Further, if you run this sample without any modification to the
              names of functions and subroutines, then PROC FCMP writes
              warnings of the following nature to the SAS log:
              WARNING: Function  was defined in a previous package.
                       Function  as defined in the current program will
                       be used as default when the package is not specified.
              You can ignore such warnings; they appear because the functions
              defined in this sample are already defined in the input library
              Sashelp.Svrtdist.

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

proc fcmp library=sashelp.svrtdist outlib=sasuser.svrtdist.mymodels;
    function BURR_DESCRIPTION() $32;
        length model $32;
        model = "Burr Distribution";
        return(model);
    endsub;

    function BURR_PARMCOUNT();
        return(3);
    endsub;

    function BURR_LOGPDF(x, Theta, Alpha, Gamma);
        /* Theta : Scale */
        /* Alpha : Shape1 */
        /* Gamma : Shape2 */
        if (x >= constant('MACEPS')) then do;
            z = x/Theta;
            logpdf = log(Alpha*Gamma/x) + Gamma*log(z)
                     - (Alpha+1) * log1px(z**Gamma);
            return (logpdf);
        end;
        else
            return (.);
    endsub;
    function BURR_PDF(x, Theta, Alpha, Gamma);
        /* Theta : Scale */
        /* Alpha : Shape1 */
        /* Gamma : Shape2 */
        if (x >= constant('MACEPS')) then do;
            logpdf = BURR_LOGPDF(x, Theta, Alpha, Gamma);
            if (not(missing(logpdf)) and logpdf < 174) then
                return ( exp(logpdf) );
            else
                return ( . );
        end;
        else
            return (0);
    endsub;

    function BURR_LOGCDF(x, Theta, Alpha, Gamma);
        /* Theta : Scale */
        /* Alpha : Shape1 */
        /* Gamma : Shape2 */
        if (x >= constant('MACEPS')) then
            return (log1px(-(1 + (x/Theta)**Gamma)**(-Alpha)));
        else
            return (.);
    endsub;
    function BURR_CDF(x, Theta, Alpha, Gamma);
        /* Theta : Scale */
        /* Alpha : Shape1 */
        /* Gamma : Shape2 */
        if (x >= constant('MACEPS')) then
            return (1- (1 + (x/Theta)**Gamma)**(-Alpha));
        else
            return (0);
    endsub;

    function BURR_LOGSDF(x, Theta, Alpha, Gamma);
        /* Theta : Scale */
        /* Alpha : Shape1 */
        /* Gamma : Shape2 */
        if (x >= constant('MACEPS')) then
            return (-Alpha * log1px((x/Theta)**Gamma));
        else
            return (0);
    endsub;
    function BURR_SDF(x, Theta, Alpha, Gamma);
        /* Theta : Scale */
        /* Alpha : Shape1 */
        /* Gamma : Shape2 */
        if (x >= constant('MACEPS')) then
            return ((1 + (x/Theta)**Gamma)**(-Alpha));
        else
            return (1);
    endsub;

    subroutine BURR_PARMINIT(dim, x[*], nx[*], F[*], Ftype,
                             Theta, Alpha, Gamma);
        outargs Theta, Alpha, Gamma;
        array m[3] / nosymbols;

        /* Assume Gamma=2 and compute Alpha & Theta using Method of Moments */
        call svrtutil_rawmoments(dim, x, nx, 3, m);

        if (missing(m[1])) then do;
            Theta = .;
            Alpha = .;
            Gamma = .;
        end;
        else do;
            t1 = 2*m[3] - 3*m[1]*m[2];

            if (t1 < constant('MACEPS')) then do;
                Theta = sqrt(m[2]);
                Alpha = 2;
                Gamma = 2;
            end;
            else do;
                Theta = sqrt(m[2]*m[3]/t1);
                Alpha = 1 + (m[3]/t1);
                Gamma = 2;
            end;
        end;
    endsub;
quit;