Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • eclass store results

    Dear stata users,

    I would like to store a matrix and the number of observations after my eclass program. In this simple example the output is a 6x6 matrix but of course it can contain n elements of the varlist. I am confused because some columns are varying strings which should be stored as macros or colnames? Notice that strings have different categories depending on the other (numeric) variables.
    variable sd rh0(min) cy rh0(max) ph
    x1 1.145 0.950 string1 0.950 string1
    x2 1.155 0.651 string2 0.660 string2
    x3 1.035 0.25 string3 0.254 string3
    x4 0.542 0.550 string4 0.552 string4
    x5 0.663 0.247 string5 0.250 string5








    Many thanks
    Santiago C



  • #2
    There is no string matrix in Stata. So forget about that. Even in Mata you cannot have a mixed type matrix (*).

    To find a meaningful solution to your problem we need to know what your problem is. Right now we have a classic XY problem: https://en.wikipedia.org/wiki/XY_problem . So tell us what you want your program to do, what are those columns, how do you expect the user to use what your program returns.

    (*) Not quite true, but you don't want to go that route. Really trust me on that.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Many thanks for the reponse. Indeed you are right, what I actually did is a program to report some variables with different conditions in terms of correlations. Below I have the last lines before the end
      First I put a I _newline as text "variable" _column(1) as text "sd", then I make another newline with a different string name but then I express column(1) as result %5.3f `sd'.
      For the other conditions I use the same structure with different columns. Results are clean, the only issue is that I want to store the matrix and the total number of observations to then export the results.


      Comment


      • #4
        I still don't understand what you want to do. This is what I do understand:
        • You have written a program
        • It produces some output containing numbers and strings
        • You want to return that output in a matrix
        The last step is impossible, because it is a mix of numbers and strings, as I told you before. So forget about that. It cannot be done.

        There are other things that can be done, but to decide what can be done we need to know what you want to do. So to be able to find a solution, I need you to answer, in detail, all these questions: want is your program supposed to do, what are those columns in the output, how do you expect the user to use what your program returns.
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          Thanks again for responding.
          Of course the last step cannot be done. I will keep the non-string variables or make more lines of coding to treat it in a different way.
          Regards

          Comment


          • #6
            Hi Santiago
            assuming you already know how to store the information you need either in locals, or matrices, here is a good trick.
            Code:
            program adde, eclass
            ereturn `0'
            end
            So, after running your regression, you can add more info to e() using this command
            for example:
            Code:
            sysuse auto,clear
            reg price mpg headroom trunk weight length foreign
            tabstat price mpg headroom trunk weight length foreign, save
            matrix sstat=r(StatTotal)
            adde matrix sum_stats = sstat
            adde local model_des "This regression tries to explain prices as function of car characteristics"
            ereturn list

            Comment

            Working...
            X