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: Problems with ml max Survival analysis


From   <[email protected]>
To   <[email protected]>
Subject   st: Problems with ml max Survival analysis
Date   Fri, 8 Nov 2013 09:39:48 +0000

Working through the details of Amparo's -ml- code is beyond me right now, but I notice that the output reported for gradient length seems huge: " Gradient length       = 9.21e+09". Is this a signal that something is wrong in the code?

Consider the following:
* what happens if you use numerical derivatives (i.e. without the -mlvecsum- etc gradient calculation)? Principle: start simple and get something working, and then complicate it. Following the same principle, use a smaller set of predictors, and later add others when you're sure the model is working.
* what does -ml check- show?
* What model are you actually trying to fit? Refer to a paper (full reference please). Also, what is the nature of your survival time data (continuous/discrete; what is the nature of the competing risks; etc.)  Someone may already have code for the model, or a related one, and have tips about how to approach fitting it.


Stephen
------------------
Stephen P. Jenkins <[email protected]>
------------------------------

Date: Thu, 07 Nov 2013 11:43:27 +0100
From: "Amparo Nagore Garcia" <[email protected]>
Subject: st: Problems with ml max Survival analysis

Dear all,

I am trying to maximize my own likelihood function and I get the coefficients but I do not get any other output(Std. Err, z, P>Z.....)
Please, could you help me with this? Is something wrong in my program???.
Just below you could find my ml model, my program and the results that I get.

Thank you in advance.
Amparo

The objective function is the  L= π h(ti|xi)^di S(ti|xi)

********************
my ml model
*******************
ml model d1 CR_stable (cr_05_stable: t0_s t_s d_s= tp* $personal $labour ,nocons), cluster(`ID') 
ml max, difficult

where:
global personal "u_rate   male  h_skill m_skill non_manual  municipio spanish_speakers no_spanish_speaker Aged_16_19 Aged_20_24 Aged_25_29 Aged_30_34 Aged_35_39 Aged_40_44 Aged_45_51 older61 responsabilities"
global labour "construction industry size_0 size_10_19 size_20_49 size_50_249 size_250 discontinuous fix_term on_call duration_1  coefte_num_1 prest_emp" 
global ID "id_bis"

**************************************
The program is the following:
**************************************
capture program drop CR_stable 
****Competing risk without uh
program CR_stable
version 11.2
args todo b lnf g

***Declare and define the arguments of the LL
tempvar beta1
mleval `beta1'=`b', eq(1)

local dt0_1="$ML_y1"
local dt1_1="$ML_y2"
local d1="$ML_y3"

tempvar inthaz1 last  p1
*tempname p1 
tempvar sumb1
sort contadorbis
by contadorbis: gen double `sumb1'=sum(`d1'*`beta1') if $ML_samp

tempvar haz1 
by contadorbis: gen double `haz1'=exp(`sumb1'[_N]) if $ML_samp

