**[R] bitest** -- Binomial probability test

__Syntax__

Binomial probability test

**bitest** *varname* **==** *#p* [*if*] [*in*] [*weight*] [**,** __d__**etail**]

Immediate form of binomial probability test

**bitesti** *#N* *#succ* *#p* [**,** __d__**etail**]

**by** is allowed with **bitest**; see **[D] by**.

**fweight**s are allowed with **bitest**; see weight.

__Menu__

__bitest__

**Statistics > Summaries, tables, and tests > Classical tests of**
**hypotheses >** **Binomial probability test**

__bitesti__

**Statistics > Summaries, tables, and tests > Classical tests of**
**hypotheses >** **Binomial probability test calculator**

__Description__

**bitest** performs exact hypothesis tests for binomial random variables.
The null hypothesis is that the probability of a success on a trial is
*#p*. The total number of trials is the number of nonmissing values of
*varname* (in **bitest**) or *#N* (in **bitesti**). The number of observed successes
is the number of 1s in *varname* (in **bitest**) or *#succ* (in **bitesti**).
*varname* must contain only 0s, 1s, and missing.

**bitesti** is the immediate form of **bitest**; see immed for a general
introduction to immediate commands.

__Option__

+----------+
----+ Advanced +---------------------------------------------------------

**detail** shows the probability of the observed number of successes, k_obs;
the probability of the number of successes on the opposite tail of
the distribution that is used to compute the two-sided p-value,
k_opp; and the probability of the point next to k_opp. This
information can be safely ignored. See the technical note in **[R]**
**bitest** for details.

__Examples__

Setup
**. webuse quick**

Test whether probability of success equals 0.3
**. bitest quick == 0.3**
**. bitest quick == 0.3, detail**

Test if probability of success = 0.5, given 3 successes in 10 trials
**. bitesti 10 3 .5**

Test if probability of success = 0.000001, given 36 successes in 2.5
million trials
**. bitesti 2500000 36 .000001**

__Stored results__

**bitest** and **bitesti** store the following in **r()**:

Scalars
**r(N)** number N of trials
**r(P_p)** assumed probability p of success
**r(k)** observed number k of successes
**r(p_l)** lower one-sided p-value
**r(p_u)** upper one-sided p-value
**r(p)** two-sided p-value
**r(k_opp)** opposite extreme k
**r(P_k)** probability of observed k (**detail** only)
**r(P_oppk)** probability of opposite extreme k (**detail** only)
**r(k_nopp)** k next to opposite extreme (**detail** only)
**r(P_noppk)** probability of k next to opposite extreme (**detail** only)