Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: mat list


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index