Suppose I want to run a maximum likelihood program that calls another maximum likelihood program. (For example: suppose I have two equations and one of them is essentially an ordered logit, which is rather difficult to program from scratch, as numerical approximations make an lf0 estimator take forever.) So I write something like
This will produce the output:
I'm pretty sure the reason is that ml state is stored in global variables, which are overwritten when ologit is called. Is this correct? Does this mean that one can never use an ml estimation command within another ml evaluator, or is there some kind of workaround?
Code:
program define myeval args lnfj Xb ologit $ML_y1 `Xb' tempvar lnfj_part1 predict `lnfj_part1', pr ... replace `lnfj' = log(`lnfj_part1')+... end
Code:
variable _MLtua1 not found st_data(): 3500 invalid Stata variable name mopt__st_user_lf1(): - function returned error mopt__calluser_lf2(): - function returned error opt__eval_nr_lf1(): - function returned error opt__eval(): - function returned error _optimize_evaluate(): - function returned error _mopt__evaluate(): - function returned error _moptimize_evaluate(): - function returned error _moptimize_search(): - function returned error Mopt_search(): - function returned error <istmt>: - function returned error r(3500);
Comment