Stata Textbook Examples
Introduction to the Practice of Statistics by Moore and McCabe
Chapter 5: From Probability to Inference

NOTE: This page has been delinked.  It is no longer being maintained, and information on this page may be out of date.

Example 5.4 can be solved with the bitesti command. We supply the value of n k and p. We see the probability that X <= 1 is .7361, as shown in the book.
bitesti 10 1 .1

        N   Observed k   Expected k   Assumed p   Observed p
------------------------------------------------------------
       10          1            1       0.10000      0.10000

  Pr(k >= 1)           = 0.651322  (one-sided test)
  Pr(k <= 1)           = 0.736099  (one-sided test)
  Pr(k <= 1 or k >= 2) = 1.000000  (two-sided test)
Example 5.5 also can be solved with bitesti. In this example, the N is 12, k is 5, and p is .25. Stata shows that the probability of missing 5 or more shots is .1576.
bitesti 12 5 .25

        N   Observed k   Expected k   Assumed p   Observed p
------------------------------------------------------------
       12          5            3       0.25000      0.41667

  Pr(k >= 5)           = 0.157644  (one-sided test)
  Pr(k <= 5)           = 0.945598  (one-sided test)
  Pr(k <= 0 or k >= 5) = 0.189320  (two-sided test)
We can also solve example 5.7 using bitesti, as shown below. Stata shows the probablity X >= 1450 is .9802, as shown in the book.
bitesti 2500 1450 .6

        N   Observed k   Expected k   Assumed p   Observed p
------------------------------------------------------------
     2500       1450         1500       0.60000      0.58000

  Pr(k >= 1450)              = 0.980180  (one-sided test)
  Pr(k <= 1450)              = 0.021854  (one-sided test)
  Pr(k <= 1450 or k >= 1550) = 0.043274  (two-sided test)
We can solve example 5.10 using bitesti as shown below.
bitesti 100 9 .1

        N   Observed k   Expected k   Assumed p   Observed p
------------------------------------------------------------
      100          9           10       0.10000      0.09000

  Pr(k >= 9)            = 0.679126  (one-sided test)
  Pr(k <= 9)            = 0.451290  (one-sided test)
  Pr(k <= 9 or k >= 11) = 0.868135  (two-sided test)
We skip examples 5.11 and 5.12.
Show example 5.21 on page 416.

How to cite this page

Report an error on this page or leave a comment

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.