Calculates one- and two-sample binomial tests (D.A. Murray).
|Controls printed output (
||Type of test required (
||Form of the test for one-sample test (
||The probability level for the confidence interval; default 0.95|
||The value of the probability of success under the null hypothesis for the one-sample test; default 0.5|
||Number of successes (scalar) or results (variate) for the first sample|
||Sample size of the first sample|
||Number of successes (scalar) or results (variate) for the second sample|
||Sample size of the second sample|
||Saves the Normal approximation from the one-sample or two-sample tests, or the odds ratio|
||Saves the probability value from the one-sample or two-sample tests|
||Saves the lower limit of the confidence interval|
||Saves the upper limit of the confidence interval|
BNTEST calculates one- and two-sample binomial tests, and odds ratios. For a one-sample test, the number of successes r1 can be specified using the
R1 parameter, and the sample size n1 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,
N1 similarly provide the number of successes and sample size for the first sample (r1 and n1), and
N2 those for the second sample (r2 and n2).
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 r1/n1 > r2/n2 or
NULL (for a two-sample or one-sample test, respectively). Similarly,
METHOD=lessthan produces a test of the null hypothesis r1/n1 < r2/n2 or
NULL. A small “p-value” indicates that the data are inconsistent with the null hypothesis.
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
||number of successes, sample size, proportion, standard error (for Normal approximation and odds ratio) and odds ratio (when
||test and probability level;|
||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 saves the Normal approximation for the one- and two-sample tests or the odds ratio,
PROBABILITY saves the probability level.
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.
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
p1 (1 – p1) / p2 (1 – p2)
where p1 and p2 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).
Armitage, P. & Berry, G. (1994). Statistical Methods in Medical Research. Blackwell Science, Oxford.
Collett, D. (1991). Modelling Binary Data. Chapman & Hall, London.
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