-----LKPDF (LET)--------------------------------
 
LKPDF
 
Name:
    LKPDF (LET)
 
Type:
    Library Function
 
Purpose:
    Compute the Lagrange Katz probability mass function.
 
Description:
    The Lagrange Katz distribution has the following probability
    mass function:

       p(x;a,b,beta)=(a/beta)/((a/beta) + (x*b/beta) + x)*
                     ((a/beta)+x*b/beta+x  x)*
                     beta**x*(1-beta)**((a/beta)+x*b/beta)
                     x = 0, 1, 2, 3, ,... ;
                     a > 0; b > -beta; beta < 1

    The mean and variance are

        mu       = a/(1 - b - beta)
        sigma**2 = a*(1 - beta)/(1 - b - beta)**3


    Consul and Famoye (see Reference section below) discuss the
    application of this distribution to random walks, queuing
    models, gamblers ruin at the nth step, and urn models.

Syntax:
    LET <y> = LKPDF(<x>,<a>,<b>,<b>) 
              <SUBSET/EXCEPT/FOR qualification>
    where <x> is a non-negative integer variable, number, or
               parameter;
          <a> is a number, parameter, or variable that specifies
               the first shape parameter;
          <b> is a number, parameter, or variable that
               specifies the second shape parameter;
          <beta> is a number, parameter, or variable that
               specifies the third shape parameter;
          <y> is a variable or a parameter (depending on what <x>
               is) where the computed Lagrange Katz pdf value is
               stored;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.
 
Examples:
    LET A = LKPDF(0,2,0.2,0.5)
    LET Y = LKPDF(X,A,B,BETA)
    PLOT LKPDF(X,2,0.2,0.5) FOR X = 0  1  20

Note:
    For a number of commands utilizing the Lagrange Katz
    distribution, it is convenient to bin the data.  There are
    two basic ways of binning the data.

      1) For some commands (histograms, maximum likelihood
         estimation), bins with equal size widths are
         required.  This can be accomplished with the
         following commands:

            LET AMIN = MINIMUM Y
            LET AMAX = MAXIMUM Y
            LET AMIN2 = AMIN - 0.5
            LET AMAX2 = AMAX + 0.5
            CLASS MINIMUM AMIN2
            CLASS MAXIMUM AMAX2
            CLASS WIDTH 1
            LET Y2 X2 = BINNED

      2) For some commands, unequal width bins may be
         helpful.  In particular, for the chi-square goodness
         of fit, it is typically recommended that the minimum
         class frequency be at least 5.  In this case, it may
         be helpful to combine small frequencies in the tails.
         Unequal class width bins can be created with the
         commands

            LET MINSIZE = <value>
            LET Y3 XLOW XHIGH = INTEGER FREQUENCY TABLE Y

         If you already have equal width bins data, you can
         use the commands
         
            LET MINSIZE = <value>
            LET Y3 XLOW XHIGH = COMBINE FREQUENCY TABLE Y2 X2

         The MINSIZE parameter defines the minimum class
         frequency.  The default value is 5.

