rghuang <[email protected]> is having trouble with the -bs- command and
version control:
> i use the following program in stata8,but when it finish,the variable se and
> bias all are missing.
>
> capture program drop Accum
> program define Accum
> postfile results se bias n using sim, replace
> forvalues n=20(20)2000 {
> qui bs "regress mpg weight for" "_b[for]", reps(`n')
> post results (r(se)) (r(bias)) (`n')
> }
> postclose results
> end
> Accum
> use sim, clear
>
>
> then i add version 7 to it ,then it work fine.see following:
> capture program drop Accum
> program define Accum
> version 7
> postfile results se bias n using sim, replace
> forvalues n=20(20)2000 {
> qui bs "regress mpg weight for" "_b[for]", reps(`n')
> post results (r(se)) (r(bias)) (`n')
> }
> postclose results
> end
> Accum
> use sim, clear
>
> so my question is :if i do not add verion 7,then what should i modify the
> program. thank you!
There was a fundamental change in the saved results in the -bs- command from
Stata 7 to Stata 8. In Stata 8 -bs- is a synonym for -bootstrap-, unless it
is called under the control of version 7 or less. The -bootstrap- command
saves results in -e()-.
Here is what the Stata 8 version should probably look like:
program define Accum
version 8
tempname bias
postfile results se bias n using sim, replace
forvalues n=20(20)2000 {
qui bootstrap "regress mpg weight for" b_for=_b[for], reps(`n')
mat `bias' = e(bias)
post results (_se[b_for]) (`bias'[1,1]) (`n')
}
postclose results
end
Note that you should always put a version statement at the top of your
programs (ado-files) and do-files; this ensures that future changes to syntax
will not break your files.
--Jeff
[email protected]
*
* 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/