Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: Stata package -diagt- version 2.0.5.


From   Paul Seed <[email protected]>
To   "Alessandro A. Leidi" <[email protected]>, "[email protected]" <[email protected]>
Subject   st: Re: Stata package -diagt- version 2.0.5.
Date   Tue, 12 May 2009 13:18:28 +0100

Dear Allesandro,

Bootstrapping should not be necessary, as the CI for sensitivity & specificity
are based on the exact Binomial distribution.  In fact, if you do not use
the -bca- option with bootstrap, you will get symmetrical intervals
based on 1.96 SE, which are definitely worse.

Alo, for speed with long runs, you are very often better off writing your own version of a program that only does the bare minimum you need, as otherwise, you will be asking the computer to work out a lot of unneeded values, which can be quite time consuming.

I have done this below for diagt.

*****************************
prog drop _all

prog define mydiagt, rclass
*! mydiagt version 1.0 written 12 May 2009 by PT Seed ([email protected])
*! stripped-down version of -diagt- for use with -bootstrap- command.

* Note: it assumes that values of test & true variables are 0 and 1 only.

version 6.0
* Syntax
   syntax varlist(min=2 max=2 numeric) [if]
   tempvar touse
   mark `touse' `if'

   tokenize  "`varlist'"
   local true `1'
local test `2' su `true' if `test' == 1 & `touse', meanonly
   return scalar sens = r(mean)
   su `true' if `test' == 0 & `touse', meanonly
   return scalar spec = (1-r(mean))
end mydiagt

bootstrap sens=r(sens) spec=r(spec), reps(100) bca: mydiagt true test
estat bootstrap, all


**********************************

Paul T Seed MSc CStat CSci, Senior Lecturer in Medical Statistics,
tel  (+44) (0) 20 7188 3642, fax (+44) (0) 20 7620 1227
Wednesdays: (+44) (0) 20 7848 4208
[email protected], [email protected]

King's College London, Division of Reproduction and Endocrinology
St Thomas' Hospital, Westminster Bridge Road, London SE1 7EH



Alessandro A. Leidi wrote:
Dear Paul,
Just to bring to your attention that I have hit a snag with your excellent Stata package -diagt- version 2.0.5, which does not like to be prefixed by-bootstrap-, since it calls -diagti- for computations, as explained by Thomas Steichen below. Tried but failed to locate an earlier version like 2.0.0: do you know where I can find one?
Meanwhile I'll try to delve into diagt.ado and diagti.ado fo version 2.0.5 to see if I can contribute.
Thank you and regards
Sandro Leidi

________________________________________
From
  "Steichen, Thomas J." <[email protected]>
To
  "'[email protected]'" <[email protected]>
Subject
  st: RE: RE: bootstrap with a user-contributed command
Date
  Mon, 11 May 2009 16:09:37 -0400
________________________________________
Assuming you are running version 2.0.5 or later of -diagt-, the problem appears to be that -diagt- calls -diagti-, wherein r(spec) and r(sens) are generated, then -diagt- reads these values and attempts to repost them. The values appear to get lost when -bootstrap- is wrapped around everything.

Version 2.0.0 of -diagt- does its own computations (i.e., doesn't call -diagti-), so it works fine with -bootstrap-:

. diagti 80 17 11 44

      True |
   disease |      Test result
    status |      Pos.       Neg. |     Total
-----------+----------------------+----------
  Abnormal |        80         17 |        97
    Normal |        11         44 |        55
-----------+----------------------+----------
     Total |        91         61 |       152


                                                      [95% Conf. Inter.]
-------------------------------------------------------------------------
Sensitivity                     Pr( +| D)  82.47%      73.43%   89.45%
Specificity                     Pr( -|~D)  80.00%      67.03%   89.57%
Positive predictive value       Pr( D| +)  87.91%      79.40%   93.81%
Negative predictive value       Pr(~D| -)  72.13%      59.17%   82.85%
-------------------------------------------------------------------------
Prevalence                      Pr(D)      63.82%      55.64%   71.44%
-------------------------------------------------------------------------
Likelihood Ratio of Pos. Test   LR+         4.12        2.41     7.05
Likelihood Ratio of Neg. Test   LR-         0.22        0.14     0.34
-------------------------------------------------------------------------

. which diagt
h:\ado\diagt.ado
*! diagt 2.0.0  21 Feb 2001  PTS -- added DR and FPR

. bootstrap sens=r(sens) spec=r(spec): diagt true test
(running diagt on estimation sample)

Warning:  Since diagt is not an estimation command or does not set e(sample),
          bootstrap has no way to determine which observations are used in
          calculating the statistics and so assumes that all observations are used.
          This means 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.

Bootstrap replications (50)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
..................................................    50

Bootstrap results                               Number of obs      =       152
                                                Replications       =        50

      command:  diagt true test
         sens:  r(sens)
         spec:  r(spec)

------------------------------------------------------------------------------
             |   Observed   Bootstrap                         Normal-based
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        sens |   82.47423   3.475202    23.73   0.000     75.66296     89.2855
        spec |         80   4.271629    18.73   0.000     71.62776    88.37224
------------------------------------------------------------------------------

-----------------------------------
Thomas J. Steichen
[email protected]
-----------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Alessandro A. Leidi
Sent: Monday, May 11, 2009 1:13 PM
To: [email protected]
Subject: st: RE: bootstrap with a user-contributed command

I had already tried bootstrapping -diagt- directly without a user-written program, see below.
-bootstrap- squawks like it does when used with -rclass- functions but it does not deliver for -diagt-.

Of course it may be my mistake, but where am I going wrong?

Thank you for your consideration.
Sandro Leidi
[email protected]

. quietly diagti 80 17 11 44

. which diagt
c:\ado\plus\d\diagt.ado
*! diagt 2.052, 30 June 2003
*! by PT Seed ([email protected])
*! based on diagtest.ado (Aurelio Tobias, STB-56: sbe36)
*! and further suggestions from Tom Steichen

. bootstrap sens=r(sens) spec=r(spec): diagt true test
(running diagt on estimation sample)

Warning:  Since diagt is not an estimation command or does not set e(sample), bootstrap has no way to determine which observations are used in calculating the statistics and so assumes that all observations are used.  This means 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.

Bootstrap replications (50)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
post __000002 not found
post __000002 not found
r(111);

.

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index