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: mat list


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: mat list
Date   Tue, 10 Apr 2012 13:42:57 +0200

On Tue, Apr 10, 2012 at 12:33 PM, Chiara Mussida wrote:
> i run a reg and i need to use the coefficients for calculations purposes.
> After my reg i gen a matrix with my betas:
> mat beta=e(b)
> this is a 1*k vector of coef.
> To use them for my manipulation is it enough to refer to them- such:
> beta[1,col] or it is better to gen a scalar for each matrix element?

I have programmed quite a bit of post-estimation commands and I have
never been in a situation where I had to refer to coefficients by
column number. That seems to me an extremely bug-prone method.

I find it often convenient to refer to specific coefficients as
-_b[varname]-. This is mainly because it is easier to see in your code
what coefficient you refer to, so the code becomes easier to read and
debug. This trick does not require that you store your coefficients in
a separate matrix, but it does refer to the currently active model
(which you can manipulate using -est store- and -est restore-).

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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