0
votes

I want to make my ml program ( ado file) byable (i.e. allow the use of by). For that purpose, I was going through Maximum Likelihood Estimation with Stata third edition to see whether I need to take special consideration for ml program, other than those mentioned in programming manual. In p. 170 of the book, the author suggests the reader to look into the manual. So, I was wondering whether we need to take special consideration (other than that mentioned in the manual)for making the ml program byable

1
I'd ask why you want to do this. A major consequence would be that only the results for the last estimation remain accessible after fitting. For many purposes that would be problematic. If you want to fit a given model repeatedly to different groups, use the machinery provided by statsby instead.Nick Cox
@Nick: Thank you for your advice. I will look into statsby.Metrics

1 Answers

2
votes

With any programming project there are a milion things and more that can go wrong, so there can never be a guarantee that there is not something specific about your maximum likelihood program that breaks things. However, in general you should be fine. I copy the relevant top part of a program Nick, Stephen Jenkins and I have written some time ago (betafit), that makes betafit "byable".

/*------------------------------------------------ playback request */
program betafit, eclass byable(onecall)
        ...
        if replay() {
                if "`e(cmd)'" != "betafit" {
                        di as err "results for betafit not found"
                        exit 301
                }
                if _by() error 190 
                Display `0'
                exit `rc'
        }
        if _by() by `_byvars'`_byrc0': Estimate `0'
        else Estimate `0'
end

/*------------------------------------------------ estimation */
program Estimate, eclass byable(recall)
     ...