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: matrix problem


From   Richard Goldstein <richgold@ix.netcom.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: matrix problem
Date   Wed, 15 May 2013 11:37:04 -0400

Maarten, Scott

thank you very much; each solution works :-)

Best,
Rich

On 5/15/13 11:18 AM, Scott Merryman wrote:
> If you create a new matrix equal to r(table) you to reference
> individual elements:
> 
> sysuse auto,clear
> somersd price mpg
> mat a = r(table)
> scalar c = a[1,1]+ 2
> scalar list c
> 
> Scott
> 
> 
> On Wed, May 15, 2013 at 10:13 AM, Maarten Buis <maartenlbuis@gmail.com> wrote:
>> you can exctract a scalar from a table using the -el()- function, see
>> -help el()-.
>>
>> -- Maarten
>>
>> On Wed, May 15, 2013 at 5:04 PM, Richard Goldstein
>> <richgold@ix.netcom.com> wrote:
>>> Hi all,
>>>
>>> I am using Newson's -somersd- command (from ssc); results, including the
>>> piece I want, are saved in a matrix and I can list that matrix:
>>>
>>> . mat list r(table)
>>>
>>> r(table)[9,1]
>>>             yhat1
>>>      b  .62563699
>>>     se  .00834334
>>>      t  74.986391
>>> pvalue  3.73e-257
>>>     ll  .60924043
>>>     ul  .64203354
>>>     df        452
>>>   crit  1.9652262
>>>  eform          0
>>>
>>> My problem comes in attempting to use the [1,1] term (.62563699 here);
>>> for example, I can't seem to list it:
>>>
>>> . matrix li r(table)[1,1]
>>> [ invalid name
>>> matrix [1,1] not found
>>> r(111)
>>>
>>> and I can't do what I want to do - add this value to a scalar:
>>>
>>> scalar cstat=cstat+r(table)[1,1]
>>> invalid syntax
>>> r(198)
>>>
>>> note that cstat is not the problem as it is defined (as 0) prior to
>>> entering my loop
>>>
>>> clearly I am doing something wrong but I have been unable to figure out
>>> what it is or how to fix it
>>>
>>> Rich
>>> *
>>> *   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/
>>
>>
>>
>> --
>> ---------------------------------
>> Maarten L. Buis
>> WZB
>> Reichpietschufer 50
>> 10785 Berlin
>> Germany
>>
>> http://www.maartenbuis.nl
>> ---------------------------------
>> *
>> *   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/
> 
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index