SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Contacts SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 1 Auxiliary Chapter

EXACT BINOMIAL CONFIDENCE LIMITS

Name:
    EXACT BINOMIAL CONFIDENCE LIMITS (LET)
Type:
    Let Subcommand
Purpose:
    Compute the exact binomial confidence limits for a binomial proportion.
Description:
    The binomial proportion is defined as the number of successes divided by the number of trials.

    Confidence intervals for the binomial proportion can be computed using one of the following methods:

    1. the most common method is based on the normal approximation

        phat +/- z(alpha/2)*SQRT[(phat*(1-phat))/n]

    2. the Agresti-Coull method (HELP AGRESTI COULL for details) In most cases, this is the recommended method to use.

    3. an exact method based on the binomial distribution. This is the method discussed here.

    If either the number of failures or the sample size is small, the commonly used symmetrical confidence limits based on the normal approximation may not be accurate enough. In that case, the following exact method can be used.

    1. Solve the equation

        BINCDF(x;p(u),n) = alpha/2

      for pu to obtain the upper 100(1 - alpha)% limit for p where BINCDF is the cumulative distribution function of the binomial distribution, x is the number of successes, and n is the number of trials.

    2. Next solve the equation

        BINCDF(x-1;p(l),n) = 1 - alpha/2

      for pl to obtain the lower 100(1 - alpha)% limit for p.

    Note that these intervals are not symetric about p.

    One-sided intervals can be computed by replacing z(alpha/2) by z(alpha) in the above equations.

Syntax 1:
    LET <lowlim> <upplim> = EXACT BINOMIAL CONFIDENCE LIMITS
                            <p> <n> <alpha>
                            <SUBSET/EXCEPT/FOR qualification>
    where <p> is constant, parameter, or variable that contains the proportion of successes;
                <n> is constant, parameter, or variable that contains the number of trials;
                <alpha> is constant or parameter that contains the significance level;
                <lowlim> is a variable that contains the computed lower exact binomial confidence limit;
                <upplim> is a variable that contains the computed upper exact binomial confidence limit;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    The <p> and <n> arguments can be either parameters or variables. If they are both variables, then the variables must have the same number of elements. The <alpha> argument is always assumed to be either a constant or a parameter.

    If <p> and <n> are both parameters, then <lowlim> and <upplim> will be parameters. Otherwise, they will be variables.

Syntax 2:
    LET <lowlim> = EXACT BINOMIAL LOWER LIMITS <p> <n> <alpha>
                            <SUBSET/EXCEPT/FOR qualification>
    where <p> is constant, parameter, or variable that contains the proportion of successes;
                <n> is constant, parameter, or variable that contains the number of trials;             <lowlim> is a variable that contains the computed lower exact binomail confidence limit;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    The <p> and <n> arguments can be either parameters or variables. If they are both variables, then the variables must have the same number of elements. The <alpha> argument is always assumed to be either a constant or a parameter.

    If <p> and <n> are both parameters, then >lowlim> will be a parameter. Otherwise, it will be a variable.

Syntax 3:
    LET <upplim> = EXACT BINOMIAL LOWER LIMITS <p> <n> <alpha>
                            <SUBSET/EXCEPT/FOR qualification>
    where <p> is constant, parameter, or variable that contains the proportion of successes;
                <n> is constant, parameter, or variable that contains the number of trials;
                <alpha> is constant or parameter that contains the significance level;
                <upplim> is a variable that contains the computed upper exact binomail confidence limit;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    The <p> and <n> arguments can be either parameters or variables. If they are both variables, then the variables must have the same number of elements. The <alpha> argument is always assumed to be either a constant or a parameter.

    If <p> and <n> are both parameters, then <upplim> will be a parameter. Otherwise, it will be a variable.

Examples:
    LET AL AU = EXACT BINOMIAL CONFIDENCE LIMITS P N ALPHA
    LET AL = EXACT BINOMIAL LOWER LIMITS P N ALPHA
    LET AU = EXACT BINOMIAL UPPER LIMITS P N ALPHA
    LET AL AU = EXACT BINOMIAL CONFIDENCE LIMITS P N ALPHA ...
                            SUBSET TAG > 2
Note:
    If you would like to use this command on raw data (i.e., you have a variable containing a sequence of 0's and 1's), do something like the following

      LET YSUM = SUM Y
      LET NTRIAL = SIZE Y
      LET P = YSUM/NTRIAL
      LET AL AU = EXACT BINOMIAL CONFIDENCE LIMITS P NTRIAL ALPHA

    If you have a group-id variable (X), you would do something like

      SET LET CROSS TABULATE COLLAPSE
      LET YSUM = CROSS TABULATE SUM Y X
      LET NTRIAL = CROSS TABULATE SIZE Y X
      LET P = YSUM/NTRIAL
      LET AL AU = EXACT BINOMIAL CONFIDENCE LIMITS P NTRIAL ALPHA

    In this case, P and NTRIAL are now variables rather than parameters.

Note:
    The following commands are also available:

      LET A = TWO SIDED LOWER EXACT BINOMIAL Y
      LET A = TWO SIDED UPPER EXACT BINOMIAL Y
      LET A = ONE SIDED LOWER EXACT BINOMIAL Y
      LET A = ONE SIDED UPPER EXACT BINOMIAL Y

    This command is a Statistics Let Subcommand rather than a Math LET Subcommand. The distinctions are:

    1. The "Statistics" version of the command returns a single parameter value while the "Math" version of the command returns either one or two variables or one or two parameters.

    2. The "Statistics" version of the command can be used with a number of other commands (see the Note above) while the "Math" version of the command cannot.

      For example, the "Statistics" version of the command is most typically used with the FLUCTUATION PLOT, CROSS TABULATE, and STATISTIC PLOT commands.

    3. The "Statistics" version of the command expects a single variable (containing a sequence of 1's and 0's). The "Math" version expects summary data (i.e., P and N). The P and N can be either constants, parameters, or variables (or even a mix of these).

    Which form of the command to use is determined by the context of what you are trying to do.

    For details on the "Statistics" version of the command, enter

Default:
    None
Synonyms:
    BINOMIAL EXACT is a synonym for BINOMIAL EXACT
    CONFIDENCE is a synonym for CONFIDENCE LIMITS
    CONFIDENCE INTERVAL is a synonym for CONFIDENCE LIMITS
Related Commands: Reference: Applications:
    Statistics
Implementation Date:
    2008/3: One-sided limits implemented
    2010/10: Two-sided limits implemented
Program:
     
    LET N = 25
    LET P = 0.8
    LET ALPHA = 0.95
    LET AL AU = EXACT BINOMIAL CONFIDENCE LIMITS P N ALPHA
        
    The returned value of AL and AU are 0.592962 and 0.9316878.

Date created: 10/5/2010
Last updated: 10/5/2010
Please email comments on this WWW page to alan.heckert@nist.gov.