[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Yulia Marchenko" <ymarchenko@stata.com> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: -sampsi- command and exact tests |

Date |
Wed, 2 Feb 2005 12:30:54 -0600 |

On Tuesday, David wrote: >I understand from several previous posts that the command -sampsi- uses >an approximate large sample test on proportion. power, and sample size >calculations. Specifically, it uses the normal approximation (with >correction) as opposed to an exact test. The advice in a previous post >was that the following equalities must hold in order for sampsi to work >adequately: >n1p1>=10 >n1(1-p1)>=10 >n2p2>=10 >n2(1-p2)>=10 >(see post from ymarchenko@stata.com entitled st:RE: calculation of >sample size, dated 8 Oct 2004) >I am trying to use sampsi to estimate the required number of samples as >follows: >sampsi 0.4 0.46, alpha(0.05) power(0.90) onesample >Stata indicates that 711 samples are required as indicated in the Stata >output >This seems to meet the n1p1>=10 etc. requirements listed above to use >the -sampsi- command. However, I am told that the right answer using >NQuery Advisor and its exact test for single proportions is 610 >observations. S-Plus gives 613 as an answer. StatXact also gives a >similar answer to NQuery Advisor and S-Plus. >Does anyone know if Stata's use of the normal approximation (with >continuity correction) is indeed what is causing the 100+ discrepancy >here? Is there is an exact test in Stata that can be used instead of >-sampsi-? And are there additional criteria beyond the n1p1>=10 etc. >criteria listed in the referenced previous post that should be checked >before using -sampsi- ? The command -sampsi- uses continuity correction only for two-sample proportion test. However, the discrepancy of 100 may be explained if other packages by default report sample size for one-sided test. By default -sampsi- uses two-sided test. For one-sided test Stata gives n=580 as shown below. . sampsi 0.4 0.46, onesample onesided Estimated sample size for one-sample comparison of proportion to hypothesized value Test Ho: p = 0.4000, where p is the proportion in the population Assumptions: alpha = 0.0500 (one-sided) power = 0.9000 alternative p = 0.4600 Estimated required sample size: n = 580 This is closer to 610 and 613 obtained from other packages by using the exact test. We can simulate the exact power for these three sample sizes (580, 610, 613) using exact Binomial test ( Stata -bitest- command): capture program drop exactpow program exactpow, rclass args n p0 pa alpha qui { rndbin `n' `pa' 1 bitest xb=`p0' } return scalar p=(r(p)<`alpha') end clear local numlist="613 610 580" qui foreach n of local numlist{ clear simulate "noi exactpow `n' 0.4 0.46 0.1" p=r(p), reps(10000) summ p noi di in gr "Sample size = " in yel `n' in gr " Exact power:" r(mean) } exit Here are my results: Sample size = 613 Exact power:.9131 Sample size = 610 Exact power:.9159 Sample size = 580 Exact power:.9001 The above results support the guess about other packages reporting sample size for one-sided test. --Yulia ymarchenko@stata.com * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: -sampsi- command and exact tests***From:*Miller.DavidJ@epamail.epa.gov

- Prev by Date:
**st: RE: quotes in a string variable** - Next by Date:
**st: displaying variance-covariance matrix after "pca"** - Previous by thread:
**st: -sampsi- command and exact tests** - Next by thread:
**Re: st: -sampsi- command and exact tests** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |