UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

Stata Textbook Examples
Statistical Methods for the Social Sciences by Alan Agresti and Barbra Finley
Chapter 6: Statistical Inference: Significance Tests

Figure 6.3, page 161. ztail and zdemo are available from ATS and can be downloaded over the Internet using the findit command (see How can I use the findit command to search for programs and get additional help? for more information about using findit).
zdemo 1.5 -1.5
ztail .1336 2
Z-score, page 163; figure 6.4, page 164. zcalc is available from ATS and can be downloaded over the Internet using the findit command (see How can I use the findit command to search for programs and get additional help? for more information about using findit).
zcalc 4.032 4 1.257 627

z-score for sample means


      (m - mu)       (4.032 - 4)           (4.032 - 4)
 z = ----------  =  ---------------- =  -----------------  =  0.64
     s/sqrt(n)       1.257/sqrt(627)           0.0502

ztail .5222 2
Z-score, page 164. zcalc is available from ATS and can be downloaded over the Internet using the findit command (see How can I use the findit command to search for programs and get additional help? for more information about using findit).
zcalc 4.032 4 1.257 6270

z-score for sample means


      (m - mu)       (4.032 - 4)           (4.032 - 4)
 z = ----------  =  ---------------- =  -----------------  =  2.02
     s/sqrt(n)       1.257/sqrt(6270)           0.0159
Confidence interval, page 165.
cii 627 4.032 1.257

    Variable |     Obs         Mean    Std. Err.       [95% Conf. Interval]
-------------+-------------------------------------------------------------
             |     627        4.032    .0501997         3.93342     4.13058
Z-score, page 166.
zcalc 3.01 0 7.309 29

z-score for sample means


      (m - mu)       (3.01 - 0)           (3.01 - 0)
 z = ----------  =  ---------------- =  -----------------  =  2.22
     s/sqrt(n)       7.309/sqrt(29)           1.3572
Test for a single proportion, page 170; confidence interval, page 171.
prtesti 1227 .482 .5

One-sample test of proportion                      x: Number of obs =     1227

------------------------------------------------------------------------------
Variable |      Mean    Std. Err.       z     P>|z|       [95% Conf. Interval]
---------+--------------------------------------------------------------------
       x |      .482    .0142648   33.7894   0.0000       .4540415    .5099585
------------------------------------------------------------------------------

                          Ho: proportion(x) = .5

       Ha: x < .5              Ha: x ~= .5               Ha: x > .5
        z = -1.261               z = -1.261               z = -1.261
    P < z =  0.1036        P > |z| =  0.2073          P > z =  0.8964

cii 1227 .482

                                                       -- Binomial Exact --
    Variable |     Obs         Mean    Std. Err.       [95% Conf. Interval]
-------------+-------------------------------------------------------------
             |    1227     .4816626    .0142645        .4533704    .5100448
Z-score, page 178.
zcalc 4.17 4 1.39 2879

z-score for sample means


      (m - mu)       (4.17 - 4)           (4.17 - 4)
 z = ----------  =  ---------------- =  -----------------  =  6.56
     s/sqrt(n)       1.39/sqrt(2879)           0.0259
Confidence interval using t, page 184.
cii 29 3.01 7.31

    Variable |     Obs         Mean    Std. Err.       [95% Conf. Interval]
-------------+-------------------------------------------------------------
             |      29         3.01    1.357433        .2294247    5.790575
Single-sample t-test, page 185.
ttesti 29 3.01 7.31 0

One-sample t test

------------------------------------------------------------------------------
         |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       x |      29        3.01    1.357433        7.31    .2294247    5.790575
------------------------------------------------------------------------------
Degrees of freedom: 28

                               Ho: mean(x) = 0

     Ha: mean < 0               Ha: mean ~= 0              Ha: mean > 0
       t =   2.2174                t =   2.2174              t =   2.2174
   P < t =   0.9826          P > |t| =   0.0349          P > t =   0.0174
Power of a test, page 195. Stata uses the t-distribution rather than the z-distribution so the results below will differ slightly for the book value.
sampsi 0 10, alpha(.05) sd(18) n(36) onesample onesided

Estimated power for one-sample comparison of mean
  to hypothesized value

Test Ho: m =      0, where m is the mean in the population

Assumptions:

         alpha =   0.0500  (one-sided)
 alternative m =       10
            sd =       18
 sample size n =       36

Estimated power:

         power =   0.9543

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


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