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: Permute - error message


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Permute - error message
Date   Thu, 31 Mar 2011 14:10:39 +0100

That's not an error message; it's a warning. An error message will be
accompanied by the program stopping. It's a big difference!

Besides, it is self-explanatory. It doesn't matter for your problem,
at least on the information you have given us.

On Thu, Mar 31, 2011 at 2:05 PM, Guy Grossman <[email protected]> wrote:
> Dear Nick,
> The error message I received is below. However, when running your
> adjusted code, the command was executed swiftly.
> Thank a million,
> Guy
>
> . permute z r(diff): mydiff
>
> (running mydiff on estimation sample)
> Warning:  Because mydiff is not an estimation command or does not set e(sample),
>           permute has no way to determine which observations are used in
>           calculating the statistics and so assumes that all observations are
>           used.  This means that no observations will be excluded from the
>           resampling because of missing values or other reasons.
>           If the assumption is not true, press Break, save the data,
> and drop the
>           observations that are to be excluded.  Be sure that the dataset in
>           memory contains only the relevant data.
>
> Permutation replications (100)
> ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
> .xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx    50
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   100
> Monte Carlo permutation results                   Number of obs   =          8
>       command:  mydiff
>         _pm_1:  r(diff)
>
> permute var:  z
> ------------------------------------------------------------------------------
> T            |     T(obs)       c       n   p=c/n   SE(p) [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>        _pm_1 |   .3586207       1       1  1.0000  0.0000      .025          1
> ------------------------------------------------------------------------------
> Note:  confidence interval is with respect to p=c/n.
> Note:  c = #{|T| >= |T(obs)|}
> Note:  missing values observed in permutation replicates.
>
> On Thu, Mar 31, 2011 at 8:28 AM, Nick Cox <[email protected]> wrote:
>>
>> I don't know what error messages you are getting. You don't tell us
>> and what I did, as below, ran without error.
>>
>> The first thing I noticed was that your code can be slimmed down. It
>> seems to me that
>>
>> > egen grouptotal = rowtotal(y1-y10)
>> > egen groupN = rownonmiss(y1-y10)
>> >
>> > cap program drop mydiff
>> > program define mydiff, rclass
>> >        egen tot_treat = total(grouptotal) if z ==1
>> >        egen tot_cont = total(grouptotal) if z ==0
>> >        egen N_treat = total(groupN) if z ==1
>> >        egen N_cont = total(groupN) if z ==0
>> >        sum tot_treat
>> >        local size_treat=r(max)
>> >        sum tot_cont
>> >        local size_cont=r(max)
>> >        sum N_treat
>> >        local N_treatment=r(max)
>> >        sum N_cont
>> >        local N_control=r(max)
>> >        return scalar diff =
>> > (`size_treat'/`N_treatment')-(`size_cont'/`N_control')
>> > end
>>
>> is equivalent to
>>
>> egen mean = rowmean(y1-y10)
>> cap program drop mydiff
>> program mydiff, rclass
>>       su mean if z == 1, meanonly
>>       local mean_treat = r(mean)
>>       su mean if z == 0, meanonly
>>       return scalar diff = `mean_treat' -  r(mean)
>> end
>>
>> I am a big fan of -egen- when appropriate, but egenitis is a condition
>> in which it is used quite unnecessarily to create variables merely to
>> hold single constants.
>>
>> When I ran that I got output with -permute-.
>>
>> That said, I don't think that I what I did was anything other than
>> making style changes, so I can't explain your report of errors.
>>
>> Nick
>>
>> On Thu, Mar 31, 2011 at 11:40 AM, Guy Grossman <[email protected]> wrote:
>>
>> > I am trying to conduct a simple randomization inference analysis
>> > (permuting Z - treatment indicator). y1-y10 are outcomes of individual
>> > units within groups identified by the id variable. The number of units
>> > within groups varies from 3 to 10. In the original data 3 groups are
>> > treated (z=1) and 5 are control (z=0).
>> >
>> > For some reason whether I am using the permute command or the
>> > user-written "tsrtest" command (by Kaiser and Lacy) I get error
>> > messages which I fail to correct. Any suggestions on how to get this
>> > code running would be highly appreciated.
>> >
>> > Thanks!
>> > Guy
>> >
>> > input id z y1 y2 y3 y4 y5 y6 y7 y8 y9 y10
>> > 1 0 0 0 0 0 0 . . . . .
>> > 2 0 0 0 0 0 0 0 0 0 0 0
>> > 3 0 1 1 1 1 0 . . . . .
>> > 4 0 0 1 1 . . . . . . .
>> > 5 1 0 0 1 1 . . . . . .
>> > 6 1 1 1 1 1 1 . . . . .
>> > 7 0 0 0 0 1 0 0 . . . .
>> > 8 1 0 0 0 1 0 1 . . . .
>> > end
>> >
>> > egen grouptotal = rowtotal(y1-y10)
>> > egen groupN = rownonmiss(y1-y10)
>> >
>> > cap program drop mydiff
>> > program define mydiff, rclass
>> >        egen tot_treat = total(grouptotal) if z ==1
>> >        egen tot_cont = total(grouptotal) if z ==0
>> >        egen N_treat = total(groupN) if z ==1
>> >        egen N_cont = total(groupN) if z ==0
>> >        sum tot_treat
>> >        local size_treat=r(max)
>> >        sum tot_cont
>> >        local size_cont=r(max)
>> >        sum N_treat
>> >        local N_treatment=r(max)
>> >        sum N_cont
>> >        local N_control=r(max)
>> >        return scalar diff =
>> > (`size_treat'/`N_treatment')-(`size_cont'/`N_control')
>> > end
>> > tsrtest z r(diff): mydiff
>> > permute z r(diff): mydiff

*
*   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/


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