Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: graph results of bitest stratified with by(var)


From   Michael McCulloch <[email protected]>
To   [email protected]
Subject   Re: st: graph results of bitest stratified with by(var)
Date   Thu, 23 Jan 2014 09:55:23 -0800

Thank you Richard, that's exactly what I'm wanting to achieve.
I understand now that -bysort- clears the scalars at each re-call.

Can you point me to primers so I can learn how to wrap this into a -foreach- / -levelsof- loop?

 

Best wishes,
Michael McCulloch

--
Pine Street Foundation, since 1989
124 Pine Street | San Anselmo | California | 94960-2674  
P: (415) 407-1357 | F: (206) 338-2391 | http://www.PineStreetFoundation.org

On Jan 23, 2014, at 5:45 AM, Richard Goldstein wrote:

> If I understand what you want correctly, you cannot do it with bysort
> because each time you do the test the set of returned values (the
> "r()"'s) will be replaced and the old ones lost
> 
> you can do this within a -foreach- loop (you may need -levelsof- first)
> in which you quietly do the -bitest- and then list your results for that
> test and then do the next -bitest-, etc.
> 
> here is an example of how to use the returned values:
> 
> . sysuse auto
> 
> . bitest foreign=.2
> 
>    Variable |        N   Observed k   Expected k   Assumed p   Observed p
> -------------+------------------------------------------------------------
>     foreign |       74         22         14.8       0.20000      0.29730
> 
>  Pr(k >= 22)           = 0.029904  (one-sided test)
>  Pr(k <= 22)           = 0.984075  (one-sided test)
>  Pr(k <= 7 or k >= 22) = 0.041800  (two-sided test)
> r; t=0.09 8:39:38
> 
> . di r(N) _skip(2) r(P_p) _skip(2) r(k)/r(N) _skip(2) r(p)
> 74  .2  .2972973  .04179963
> 
> I have not put headers on the columns and have not done several other
> things you might want (e.g., print format for results) but this should
> give the basic idea, assuming I have correctly understood you
> 
> Rich
> 
> On 1/23/14, 12:57 AM, Michael McCulloch wrote:
>> I am using bitest for a two-sided test on whether the mean of varB is different than 0.2, and testing on each level of varA:
>> 	bysort varA:	bitest varB=.2
>> 
>> varA has ~30 values. I wish to display these in a table (showing N, observed p, 
> expected p, and the two-sided p-value), without manual cut-and-paste, as
> the test
> will be used to monitor an ongoing training program.
>> 
>> I note that the results of bitest are stored as:
>>      r(N)           number N of trials
>>      r(P_p)         assumed probability p of success
>>      r(k)           observed number k of successes
>>      r(p_l)         lower one-sided p-value
>>      r(p_u)         upper one-sided p-value
>>      r(p)           two-sided p-value
>> 
>> However, I do not know how one uses these r(**) values. Can anyone suggest how one 
> would go about this?
>> 
>> Best wishes,
>> Michael McCulloch
>> 
>> --
>> Pine Street Foundation, since 1989
>> 124 Pine Street | San Anselmo | California | 94960-2674  
>> P: (415) 407-1357 | F: (206) 338-2391 | http://www.PineStreetFoundation.org
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index