Announcement

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

  • Fixed Point within Likelihood Function of ml Command

    I would like to use the ml command to code up a multinomial logit likelihood function that includes a fixed-point mapping.

    For a basic MNL function, I would define:
    Code:
    program define fpmlogit
        args lnf Xb1 Xb2
        quietly replace `lnf' = `Xb1' - ln(1 + exp(-`Xb1') + exp(-`Xb2')) if $ML_y1==1
        quietly replace `lnf' = `Xb2' - ln(1 + exp(-`Xb1') + exp(-`Xb2')) if $ML_y1==2
        quietly replace `lnf' = - ln(1 + exp(-`Xb1') + exp(-`Xb2')) if $ML_y1==3
    end
    However, my understanding is that this works on an observation-by-observation basis. I want to use the full sample to iterate on a fixed effect of group g until convergence of modeled and observed shares within g so that the code is more like:
    Code:
    program define fpmlogit
        args lnf Xb1 Xb2
        quietly replace `lnf' = `Xb1' + `xig1' - ln(1 + exp(-`Xb1' - `xig1') + exp(-`Xb2'- `xig2')) if $ML_y1==1
        quietly replace `lnf' = `Xb2' + `xig2'- ln(1 + exp(-`Xb1' - `xig1') + exp(-`Xb2'- `xig2')) if $ML_y1==2
        quietly replace `lnf' = - ln(1 + exp(-`Xb1' - `xig1') + exp(-`Xb2'- `xig2')) if $ML_y1==3
    end
    And I can't pass `xig[outcome]' as an argument because it's a function of the parameters in `Xb[outcome]'. Is this possible with the ml command?
Working...
X