by contadorbis: gen double `inthaz1'=sum(exp(`beta1'*(`dt1_1'-`dt0_1'))) if $ML_samp

by contadorbis: gen double `p1'= `haz1'*exp(-`inthaz1'[_N]) if $ML_samp

by contadorbis: gen byte `last'=(_n==_N) 
mlsum `lnf'= ln(`p1') if `last'==1 

*Calculate the gradient,I have to supply dlnl/dtheta and mlvecsum returns dlnL/dbetai=sum dlnl/dtheta*Xij
if(`todo'==0 | `lnf'>=.) exit

mlvecsum `lnf' `g' = `d1'-(`dt1_1'-`dt0_1'), eq(1)
end

**********
the results
**********

. ml max, difficult

initial:       log likelihood = -204354.53
rescaling entire vector +++.
rescale:       log likelihood = -42637.678
- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Iteration 0:
                                                   log likelihood = -42637.678
Gradient length       = 9.21e+09
Step length           =        0
Parameters + step -> new parameters
                                                   log likelihood = -42637.678
                                                           (initial step good)
(1) Stepping forward, step length =        0
                                                   log likelihood = -42637.678
                                                          (ignoring last step)
- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Iteration 1:
                                                   log likelihood = -42637.678
                                                      g inv(H) g' =          0
Gradient length       = 9.21e+09
- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

                                                  Number of obs   =     658755
                                                  Wald chi2(0)    =          .
Log likelihood = -42637.678                       Prob > chi2     =          .

- ------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
- -------------+----------------------------------------------------------------
         tp1 |       -.81          .        .       .            .           .
         tp2 |    -.79875          .        .       .            .           .
         tp3 |    -.79125          .        .       .            .           .
         tp4 |    -.81125          .        .       .            .           .
         tp5 |    -.81375          .        .       .            .           .
         tp6 |    -.82125          .        .       .            .           .
         tp7 |     -.8125          .        .       .            .           .
         tp8 |    -.86125          .        .       .            .           .
         tp9 |    -.85625          .        .       .            .           .
        tp10 |    -.87375          .        .       .            .           .
        tp11 |     -.8875          .        .       .            .           .
        tp12 |       -.88          .        .       .            .           .
        tp13 |     -.8825          .        .       .            .           .
        tp14 |    -.89625          .        .       .            .           .
        tp15 |     -.9025          .        .       .            .           .
        tp16 |    -.89875          .        .       .            .           .
        tp17 |      -.915          .        .       .            .           .
        tp18 |       -.93          .        .       .            .           .
        tp19 |    -.92625          .        .       .            .           .
        tp20 |    -.93625          .        .       .            .           .
        tp21 |    -.96375          .        .       .            .           .
        tp22 |    -.92625          .        .       .            .           .
        tp23 |      -.925          .        .       .            .           .
        tp24 |     -.9475          .        .       .            .           .
        tp25 |    -.82375          .        .       .            .           .
        tp26 |      -1.12          .        .       .            .           .
        tp27 |   -1.00875          .        .       .            .           .
        tp28 |   -1.15375          .        .       .            .           .
      u_rate |   -.469875          .        .       .            .           .
        male |    .014625          .        .       .            .           .
     h_skill |     .01775          .        .       .            .           .
     m_skill |    .000375          .        .       .            .           .
  non_manual |      .0035          .        .       .            .           .
   municipio |     .00075          .        .       .            .           .
spanish_sp~s |    -.01375          .        .       .            .           .
no_spanish~r |    -.03125          .        .       .            .           .
  Aged_16_19 |    -.00875          .        .       .            .           .
  Aged_20_24 |       .026          .        .       .            .           .
  Aged_25_29 |        .04          .        .       .            .           .
  Aged_30_34 |       .041          .        .       .            .           .
  Aged_35_39 |     .04325          .        .       .            .           .
  Aged_40_44 |       .045          .        .       .            .           .
  Aged_45_51 |    .042875          .        .       .            .           .
     older61 |     -.0725          .        .       .            .           .
responsabi~s |    .015625          .        .       .            .           .
construction |     .02325          .        .       .            .           .
    industry |       .006          .        .       .            .           .
      size_0 |    -.00375          .        .       .            .           .
  size_10_19 |    .012125          .        .       .            .           .
  size_20_49 |      .0215          .        .       .            .           .
 size_50_249 |       .029          .        .       .            .           .
    size_250 |     .02475          .        .       .            .           .
discontinu~s |       .223          .        .       .            .           .
    fix_term |    .062625          .        .       .            .           .
     on_call |    .115625          .        .       .            .           .
  duration_1 |  -3.88e-06          .        .       .            .           .
coefte_num_1 |    .002375          .        .       .            .           .
   prest_emp |    -.08625          .        .       .            .           .
- ------------------------------------------------------------------------------

. 
end of do-file



Please access the attached hyperlink for an important electronic communications disclaimer: http://lse.ac.uk/emailDisclaimer

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index