Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: sw command within bstrap

From   Stas Kolenikov <>
Subject   Re: st: sw command within bstrap
Date   Fri, 4 Feb 2005 19:41:23 -0500

you would have to do some programming, so that your -bootstrap-
command calls the routine you wrote, rather Stata's -sw- command. That
would be my guess if -bootstrap- does not work directly with -sw-.

Typically, you would do something like

bootstrap "logistic outcome stuff" _b _se

as shown in the examples. For the stepwise methods, however, you would
run into troubles that different boostrap samples may produce
different sets of the selected variables. So your wrapper around this
would have to indicate explicitly that the values of the coefficient
estimates of the variable not included into the model should be set to

program define crazy, rclass
   syntax varlist
   sw logistic outcome `varlist' , sw options
   foreach x of `varlist' {
      cap local b`var' = _b[`var']
      if _rc {
         local b`var' = .
      local blist `blist' (b`var')
   return local blist `blist'

bootstrap "crazy varlist" `r(blist)' , bootstrap options

I am pretty sure it won't work, but it should give you a direction to go.


On Fri, 4 Feb 2005 11:45:29 +0000, pra06 <> wrote:
> Hi all
> I am embarking on a project to derive a clinical prediction rule (using
> logistic regression) and it has been suggested that I should use a
> bootstrapping technique to study the internal validity of the final prediction
> model in order to derive bias-corrected coefficients/odds ratios.
> Perusing the manuals I came across the bstrap command which seems like a good
> place to start. I have been able to use a simple logistic regression in the
> bstrap command to calculate bias-corrected coefficients/odds ratios. However,
> I have seen articles that have suggested that they have used a stepwise
> command within the bootstrapping routine, ie replicating the exact same
> procedure that I will used to arrive at the final prediction model in each of
> the 1000 samples. I am unable to get bstrap to implement the sw command.
> I know that I can simply derive 1000 samples and apply the sw procedure to
> each sample. However, I am unsure as to how to assimilate the data from these
> 1000 samples as not only will the magnitude of the coefficients vary in each
> sample (simple part!) but the actual variables chosen by each sw procedure may
> be different in each sample.
> Any help with  programming in Stata or detailed examples in the literature
> (many just glibly state that this process was carried out – very helpful!)
> would be appreciated
> Best wishes
> Elaine Thomas
> *
> *   For searches and help try:
> *
> *
> *

Stas Kolenikov

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index