I wonder if anyone has a better solution to the following problem.
Say that I'm interested in estimating K linear regressions simultaneously using -ml- approach.
where K is variable, But I know it beforehand, But I do not want to write the program that defines the Loglikehood for every case (every k in K)
So I came up with this solution:
My program will be:
Code:
program myols2 args lnf $args qui { replace `lnf'=0 forvalues i = 1/$k { replace `lnf'=`lnf' + log(normalden(${ML_y`i'},`xb`i'',exp(`lns`i''))) } } end
Code:
global k 2 global args xb1 lns1 xb2 lns2 ml model lf myols2 ( price = foreign weight length) /lns1 (mpg =foreign weight) /lns2 ml maximize global k 3 global args xb1 lns1 xb2 lns2 xb3 lns3 ml model lf myols2 ( price = foreign weight length) /lns1 (mpg =foreign weight) /lns2 (displ = foreign weight) /lns3 ml maximize
Since globals can some times be problematic (as they could create conflicts that could be undetectable when using multiple programs), I wonder if anyone has an alternative solution to modify the number of "arguments
my "myols2" programs should accept, or the number of equations to be estimated.
Thank you
Fernando
0 Response to How to modify arguments (args) in a ML program?
Post a Comment