SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

DIFFERENCE OF PROPORTION HYPOTHESIS TEST

Name:
    DIFFERENCE OF PROPORTION HYPOTHESIS TEST (LET)
Type:
    LET Subcommand
Purpose:
    Return the p-value for a large sample hypothesis test for the equality of two binomial proportions.
Description:
    Given a set of N1 observations in a variable X1 and a set of N2 observations in a variable X2, we can compute a normal approximation test that the two proportions are equal (or alternatively, that the difference of the two proportions is equal to 0). In the following, let p1 and p2 be the population proportion of successes for samples one and two, respectively.

    The hypothesis test that the two binomial proportions are equal is

      H0: p1 = p2
      Ha: p1p2
      Test Statistic: \( Z = \frac{\hat{p_1} - \hat{p_2}} {\sqrt{\hat{p}(1 - \hat{p})(1/n_1 + 1/n_2)}} \)

      where \( \hat{p} \) is the proportion of successes for the combined sample and

      \( \begin{array}{lcl} \hat{p} & = & \frac{n_1 \hat{p_1} + n_2 \hat{p_2}} {n_1 + n_2} \\ & = & \frac{X_1 + X_2}{n_1 + n_2} \end{array} \)

      Significance Level: \( \alpha \)
      Critical Region: For a two-tailed test

      \( Z > \Phi^{-1}(1 - \alpha/2) \)
      \( Z < \Phi^{-1}(\alpha/2) \)

      For a lower tailed test

      \( Z < \Phi^{-1}(\alpha) \)

      For an upper tailed test

      \( Z > \Phi^{-1}(1 - \alpha) \)

      Conclusion: Reject the null hypothesis if Z is in the critical region

    For a lower tailed test, the p-value is equal to \( \Phi(Z) \). For an upper tailed test, the p-value is equal to 1 - \( \Phi(Z) \). For a two-tailed test, the p-value is equal to 2*(1 - \( \Phi(Z) \) ).

    Alternatively, you can request that the lower and upper confidence limits for p1 - p2 be returned instead of the p-value for the hypothesis test.

Syntax 1:
    LET PVAL = DIFFERENCE OF PROPORTION HYPOTHESIS TEST
                            <p1> <n1> <p2> <n2> <alpha>
                            <SUBSET/EXCEPT/FOR qualification>
    where <p1> is constant, parameter, or variable that contains the proportion of successes for the first sample;
                <n1> is constant, parameter, or variable that contains the number of trials for the first sample;
                <p2> is constant, parameter, or variable that contains the proportion of successes for the second sample;
                <n2> is constant, parameter, or variable that contains the number of trials for the second sample;
                <alpha> is constant or parameter that contains the significance level;
                <pval> is the returned p-value;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This syntax is used for the two-tailed case.

    The <p1> <n1> <p2> and <n2> arguments can be either parameters or variables. If they are 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 <p1> <n1> <p2> and <n2> are all parameters, then <pval> will be a parameter. Otherwise, it will be a variable.

Syntax 2:
    LET PVAL = DIFFERENCE OF PROPORTION LOWER TAIL
                            HYPOTHESIS TEST <p1> <n1> <p2> <n2> <alpha>
                            <SUBSET/EXCEPT/FOR qualification>
    where <p1> is constant, parameter, or variable that contains the proportion of successes for the first sample;
                <n1> is constant, parameter, or variable that contains the number of trials for the first sample;
                <p2> is constant, parameter, or variable that contains the proportion of successes for the second sample;
                <n2> is constant, parameter, or variable that contains the number of trials for the second sample;
                <alpha> is constant or parameter that contains the significance level;
                <pval> is the returned p-value;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This syntax is used for the lower tailed case.

    The <p1> <n1> <p2> and <n2> arguments can be either parameters or variables. If they are 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 <p1> <n1> <p2> and <n2> are all parameters, then <pval> will be a parameter. Otherwise, it will be a variable.

Syntax 3:
    LET PVAL = DIFFERENCE OF PROPORTION UPPER TAIL
                            HYPOTHESIS TEST <p1> <n1> <p2> <n2> <alpha>
                            <SUBSET/EXCEPT/FOR qualification>
    where <p1> is constant, parameter, or variable that contains the proportion of successes for the first sample;
                <n1> is constant, parameter, or variable that contains the number of trials for the first sample;
                <p2> is constant, parameter, or variable that contains the proportion of successes for the second sample;
                <n2> is constant, parameter, or variable that contains the number of trials for the second sample;
                <alpha> is constant or parameter that contains the significance level;
                <pval> is the returned p-value;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This syntax is used for the upper tailed case.

    The <p1> <n1> <p2> and <n2> arguments can be either parameters or variables. If they are 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 <p1> <n1> <p2> and <n2> are all parameters, then <pval> will be a parameter. Otherwise, it will be a variable.

Syntax 4:
    LET <pdiff> <al> <au> = DIFFERENCE OF PROPORTION CONFIDENCE LIMITS
                            <p1> <n1> <p2> <n2> <alpha>
                            <SUBSET/EXCEPT/FOR qualification>
    where <p1> is constant, parameter, or variable that contains the proportion of successes for the first sample;
                <n1> is constant, parameter, or variable that contains the number of trials for the first sample;
                <p2> is constant, parameter, or variable that contains the proportion of successes for the second sample;
                <n2> is constant, parameter, or variable that contains the number of trials for the second sample;
                <alpha> is constant or parameter that contains the significance level;
                <pval> is the returned difference of binomial proportions;
                <al> is the returned lower confidence limit;
                <au> is the returned upper confidence limit;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    The <p1> <n1> <p2> and <n2> arguments can be either parameters or variables. If they are 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 <p1> <n1> <p2> and <n2> are all parameters, then <al> and <au> will be parameters. Otherwise, they will be variables.

Examples:
    LET PVAL = DIFFERENCE OF PROPORTION HYPOTHESIS TEST ...
                            P1 N1 P2 N2 ALPHA
    LET PDIFF AL AU = DIFFERENCE OF PROPORTION CONFIDENCE LIMTIS ...
                            P1 N1 P2 N2 ALPHA
Note: Note:
    The following command is also available:

      LET DIFF = DIFFERENCE OF BINOMIAL PROPORTIONS Y1 Y2

    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 two variables.

    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

    In addition, the command

    performs a difference of binomial proportions test. This command generates a more detailed output for the test. The LET version of the test is most useful when computing many values of the test statistic.

Default:
    None
Synonyms:
    None
Related Commands: References: Applications:
    Categorical Data Analysis
Implementation Date:
    2008/8
Program 1:
     
    LET X1 = 32
    LET N1 = 38
    LET P1 = X1/N1
    LET X2 = 39
    LET N2 = 44
    LET P2 = X2/N2
    LET ALPHA = 0.05
    LET PVAL = DIFFERENCE OF PROPORTION HYPOTHESIS TEST P1 N1 P2 N2 ALPHA
    LET PDIFF AL AU = DIFFERENCE OF PROPORTION CONFIDENCE LIMITS P1 N1 P2 N2 ALPHA
        
    The resulting values for PDIFF, PVAL, AL, and AU are -0.044, 0.5576, -0.1974, and 0.1805, respectively.

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 10/05/2010
Last updated: 11/09/2015

Please email comments on this WWW page to alan.heckert@nist.gov.