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: Working with stored results e() and r()


From   Roberto Ferrer <refp16@gmail.com>
To   Stata Help <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Working with stored results e() and r()
Date   Wed, 20 Nov 2013 11:28:41 -0430

Here is a reply from Stata Tech Support:

*---------------------------------------------------------------

Dear Reberto,

Thank you for pointing the Stata documentation [U] 18.9 to us. From my
understanding, it is trying to say that e(b) and e(V) are essentially
matrices from users' viewpoint (behind the scenes, e() and r() matrices
are not the same thing as ordinary matrices). It may be more accurate to
add that, to avoid syntax issues, it is recommended to copy e(b) or e(V)
to an ordinary matrix before using it.


Though e() and r() matrices are essentially matrices, at the syntax
level, some Stata commands may not understand the names e() and r().
Due to design differences, the returned error among commands such as
-svmat- and -display- could be different. -matrix list- is written in a
way that the names e() and r() can be properly parsed.


Also, e(b) and e(V)'s internal design is different from other e() and
r() results, to allow special features. Therefore, when you ran -svmat
e(V)- and -svmat r(table)-, you got different errors. For general matrix
functions such as -colsof()-, they work with r()/e() results such as
r(table), but return an error

    matrix operators that return matrices not allowed in this context
r(509);

when used with e(b) and e(V).



Hope it helps. Let me know if you have further questions.

Best wishes,


Joy Wang

Statistician
tech-support@stata.com
StataCorp LP

***************************************************************************

On Thu, Nov 14, 2013 at 3:04 PM, Roberto Ferrer <refp16@gmail.com> wrote:
> Two related questions:
>
> 1. Why do I have to save stored results in a -matrix- before doing
> some other operations?
>
> 2. why do errors differ according to the stored result I´m processing ?
>
> According to [U] 18.9 Accessing results calculated by estimation commands:
>
> "5. Estimation commands store the entire coefficient vector and
> variance–covariance matrix of
>  the estimators in e(b) and e(V). These are matrices, and they may be
> manipulated **like any
>  other** matrix..." (Emphasis is mine.)
>
> -matrix list- works fine, but -svmat- and -display-, for example,
> don't. Additionally, depending
> on the stored result, I get different errors.
>
> Below some code:
>
> *--------- begin code ---------
>
> clear all
> set more off
>
> webuse nhanes2f
> svyset [pweight=finalwgt]
>
> svy: proportion sex, over(region)
>
> * This works
> matrix list e(V)
> matrix list r(table)
>
> * This works
> matrix a = e(V)
> svmat a
> display a[3,2]
>
> * This doesn´t work
> svmat e(V) // gives error r(111);
> display e(V)[1,1]
>
> * This doesn´t work
> svmat r(table) // gives error r(198);
> display r(table)[1,1]
>
> *-------- end code ----------
>
> It looks as if Stata is saving e(V) in some matrix/macro with a
> different name. But why
> does -matrix list- work and the others do not?
>
> *
> *   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/

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