Note:
    You can generate generalized negative binomial random
    numbers, probability plots, and chi-square goodness of fit
    tests with the following commands:

       LET A = <value>
       LET B = <value>
       LET BETA = <value>
       LET Y = LAGRANGE KATZ RANDOM NUMBERS FOR I = 1 1 N

       LAGRANGE KATZ PROBABILITY PLOT Y
       LAGRANGE KATZ PROBABILITY PLOT Y2 X2
       LAGRANGE KATZ PROBABILITY PLOT Y3 XLOW XHIGH

       LAGRANGE KATZ CHI-SQUARE GOODNESS OF FIT Y
       LAGRANGE KATZ CHI-SQUARE GOODNESS OF FIT Y2 X2
       LAGRANGE KATZ CHI-SQUARE GOODNESS OF FIT Y3 XLOW XHIGH

    To obtain the method of moment estimates, the mean and
    zero frequency estimates, and the maximum likelihood
    estimates of a, b, and beta, enter the command

        LAGRANGE KATZ MAXIMUM LIKELIHOOD Y
        LAGRANGE KATZ MAXIMUM LIKELIHOOD Y2 X2

    The moment estimates are:

       betahat = 2 - 0.5*(A +/- SQRT(A*(A-4))
       ahat = 0.5*xbar**(3/2)*(1/SQRT(s2))*
              (SQRT(A) +/- SQRT(A-4))
       bhat = -1 + 0.5*(SQRT(A) +/- SQRT(A-4)*
               (SQRT(A) - SQRT(xbar/s2))

    where

       A    = (3*s2**2 - s3*xbar)**2/(xbar - s2**3)
       xbar = the sample mean
       s2   = the sample variance
       s3   = sample third sample moment
            = SUM[i=0 to k][n(i)*(i-xbar)**3/(n-1)  (binned data)
            = SUM[j=1 to n][(X(j) - xbar)**3]       (unbinned data)

    Note that the moment estimators only exist if A >= 4.

    The moments and zero frequency estimate of beta is the
    solution of the equation:

       (1-beta)*(LOG(1-beta))**2 -
       (beta**2*s/xbar**3)*[LOG(F0)]**2 = 0

    where

       F0  = frequency of the zero class

    The moments and zero frequency estimates of a and b are
    then:

       ahat = SQRT(xbar**3*(1 - betahat)/s2)
       bhat = 1 - betahat - (ahat/xbar)

    The maximum likelihood estimates of b and beta are the
    solutions to the equations:

       n*xbar*LOG(1-beta)/beta - 
       SUM[x=2 to k][SUM[i=1 to x-1]
       [x*n(x)/(xbar*(1-b-beta) + b*x + beta*I)]] = 0

       -n*xbar*(1-beta)*LOG(1-beta)/beta + n*xbar/beta +
       SUM[X=2 to k][SUM[i=1 to x-1]
       [I*n(x)/(xbar*(1-b-beta) + b*x + beta*I)]] = 0

    with n(x) denoting the frequency of the xth class.

    The maximum likelihood estimate of a is then:

       ahat = xbar*(1 - b - beta)

Note:
    Library functions are distinguished from let subcommands
    in the following ways.
    1) Functions enclose the input value in parenthesis.  Let
       subcommands use spaces.
    2) Functions can accept (and return) either parameters
       (i.e., single values) or variables (i.e., an array of
       values) while let subcommands are specific in which they
       accept as input and what they return as output.
    3) Functions can accept expressions while let subcommands
       do not.  For example, the following is legal:
           LET Y2 = ABS(Y1-INT(Y1))
       For let subcommands, you typically have to do something
       like the following:
           LET YTEMP = Y**2 + 8
           LET A = SUM YTEMP
 
Default:
    None
 
Synonyms:
    None
 
Related Commands:
    LKCDF                    = Compute the Lagrange Katz cumulative
                               distribution function.
    LKPPF                    = Compute the Lagrange Katz percent
                               point function.
    GNBPDF                   = Compute the generalized negative
                               binomial probability mass function.
    GLSPDF                   = Compute the generalized logarithmic
                               series probability mass function.
    BNBPDF                   = Compute the beta-negative binomial
                               probability mass function.
    NBPDF                    = Compute the negative binomial
                               probability mass function.
    BINPDF                   = Compute the binomial probability
                               mass function.
    LPOPDF                   = Compute the Lagrange Poisson
                               probability mass function.
    INTEGER FREQUENCY TABLE  = Generate a frequency table at
                               integer values with unequal bins.
    COMBINE FREQUENCY TABLE  = Convert an equal width frequency
                               table to an unequal width frequency
                               table.
    PROBABILITY PLOT         = Generate a probability plot.
    MAXIMUM LIKELIHOOD       = Perform maximum likelihood
                               estimation for a distribution.
 
Reference:
    Consul and Famoye (2006), "Lagrangian Probability
    Distribution", Birkhauser, chapter 10.

    Consul and Famoye (1996), "The Lagrangian Katz Family of
    Distributions", Communications in Statistics--Theory
    and Methods", 25, pp. 415-434.

Applications:
    Distributional Modeling
 
Implementation Date:
    2006/8
 
Program 1:
    title size 3
    tic label size 3
    label size 3
    legend size 3
    height 3
    x1label displacement 12
    y1label displacement 15
    .
    multiplot corner coordinates 0 0 100 95
    multiplot scale factor 2
    label case asis
    title case asis
    case asis
    tic offset units screen
    tic offset 3 3
    title displacement 2
    y1label Probability Mass
    x1label X
    .
    ylimits 0 1
    major ytic mark number 6
    minor ytic mark number 3
    xlimits 0 20
    line blank
    spike on
    .
    multiplot 2 2
    .
    title Theta = 0.3, Beta = 1.8, M =2
    plot gnbpdf(x,0.3,1.8,2) for x = 1 1 20
    .
    title Theta = 0.5, Beta = 1.5, M = 2
    plot gnbpdf(x,0.5,1.5,2) for x = 1 1 20
    .
    title Theta = 0.7, Beta = 1.2, M = 2
    plot gnbpdf(x,0.7,1.2,2) for x = 1 1 20
    .
    title Theta = 0.9, Beta = 1.1, M = 2
    plot gnbpdf(x,0.9,1.1,2) for x = 1 1 20
    .
    end of multiplot
    .
    justification center
    move 50 97
    text Generalized Negative Binomial Probability Mass Functions

Program 2:

