### Stata Textbook Examples Introduction to the Practice of Statistics by Moore and McCabe Chapter 6: Introduction to Inference

Examples 6.2-6.5, just calculator examples. Below we show that Stata can be used as a calculator using 6.2-6.4 as examples
Example 6.2
display (190.5 + 189 + 195.5 + 187) / 4
190.5

display 190.5 - 1.645*(3/sqrt(4))
188.0325

display 190.5 + 1.645*(3/sqrt(4))
192.9675
Example 6.3
display 190.5 - 1.645*(3/sqrt(1))
185.565

display 190.5 + 1.645*(3/sqrt(1))
195.435
Example 6.4
display 190.5 - 2.576*(3/sqrt(1))
182.772

display 190.5 + 2.576*(3/sqrt(1))
198.228
Bootstrap example, bottom of page 445
clear
input weight
190.5
189
195.5
187
end
Below we take 100 samples. You can control the number of samples with the reps option.
* Stata 8 code.
bs "summarize weight" r(mean), reps(100)

* Stata 9 code and output.
bootstrap r(mean), reps(100) nodots: summarize weight

Bootstrap results                               Number of obs      =         4
Replications       =       100

command:  summarize weight
_bs_1:  r(mean)

------------------------------------------------------------------------------
|   Observed   Bootstrap                         Normal-based
|      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 |      190.5   1.742532   109.32   0.000     187.0847    193.9153
------------------------------------------------------------------------------

estat bootstrap, all

Bootstrap results                               Number of obs      =         4
Replications       =       100

command:  summarize weight
_bs_1:  r(mean)

------------------------------------------------------------------------------
|    Observed               Bootstrap
|       Coef.       Bias    Std. Err.  [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 |       190.5    -.08125   1.7425323    187.0847   193.9153   (N)
|                                          187.5     194.25   (P)
|                                        187.875     194.25  (BC)
------------------------------------------------------------------------------
(N)    normal confidence interval
(P)    percentile confidence interval
(BC)   bias-corrected confidence interval

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.