Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Errors in running a generalized gamma model via log-likelihood

    Hi, I am trying to run a generalized gamma model via log-likelihood. I think that the code is correct, but the following error message appears: could not find feasible values. Could you see what is wrong here? $y is health care spending and $xs includes age, sex, and diagnoses.

    My codes is as follows:

    /*Generalised Gamma*/

    *Input log-likelihood

    program gglog

    args lnf mu sigma kappa

    local y "$ML_y1"

    quietly {
    replace `lnf' = ln(abs(`kappa')) - ln(`sigma') - ln(`y') - lngamma(`kappa'^-2) + ln(((`y'/exp(`mu'))^(`kappa'/`sigma'))/`kappa'^2)/`kappa'^2 - ((`y'/exp(`mu'))^(`kappa'/`sigma'))/`kappa'^2
    }
    end

    *Estimate Generalised Gamma

    capture noisily ml model lf gglog (mu: $y = $xs) /sigma /kappa, technique(nr 50 bfgs 50 dfp 50 bhhh 50)
    capture noisily ml search
    capture noisily ml max


    Here is the results.

    . capture noisily ml model lf gglog (mu: $y = $xs) /sigma /kappa, technique(nr > 50 bfgs 50 dfp 50 bhhh 50)

    . capture noisily ml search
    initial: log likelihood = -<inf> (could not be evaluated) could not find feasible values

    . capture noisily ml max initial: log likelihood = -<inf> (could not be evaluated) could not find feasible values



    Thank you in advance!

  • #2
    Welcome to Statalist. Please read the FAQ (hit the black bar at the top of the page), and note the advice, especially about the use of "CODE" delimiters to maximise legibility.

    I do not have the time to scrutinise your code, but you might like to compare it with the ado file code in the ML evaluator file that accompanies (say) gammafit on SSC (ssc describe gammafit) or other *fit programs on SSC (including invgammafit )

    Kleiber and Kotz (Statististical Size Distributions in Economics and Actuarial Science, Wiley, 2003) remark that fitting of GG distributions by ML is "not straightforward" (p. 156), and discuss why, with literature references.

    But it may be possible (as long as you carefully check that you reach a global maximum not a local one) -- after all, McDonald (Econometrica 1984) managed to fit GG distributions to grouped (banded) data using a multinomial ML procedure.

    This suggests that (assuming your code is correct), you should experiment with feeding starting values to the evaluator. Look at the from() option

    It's not immediately obvious to me how your parameters kappa, sigma, and mu relate to the beta, a and p parameters in Kleiber and Kotz's specification of the GG model. Whatever, ensure that any non-negativity restrictions on parameters are imposed. Use log transformations of parameters in the evaluator, and then derive estimates in the original metric after estimation using _diparm etc.

    Comment

    Working...
    X