The following returns (in addition to the AUC) a 0/1 variable for each candidate variable from the stepwise model which is 1 if the variable is included in the final model and 0 if it isn't:
program myboot, rclass
sw logit for rep wei len turn, pr(.05)
matrix B=e(b)
local finvars : colfullnames(B)
lroc, nograph
return scalar area=r(area)
foreach v of varlist rep wei len turn {
return scalar `v'=(index("`finvars'","`v'")>0)
}
end
clear
sysuse auto
sw logit for rep wei len turn, pr(.05)
lroc, nograph
bootstrap "myboot" r(area) r(rep78) r(weight) r(length) r(turn), reps(5) saving(bootresults) replace
clear
use bootresults
list
Hope this helps,
David
[email protected]
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: 20 July 2004 15:59
To: [email protected]
Subject: RE: st: obtaining AUC at each iteration when bootstrapping a
logistic reg ression model
Thanks, this works very well for me. I used this routine in a stepwise
regression analysis. I wonder whether it is possible to count how many times
a certain variable is selected out of the total number of bootstrap
repetitions. If so, does anyone know how to implement this in the rclass
program below?
-----Oorspronkelijk bericht-----
Van: May Boggess [mailto:[email protected]]
Verzonden: vrijdag 9 juli 2004 17:42
Aan: [email protected]
Onderwerp: Re: st: obtaining AUC at each iteration when bootstrapping a
logistic reg ression model
On Friday, Marieke asked:
> In order to validate internally and asses overfitting in a logistic
> regression model, I performed bootstrapping. However, I noticed that it is
> impossible to get the AUC (from lroc) for each repetition. Does anyone
know
> how I can solve this.
>
We can write a small rclass program to save the area each time.
Here is an example:
program drop myboot
program myboot, rclass
logit for rep
lroc, nograph
ret list
return scalar area=r(area)
end
clear
sysuse auto
logit for rep
lroc, nograph
bootstrap "myboot" r(area), reps(5) saving(bootresults, replace)
clear
use bootresults
list
--May
[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/
*
* 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/
*
* 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/