Statalist


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

st: Log-likelihood never converges


From   "Hendratno Tuhiman" <hendratno.tuhiman@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Log-likelihood never converges
Date   Sun, 23 Mar 2008 13:20:35 +0700

Dear Statalisters,

I am running a maximization procedure to maximize benefit of Y with Xb
<= percentiles 16. I first run the regular ml model (least squares
with normal error) to get the betas from first model. I then use these
betas as initial values for the second ml.  Using my dataset, consist
of 8635 observations, the log-likelihood after a number of iterations
takes a value which does not change over subsequent iterations  I have
to break the procedure. I don't know what is the problem, It's my
first time using ml procedure. Could someone have a way to solve  this
problem ?


Best regard,

Hendro

Here is the program:


version 9.2

set more off
clear
set mem 256m

cap log using treatment-b-exp2,replace text


cap program drop maxreg1
program maxreg1

  args todo b lnf
  tempvar xb lnfj temprank d
  tempname mu lnmu

  mleval `xb'   = `b', eq(1)
  mleval `lnmu'   = `b', eq(2) scalar


  scalar `mu' = exp(`lnmu')
  qui gen double `lnfj' = ln(normd($ML_y1,`xb',`mu'))
  mlsum `lnf' = `lnfj'



end


cap program drop maxreg
program maxreg

  args todo b lnf
  tempvar xb lnfj temprank d

  mleval `xb'   = `b', eq(1)

  gsort +`xb' +$ML_y1
  g `temprank' = _n
  qui count if `xb' != .
  local tempcount = r(N)

  qui g `d' = (`temprank' < `tempcount' * 0.16)

  qui gen `lnfj' = $ML_y1 * `d'


 mlsum `lnf' = `lnfj'
end

cap program drop mutility
program define mutility
    syntax anything(name=pcexp), [pl(varname) rho(real 12345)
alpha(real 12345)] [gen(varname)]

    if "`gen'"!="" {
       local genvar = "`gen'"
    }
    else {
       local genvar = "mutility"
    }
    gen double `genvar'=cond(pcexp <= `pl',pcexp^-`rho',`alpha'*(pcexp^-`rho'))
end

use if b1r1==16 using k:\targetting\sus2006\indics06,clear

mutility pcexp,pl(povline) rho(2) alpha(0.5)

ml model d0 maxreg1 (xb : mutility = house troof1 troof2 twall tfloor
pcfloor water toilet septic lighting) (lnmu:)
ml max
matrix startval = e(b)
ml model d0 maxreg (xb : mutility = house troof1 troof2 twall tfloor
pcfloor water toilet septic lighting)
ml init startval, skip
ml max, difficult

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



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index