Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Austin Nichols <austinnichols@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: error in forval? |

Date |
Wed, 20 Oct 2010 08:15:30 -0400 |

helen bian <helenbian06@gmail.com>: I should have said "range" not "numlist" per the help file for -forvalues-. -prtest- is OK only as long as the proportions involved are far enough away from zero or one and sample sizes sufficient that confidence intervals boundaries are not near zero or one (note that the confidence interval on a proportion for a nonzero point estimate should never include zero). You might want to check for sensible results inside your loop by recovering confidence interval bounds for the individual proportions from -proportion-. There are cases where prtest, svy:tab, and logit all fail to produce sensible results; one example is where there is a zero proportion involved. Perhaps others will suggest their favored approach in such cases, e.g. sysuse auto, clear g y=rep78<3 ren foreign x prtest y, by(x) bitest y=`r(P_1)' if x==0 svyset, srs svy:tab y x, col se test _b[p21]=_b[p22] test _b[p21]=0 proportion y, over(x) mat b=e(b) mat v=e(V) di b[1,3]-invttail(e(df_r),.025)*sqrt(v[3,3]),b[1,3]+invttail(e(df_r),.025)*sqrt(v[3,3]) test [_prop_2]_b[Domestic]=[_prop_2]_b[Foreign] test [_prop_2]_b[Domestic]=0 logit y x, nolog or binreg y x, or nolog exlogistic y x, nolog tab y x cii 22 0 cii 52 10 On Wed, Oct 20, 2010 at 7:38 AM, Austin Nichols <austinnichols@gmail.com> wrote: > helen bian <helenbian06@gmail.com>: > > Incorrect numlist; try instead > forvalues i=1(1)6 { > forvalues j=`=`i'+1'/7 { > di `i', `j' > } > } > > but also note that -prtest- is a poor solution for most problems; > svy:tab is better (even for non-survey data--just -svyset, srs- first) > or a -logit- of FLAG_ChoseBestHosp1 on the single dummy variable > defined by BG_Condition_recode==`i'. > > On Wed, Oct 20, 2010 at 7:29 AM, helen bian <helenbian06@gmail.com> wrote: >> Dear all, >> >> Could any one point to me what the problem is in the following for loop, please? >> >> forvalues i=1(1)6{ >> forvalues j= `i'+1 /7{ >> prtest FLAG_ChoseBestHosp1 if ( BG_Condition_recode==`i'| >> BG_Condition_recode==`j'), by( BG_Condition_recode) >> } >> } >> > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: error in forval?***From:*helen bian <helenbian06@gmail.com>

**Re: st: error in forval?***From:*Austin Nichols <austinnichols@gmail.com>

- Prev by Date:
**Re: st: Stata and Emacs interactively** - Next by Date:
**Re: st: Stata and Emacs interactively** - Previous by thread:
**Re: st: error in forval?** - Next by thread:
**Re: st: error in forval?** - Index(es):