Announcement

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

  • Estimating GB2 income distribution with ml (method lf)

    Dear all,

    I am trying to estimate a GB2 income distribution on binned data using Maximum Likelihood. I follow Chotikapanich et al. (2018) and want to estimate the following Log-likelihood:


    \[ L(\Phi) \propto \sum^{N}_{i = 1} c_i \log[F(x_{i} | \Phi) - F(x_{i-1} | \Phi)] \]


    The corresponding cdf is:


    \[ F(y | a, b, p, q) = \frac{1}{B(p,q} \int_0^{w} t^{p-1}(1 - t)^{q - 1} dt \]


    with


    \[ w = (y/b)^a/[1 + (y/b)^a] \]


    and


    \[ B(p,q) = \int_0^1 t^{p - 1} (1 - t)^{q-1} dt \]



    My data contains an upper limit ("upper") and a lower limit ("lower") for each income class, as well as the number of observations ("weight") in that class (equivalent to c_i in above formula). I have the following code:

    Code:
     program gb2est_lf    
      version 16    
      args lnfj    
      quietly replace `lnfj' = `lnfj' *   ///    
      (ibeta({p},{q},((upper/{b})^{a})/(1+(upper/{b})^{a}))) //      
    - (ibeta({p},{q},((lower/{b})^{a})/(1+(lower/{b})^{a})))
    end  
    
    ml model lf gb2est_lf (weight)    
    
    ml maximize
    The error I receive is "{b} invalid name" after the ml maximize command. Why do I get this error specifically for b? My goal is to estimate the four parameters a, b, p, q.

    Moreover, I´m unsure if I specified the program correctly, since all available examples seem to have explanatory variables and I just want to estimate the distribution.

    Any help is appreciated, thanks.
    Last edited by Torsten Ponik; 08 Dec 2023, 03:21.

  • #2
    OT: Sorry for the formula editing. If someone can give a hint on how to properly format them, I´d appreciate it.

    Comment


    • #3
      I don't have a full solution but you should have "///" instead of "//" in line 5.

      Comment


      • #4
        There are already GB2 fitting programs available. My -gb2fit- and -gb2lfit- are on SSC -- but are for unit record data, and you appear to have banded (interval-censored data). Austin Nichols hacked my code to produce -gbgfit- for grouped data, also on SSC. A more general program for fitting several types of distribution including GB2 to interval-censored data is -gintreg- (McDonald & Triplett, SSC). Using -search- would likely have found you these.

        Comment


        • #5
          Thank you Stephen. I know about gbgfit and have used it already. However, I´m still interested in estimating it manually and would appreciate some help regarding my code (I incorporated John´s suggestion but still got the same error)

          Comment


          • #6
            Off top of my head: your log-likelihood looks odd somehow. Why in first line is `lnfj' on both sides of the equation? Shouldn't there be terms in log(ibeta) rather than ibeta as you have? I referred you to the other programs because, even if you're trying to write your own program, those programs for interval-censored data have evaluator functions that you can look at and 'borrow' from. -viewsource- can be your friend

            Comment


            • #7
              Thank you Stephen! I´ll look at these programs to solve my issue.

              Comment

              Working...
              X