Statalist


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

Re: st: RE: how to transfer scalars from Mata to Stata for a simulation?


From   "Stas Kolenikov" <skolenik@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: how to transfer scalars from Mata to Stata for a simulation?
Date   Fri, 21 Nov 2008 09:44:36 -0600

you can use -st_view- and write a single observation to the current entry:

set obs 1000
gen results = .
mata:
st_view(results=.,.,"results")
for(i=1;i<=1000;i++) {
  // simulation
  results[i] = whatever
}

Or you can return the results to Stata using -st_numscalar()- and
-post- them. Or there might be some two or three other ways to go.

On 11/21/08, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> The first answer sounds like -st_numscalar()- to me. See -help
>  m4_stata-.
>
>  The second question has numerous possible answers. You need to be more
>  precise about what you want.
>
>  Nick
>  n.j.cox@durham.ac.uk
>
>  mujde erten
>
>  I am doing a simulation analysis in Stata. However I need to use some
>  linear algebra and I am using Mata for this. The outcome is a scalar
>  in Mata. But
>  I could not find a way to transfer this to Stata. The problem is
>  although I am using "st_store()" Stata is giving conformability error
>  since my data set is n and the scalar has one observation. Also I need
>  to repeat this and get an observation from each data set in the
>  simulation. Is there a way to deal with this problem? Thanks.
>
>  *
>  *   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/
>


-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.
*
*   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   |   What's new   |   Site index