Calculates one- and two-sample binomial tests (D.A. Murray).

### Options

`PRINT` = string tokens |
Controls printed output (`test` , `summary` , `confidence` ); default `test` , `summ` , `conf` |
---|---|

`METHOD` = string token |
Type of test required (`twosided` , `greaterthan` , `lessthan` ); default `twos` |

`TEST` = string token |
Form of the test for one-sample test (`exact` , `normalapproximation` ) or for two-sample (`normalapproximation` , `oddsratio` ); default `norm` |

`CIPROBABILITY` = scalar |
The probability level for the confidence interval; default 0.95 |

`NULL` = scalar |
The value of the probability of success under the null hypothesis for the one-sample test; default 0.5 |

### Parameters

`R1` = scalars or variates |
Number of successes (scalar) or results (variate) for the first sample |
---|---|

`N1` = scalars |
Sample size of the first sample |

`R2` = scalars or variates |
Number of successes (scalar) or results (variate) for the second sample |

`N2` = scalars |
Sample size of the second sample |

`STATISTIC` = scalars |
Saves the Normal approximation from the one-sample or two-sample tests, or the odds ratio |

`PROBABILITY` = scalars |
Saves the probability value from the one-sample or two-sample tests |

`LOWER` = scalars |
Saves the lower limit of the confidence interval |

`UPPER` = scalars |
Saves the upper limit of the confidence interval |

### Description

`BNTEST`

calculates one- and two-sample binomial tests, and odds ratios. For a one-sample test, the number of successes *r*_{1} can be specified using the `R1`

parameter, and the sample size *n*_{1} using the `N1`

parameter (both as scalars). Alternatively you can supply the raw data, by setting `R1`

to a variate containing one in the units corresponding to successful trials and zero in those for unsuccessful trials. The test is for the probability of success under a binomial distribution. The value for the probability under the null hypothesis is 0.5 by default, but you can specify other probabilities using the `NULL`

option. With a two-sample test, `R1`

and `N1`

similarly provide the number of successes and sample size for the first sample (*r*_{1} and *n*_{1}), and `R2`

and `N2`

those for the second sample (*r*_{2} and *n*_{2}).

For both one- and two-sample cases, the test is assumed to be two-sided unless otherwise requested by the `METHOD`

option. Setting `METHOD=greaterthan`

gives a one-sided test of the null hypothesis that *r*_{1}/*n*_{1} > *r*_{2}/*n*_{2} or `NULL`

(for a two-sample or one-sample test, respectively). Similarly, `METHOD=lessthan`

produces a test of the null hypothesis *r*_{1}/*n*_{1} < *r*_{2}/*n*_{2} or `NULL`

. A small “p-value” indicates that the data are inconsistent with the null hypothesis.

The `TEST`

option specifies the form of test to be used. For the one-sample test, an exact test or Normal approximation can be selected. For a two-sample test, a Normal approximation or odds ratio can be chosen.

Printed output is controlled by the `PRINT`

option with settings:

`summary` |
number of successes, sample size, proportion, standard error (for Normal approximation and odds ratio) and odds ratio (when `TEST=ODDSRATIO` is selected); |
---|---|

`test` |
test and probability level; |

`confidence` |
confidence interval for the probabilities of success; for the odds ratio the confidence interval is displayed for the true log-odds ratio and odds ratio. |

The default is to print everything.

By default a 95% confidence interval is calculated, but this can be changed by setting the `CIPROBABILITY`

option to the required value (between 0 and 1).

Results can be saved using the `STATISTIC`

, `PROBABILITY`

, `LOWER`

and `UPPER`

parameters. `STATISTIC`

saves the Normal approximation for the one- and two-sample tests or the odds ratio, `PROBABILITY`

saves the probability level. `LOWER`

and `UPPER`

save the lower and upper limits, respectively, of the confidence interval; for the odds ratio the confidence interval is saved for the true odds ratio.

Options: `PRINT`

, `METHOD`

, `TEST`

, `CIPROBABILITY`

, `NULL`

.

Parameters: `R1`

, `N1`

, `R2`

, `N2`

, `STATISTIC`

, `PROBABILITY`

, `LOWER`

, `UPPER`

.

### Method

A standard Normal approximation is used for both the one- and two-sample tests. The exact test and confidence intervals are based on the methodology described in Chapter 4 (page 121) of Armitage & Berry (1994). The odds ratio is a relative measure of the odds of a success in one set of data relative to that in the other. The estimate of the ratio is defined as

*p*_{1} (1 – *p*_{1}) / *p*_{2} (1 – *p*_{2})

where *p*_{1} and *p*_{2} are the success probabilities in two sets of data. The calculation of the approximate standard error of the estimated log-odds ratio and confidence intervals is described in Chapter 2 (page 36) of Collett (1991).

### References

Armitage, P. & Berry, G. (1994). *Statistical Methods in Medical Research*. Blackwell Science, Oxford.

Collett, D. (1991). *Modelling Binary Data*. Chapman & Hall, London.

### See also

Procedures: `PNTEST`

, `SBNTEST`

, `TTEST`

.

Commands for: Basic and nonparametric statistics, Regression analysis.

### Example

CAPTION 'BNTEST example',\ !t('Data from Statistical Methods in Medical Research',\ '(Armitage & Berry 1994, page 119).'); STYLE=meta,plain BNTEST 65; N1=100 CAPTION !t('One-sample, two-sided exact test, saving the 95% confidence',\ 'interval and the probability.') BNTEST [TEST=exact] R1=65; N1=100; PROBABILITY=prob; LOWER=lower; UPPER=upper PRINT prob,lower,upper CAPTION 'One-sample, one-sided exact test on the same data.' BNTEST [METHOD=greater; TEST=exact] R1=65; N1=100 CAPTION 'Two-sample, two-sided test.' BNTEST R1=41; N1=257; R2=64; N2=244 CAPTION 'Odds ratio.' BNTEST [TEST=oddsratio] R1=148; N1=520; R2=75; N2=418