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: bug in bs4rw (or bug in Stata?)


From   Keith Dear <[email protected]>
To   [email protected]
Subject   Re: st: bug in bs4rw (or bug in Stata?)
Date   Thu, 24 Mar 2011 08:43:03 +1100

Thanks to both for your replies.
I'll CC this to my colleague (who I don't think watches Statalist,
though he has posted here) so that he knows to switch to -svy
bootstrap-. Thanks for that tip!

Nick: you say "-syntax- is not talking semantics, it is talking
syntax", but it seems to me that although -syntax- may be *thinking*
syntax, when it says "options not allowed" it is *talking* semantics,
i.e. trying to be smart. It should say "comma not allowed" since that
is the syntax error. But I accept this doesn't amount to a bug in
Stata, and anyway the problem is really with bs4rw.

Jeff: I can see you probably don't want to touch bs4rw since it has
been superseded, but it would be very easy to fix this using the same
method you use elsewhere in the program:
        if `"`cmdopts'`rest'"' != "" {
                local cmd2      `", `cmdopts' `rest'"'
       }
       capture noisily quietly `noisily' `version'     ///
                `cmdname' `cmdargs'                     ///
                `wgt' if `touse' 'cmd2'

Anyhow, thanks again, problem solved.
Keith

On 24 March 2011 01:45, Jeff Pitblado, StataCorp LP <[email protected]> wrote:
> Keith Dear <[email protected]> is using -bs4rw- (which has been superseded
> by -svy bootstrap- in Stata 11) and is getting an unexpected error message
> from his prefixed command due to how -bs4rw- is calling it:
>
>> -bs4rw- bootstraps a command which may be user-defined. It seems the
>> command MUST have options, or at least a syntax statement ending in ",
>> *". This seems undesirable.
>>
>> The following code snippet from bs4rw.ado shows that `cmdname' is
>> called with a comma even if `cmdopts' and `rest' are empty.
>> If `cmdname' in fact has no options, this causes bs4rw to crash with
>> the error message "options not allowed".
>> .       capture noisily quietly `noisily' `version'     ///
>> .                `cmdname' `cmdargs'                     ///
>> .                `wgt' if `touse', `cmdopts' `rest'
>> (This is in the code section "bs4rw: First call to `cmdname' with data
>> as is" : later on the issue is handled more carefully.)
>>
>>
>>
>> But anyway, it seems to me that this should not be a problem, and the
>> bug is really in the Stata language, not in bs4rw after all. Consider
>> this:
>>
>> . prog snip
>> .    syntax
>> . end
>> . snip     // no effect of course, but no problems either
>> . snip ,   // the comma triggers the "options not allowed" error even
>> though no options have been given.
>>
>> Should this be an error? I don't think so.
>
> Nick Cox has already replied with a clear description of how Stata interprets
> the following two commands:
>
>        snip
>        snip ,
>
> -bs4rw- was designed to work with estimation commands that post their results
> in -e()-, but it also supports other commands that post their results in -r()-
> or global scalars and matrices.  At a minimum, -bs4rw- requires that the
> prefixed command allow -pweight-s and/or -iweight-s and an -if- condition.  So
> the prefixed command must allow the following minimum syntax
>
>        syntax [pw iw] [if]
>
> I can see how this specification is not exactly sufficient to work with
> -bs4rw-.  As Keith has already pointed out, the minimum syntax must also allow
> a comma.  Until -syntax- learns to tolerate lonely commas, Keith can add a
> NULL option to the above syntax.  For example
>
>        syntax [pw iw] [if] [, NULLOPT]
>
> --Jeff
> [email protected]
> *
> *   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/
>



-- 
Dr Keith Dear
National Centre for Epidemiology and Population Health
ANU College of Medicine, Biology and Environment
Australian National University
Canberra, ACT 0200 Australia
CRICOS provider #00120C
Phone +61 (02) 6273 2208
Mobile 0424 450 396

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