Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Using -return matrix- to return other rclass matrix results


From   daniel klein <[email protected]>
To   [email protected]
Subject   Re: st: Using -return matrix- to return other rclass matrix results
Date   Fri, 22 Feb 2013 22:32:51 +0100

Mike,

I do not fully understand what you are trying to do, but you might be
overlooking another problem here. You would like to do

tab ..
return matrix A1 = r(A)
tab ...
return matrix A2 = r(A)
CallSomeOtherProgram ...,

and claim this  "won't work, since -return matrix-, as I understand
it,  doesn't allow the direct assignment of matrices from r()."

This might be true, but even if you could do the assignment, your code
would only return matrix A2. Since -tab- is -rclass- (as I understand)
it will erase any results previously saved in r() -- including A1
after your second call to -tab-.

As you state, -return add- might be a way to go, but if you are
concerned about extraneous junk, temporary objects seem to quite a
good choice to me.

You might also want to have a look into Mata's -st_matrix()- function.
I am not sure this will help, but it might be worth a shot.

Best
Daniel
-- 
Greetings,

I commonly want to return matrices in the midst of rclass programs,
where such matrices come from
matrix results returned by other rclass programs.   What I usually do
is clumsy, as it involves
-tempname- and various reassignments. Here's a toy illustration:

[...]
So, I'd 1) like to return matrices from r() as they are created without going
through the -tempname- and -mat rename- or assignment steps. and 2) to be able
to pass these matrices to another program before returning them.  It seems
that creating temp matrices for this purpose is clumsy. Is there
another approach?
I would presume so, but ...
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index