Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: stcox error when run inside a loop


From   Shubhabrata Mukherjee <[email protected]>
To   stata forum <[email protected]>
Subject   st: stcox error when run inside a loop
Date   Wed, 28 Dec 2011 10:05:21 -0800 (PST)

Hello,

I am running stcox in a loop and can't seem to suppress the following error:


For some variables (temp1-temp20) in the varlist, Stata is erroring out because the ML estimation didn't converge for one or more variables. I thought 'capture stcox' takes care of this but it seems when it fails to converge it has nothing to post and that's the reason for the error.

. ** Cox regression for each variable
. foreach var of varlist temp1-temp20 {
          capture stcox `var' `gender age
          post `out' ("`var'") (_b[`var']) (_se[`var'])  ("a") (e(converged)) 
  }
no variables defined
post:  above message corresponds to expression 2, variable beta
r(111);


Is there a way to print missing values or 'NA'/'NaN' when it fails to convergeso that the code doesn't stop midway?

I used a subset and saw that it's failing to converge for some variables and a normal stcox run for thoses variables gives the following error:

flat region resulting in a missing likelihood
r(430);

Thanks again,

-Joey


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index