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

RE: [SPAM] - st: Returning Mata Results to Stata - Email has different SMTP TO: and MIME TO: fields in the email addresses

From   "??? ????" <>
To   <>
Subject   RE: [SPAM] - st: Returning Mata Results to Stata - Email has different SMTP TO: and MIME TO: fields in the email addresses
Date   Tue, 16 Oct 2007 19:43:38 +0400


Judging on my experience with Mata, I guess your problem is due either to matrix size when you export your results from Mata back to Stata, or by the format of the data you export (Mata is not terribly efficient in coding data as numeric or string, as far as I can see). 

If you process your data in Stata cycle, your problem almost surely can be solved by exporting your results to Stata one-by-one. The algorithm is this: 

1. Create an empty variable Result_1 in Stata

2. Start cycle in Stata (indexed by `s'), in which run your Mata routine for each observation, and write its result in 1-by-1 matrix "tempmata". Export the result within the same iteration `s' of Stata as 1-by-1 matrix using 
- st_matrix("tempmata", tempstata) -

3. Code 
- local tstat tempstata[1,1] - 
- replace Result_1`s'=`tstat' -

4. Repeat the process for the next value of s up to the end of the cycle, i.e. until you fill the variable Result1, and so on for the other variables.

I am not sure this is the most efficient solution, but with Stata 9.2 and corresponding Mata it should work.

Alexis Belianin
ICEF, Moscow

>-----Original Message-----
>[]On Behalf Of Thomas Jacobs
>Sent: Tuesday, October 16, 2007 6:33 PM
>To: StataList
>Subject: [SPAM] - st: Returning Mata Results to Stata - Email 
>has different SMTP TO: and MIME TO: fields in the email addresses
>I am trying to decipher the manuals for mata to do something that I
>imagine is pretty simple, returning my results from mata to (ideally)
>matching observations for my starting data in Stata.  I basically use
>the st_data command to move my stata based observations into a mata
>matrix as follows:
>I = st_data(., "var 1", "var2", etc.)
>I now have a mata based matrix, I, that has all of my data including
>identification data such as company number and trading day.
>I next use the information variables to produce some new values and
>let us assume I create a new matrix in mata called results that has
>the following form
>Results = (Company Number, Trade Day, Result 1, Result 2, etc.)
>where the rows are different observations.
>Back in Stata I have variables such as
>Company Number, Trade Day, Input Data1, Input Data 2, etc.
>My goal is to append the mata based information into new stata
>variables with matching observations that would appear as follows:
>Company Number, Trade Day, Input Data 1, ...Input Data n, Result 1,
>...Result n, etc.
>I have struggled in vain to decipher the mata manual for commands such
>as creating new stata variables from mata (st_addvar), adding
>observations (st_addobs), and modifying or moving values (st_store)
>but have had zero luck in getting anything to work.  At this point I
>am thinking I may simply need to write an output file from mata, close
>mata and insheet the output file into stata to append to the dataset
>Can anyone provide any thoughts or suggestions on how to proceed?
>With great thanks,
>Thomas Jacobs
>*   For searches and help try:

*   For searches and help try:

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