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: st_numscalar to pass a calculation result from Mata to Stata


From   Amir Fekrazad <amir.fekrazad@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: st_numscalar to pass a calculation result from Mata to Stata
Date   Fri, 29 Apr 2011 21:50:47 +0330

Thank you Nick. I tried what you told and found out that no precision was lost.

On Fri, Apr 29, 2011 at 9:21 PM, Nick Cox <njcoxstata@gmail.com> wrote:
> So, you should test whether precision has been lost by using a
> non-default format such as %23.18f or %21x to display your scalar.
>
> Nick
>
> On Fri, Apr 29, 2011 at 6:24 PM, Amir Fekrazad <amir.fekrazad@gmail.com> wrote:
>> I use a Mata function to do some matrix calculation and then pass the
>> result to Stata using:
>> st_numscalar("varName", varValue)
>>
>> and in my Stata code I use:
>> scalar `varName' = varName
>>
>> to obtain the value passed from Mata.
>>
>> The problem is, is seems that some precision is lost through this
>> transfer. For example, while the result of the Mata function
>> (displayed in Mata environment) is 202.6188514, the value passed to
>> Stata  (displayed in Stata environment) is 202.61885.
>>
>> I do not know if this is just the difference of displaying format in
>> Mata or Stata, or actually some precision is lost. Any advice is
>> appreciated.
>>
>>
>
> *
> *   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/
>

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