I would like to write a subroutine in mata that can return a several result a once. More precisely if I define a function (myreg for exemple ) defined as
-------------start myreg
function myreg () {
st_view(y, ., st_local("yvar"))
st_view(x, ., st_local("xvar"))
bhat=invsym(x'*x)x'*y // estimated coefficient
uhat=y-x*bhat // residual
}
----------- finish myreg
how can i tell mata to return 2 results
res1=bhat and res2=uhat. res1 and res2 are for use in the rest of my programme.
Ideally I want some thing like this:
{b,u}=myreg() as can i code in gauss for exemple
Abdelrahmen El Lahga
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/