The paper on the method is:

R. Garrappa, Numerical evaluation of two and three parameter Mittag-Leffler functions,

The MATLAB code, with basic documentation, is at https://www.mathworks.com/matlabcent...ffler-function

This is a direct port: the syntax and functionality remain the same.

The code sits in a GIthub repository: https://github.com/droodman/Mittag-Leffler-for-Stata

Only one file is needed, MittagLeffler.mata. You can download it directly from there. Or in Stata, type

Code:

net from https://raw.github.com/droodman/Mittag-Leffler-for-Stata/master

To use the program, you'll need to manually compile MittagLeffler.mata. Just run it once as if it were a do file. That will make the mlf() function permanently available.

--David]]>

Code:

capture mata mata drop reindex() mata function reindex(v,updown) { real matrix rv,chg rv=sort(v,1) chg=1 while (chg>0) { chg=0 for (j=1;j<=(rows(v)-1);j++) { if (rv[j]==rv[j+1]) { chg=chg+1 rv[j]=rv[j]+updown } } } return(rv) } end

Code:

. do "/var/folders/d5/6w9t_lzx3plbpmk6zpyz93dm0000gp/T//SD09710.000000" . capture mata mata drop reindex() . . mata ------------------------------------------------- mata (type end to exit) ------------------------------------- : : function reindex(v,updown) { > real matrix rv,chg > > rv=sort(v,1) > chg=1 > while (chg>0) { > chg=0 > for (j=1;j<=(rows(v)-1);j++) { > if (rv[j]==rv[j+1]) { > chg=chg+1 > rv[j]=rv[j]+updown > } > } > } > return(rv) > }variable j undeclared r(3000);: : end --------------------------------------------------------------------------------------------------------------- . end of do-file

Does anyone have insights into why this r(3000) error might be arising? I can certainly do a work-around, but mostly I'm curious why such an error would arise at all.

Thanks for any insights you might be able to share.]]>

Code:

version 14.2 webuse sysdsn1, clear keep if insure !=. mlogit insure age male nonwhite i.site matrix define b = e(b) tempname noomit _ms_omit_info b local cols = colsof(b) matrix `noomit' = J(1,`cols',1) - r(omit) tab insure, g(insure) tab site, g(site) mata st_view(y1=.,., "insure1") st_view(y2=.,., "insure2") st_view(y3=.,., "insure3") N=rows(y1) cons=J(N,1,1) st_view(X=.,.,"age male nonwhite site2 site3") X=X, cons b=select(st_matrix("b"),(st_matrix(st_local("noomit")))) xb2 = X*b[1..6]' xb3 = X*b[7..12]' p1 = 1 :/ (1 :+ exp(xb2) :+ exp(xb3)) p2 = exp(xb2) :/ (1 :+ exp(xb2) :+ exp(xb3)) p3 = exp(xb3) :/ (1 :+ exp(xb2) :+ exp(xb3)) s1 = X'*(y2 - p2) end

Jessica]]>

Thank you in advance.

Olga

id | anndat | statper |

1 | 14Feb2014 | 17apr2014 |

1 | 7May2014 | 19Sep2014 |

1 | 06Aug2014 | 17Nov2014 |

2 | 30Jan2015 | 17Sep2015 |

2 | 28Oct2015 | 18Oct2015 |

I would like to ask you a question about an 'End Duplicates' error in my mata programming.

My program is used to compute some matrixs. Considering the computing limit of stata, I need to use mata language. I wrote a do file for mata-stata interaface. I also want to use an ado programmingwhichmakes all kinds of do files run. But the problem is, in my program, the ado programming and the mata programming have the repeated same 'End'. Thus my stata report a error called ‘End Duplicates’.

So, I would like to ask you two questions.

Second, if my idea is resaonable, how to code in order to interface mata programming with ado programming?

My codes are:

Code:

/*Define program*/ program define MYPROGRAM version 14.0 /*Define syntax*/ syntax using/, [name(string) * [ ... ] // some other options use "`using'", clear // import data confirm name `name' /*Create and Compute Matrix use Mata*/ mata: ... create a matrix named MATRIX ... /*End Mata*/ end /*End Program*/ end // you can see that, there are two 'end's make 'end duplicates' and end unrecognize

Thank you very much for your answer!]]>