Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: mata: how function can return several results


From   "Ben Jann" <ben.jann@soz.gess.ethz.ch>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: mata: how function can return several results
Date   Mon, 16 Oct 2006 09:19:00 +0200

See

 http://www.stata.com/statalist/archive/2006-06/msg00306.html

ben

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of U.A.QU.AP
> Sent: Sunday, October 15, 2006 3:03 AM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: mata: how function can return several results
> 
> 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/

*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index