Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: How to convert a MATA matrix into a STATA matrix?


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: How to convert a MATA matrix into a STATA matrix?
Date   Fri, 3 Mar 2006 16:09:34 -0000

When Bill says the next issue of the 
Stata Journal, he meant the current one. 

Nick 
n.j.cox@durham.ac.uk 

William Gould, Stata
 
> Ulrich Kaiser <uka@sam.sdu.dk> ask, 
> 
> > My Mata code is
> > 
> >    mata
> >    m_all 	= st_matrix("all")
> >    nom	= m_all[1...,2]
> >    denom	= m_all[1...,3]
> >    denom	= (denom:/denom)-denom 
> >    lr 	= nom :/ denom
> >    out	= m_all[1...,1], lr, m_all[1...,4], m_all[1...,5]
> >    end
> >
> > and I'd like to turn "out" into data format.
> > 
> > Any ideas?
> 
> The "Mata Matters" column in the next Stata Journal deals 
> with exactly 
> this problem.  The title of the column is "Creating new variables"
> with the subtitle, "Sounds boring, isn't", although I don't 
> know if the editors let me keep that last part.
> 
> Anyway, I suggest Uli read that, because I hada lot to say, 
> all of it relevant.
> 
> In the meantime, let me provide a crude solution to Uli's problem.
> 
> First thing, Uli, is to create the variables in the Stata dataset 
> to hold the columns of out.  In what follows, I will assume those 
> variables are named x1, x2, and x3.
> 
> Second thing, I assume that the Stata dataset has the number 
> of observations
> as out has rows.
> 
> Given that, one solution is 
> 
>         st_store(., ("x1", "x2", "x3"), out)
> 
> See [M-5] st_store().

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2020 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index