Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: limiting observations within a program


From   Michael McCulloch <[email protected]>
To   [email protected]
Subject   Re: st: Re: limiting observations within a program
Date   Thu, 2 Oct 2008 17:46:38 -0700

Thanks for confirming `X', and also for pointing out the nifty abbreviations!
Now, if I could only figure out why adding the -if- statement to my -stcox- command:
stcox tcm if `wt_stab_ALL'!=.

or dropping the very with missing weight with:
drop if `wt_stab_ALL' ==.

will cause the bootstrapping of my program to give the error message:

"varlist required
an error occurred when bootstrap executed msmcox_stageALL_includeIPTWd
r(100);"

Michael



Ok, so indeplist is a user-written program. This works for me, i.e. leaves the desired result in the -return list-


*************
cap ssc inst indeplist
webuse kva, clear
stset failtime

cap pr drop myprog

pr myprog, rclass
indeplist, local
foreach var of varlist `X' {
return scalar `var' = exp(_b[`var'])
}
end


stcox load bearings
myprog
ret li
**************



HTH
Martin
_______________________
----- Original Message ----- From: "Michael McCulloch" <[email protected]>
To: <[email protected]>
Sent: Friday, October 03, 2008 2:24 AM
Subject: Re: st: Re: limiting observations within a program


Martin wrote:
`X' looks like some kind of -macro- but I cannot find its definition, either...
Ahah! Thank you. Now I know what proper question to ask. Let me try this again. Note that the section mentioning X:

" indeplist, local
foreach var of varlist `X' {
return scalar `var' = exp(_b[`var'])
}"

immediately follows the -stcox-. What I want to do is to have it give me the exponentiated coefficient so the hazard ratio is returned. How would I rewrite that section to do this?



HTH
Martin
_______________________
----- Original Message ----- From: "Michael McCulloch" <[email protected]>
To: <[email protected]>
Sent: Friday, October 03, 2008 2:12 AM
Subject: Re: st: Re: limiting observations within a program

Sergei wrote:
And where is varlist X defined?
Thanks Sergei. Sorry, not sure what you mean. I've defined the tempnames with:
tempname p_tcm_ALL p_notcm_ALL p_ALL p_noALL wt_stab_ALL
And, the variables are all within my dataset:
tcm dxage sex celltype txsurg txrad txchemo




On Thu, Oct 2, 2008 at 7:56 PM, Michael McCulloch <[email protected]> wrote:
Thanks Martin. This is my program. It first estimates probability of
receiving treatment (called "tcm"), and then weights the data for -stcox-.
There was one observation in which the weight was missing, I'm attempting to
include a line in my program to drop that one observation.

capture program drop msmcox_stageALL_includeIPTWd
program define msmcox_stageALL_includeIPTWd, rclass
 >        tempname p_tcm_ALL              p_notcm_ALL     p_ALL p_noALL
 >         wt_stab_ALL
        * fit the full model used in Traditional Cox
 >        logit tcm dxage sex celltype txsurg txrad txchemo
        *estimate probability of treatment
        predict `p_tcm_ALL'
        gen `p_notcm_ALL' = 1-`p_tcm_ALL' if tcm==0     //want p(tcm) for
 both users and nonusers
        replace `p_tcm_ALL' =`p_notcm_ALL' if tcm==0

        *create stabilized weight==P(A)/P(A|W)
        logit tcm        predict `p_ALL'
        gen `p_noALL'           =       1-`p_ALL' if tcm==0
        replace `p_ALL' =       `p_noALL' if tcm==0
        gen `wt_stab_ALL'       =       `p_ALL'/`p_tcm_ALL'

        * stset the data
        stset lastcontact [`iweight=wt_stab_ALL'], failure(failed)
 origin(datedx) scale(30.4375)   /*wt: stabilized IPTW*/

        * cox
                stcox tcm if `wt_stab_ALL'!=.
        indeplist, local
        foreach var of varlist `X' {
                return scalar `var' = exp(_b[`var'])
        }
 end set seed 12358
 eststo MSM_t_I: bootstrap tcm=r(tcm), eform reps(10):
 msmcox_stageALL_includeIPTWd

That is too little info. How does `var1' come into existence? A
-bootstrap- would cycle through the -program- several times, so that is an
important issue. Also -set trace on- and let us know the output...

HTH
Martin
_______________________
----- Original Message ----- From: "Michael McCulloch" <[email protected]>
To: "Statalist" <[email protected]>
Sent: Friday, October 03, 2008 1:10 AM
Subject: st: limiting observations within a program


Hello,
I've written a short program which estimates a probability of censoring,
and have a question. The program works as written, but if I add the
following line:

drop if `var1'==.

the program returns error message:

"varlist required an error occurred when bootstrap executed program1
r(100);"

Any assistance would be appreciated!


--

Best wishes,
Michael McCulloch



Pine Street Foundation
124 Pine St., San Anselmo, CA 94960-2674
Tel: (415) 407-1357
Fax: (415) 485-1065
[email protected]
www.pinestreetfoundation.org
*
* 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/


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

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


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


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