Announcement

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

  • Creating a string matrix populated with string macro

    Hello

    Pretty new to mata and trying to exploit its string matrix capabilities. Not getting far though.

    Probably very simple questions for the listers:

    1. Importing a scalar from stata to mata using
    d=st_local("e(cmd)") // where e(cmd) is a macro from a tabulate estimation command in stata with the contents"tabulate"
    This doesn't work and tips on the syntax or method much appreciated

    2. Using the content of "d" (once successfully imported) to create a vector with n rows with identical contents.
    eg

    1
    1 tabulate
    2 tabulate
    3 tabulate
    4 tabulate
    5 tabulate
    6 tabulate

    Ultimately I want the number of rows to equal the number of estimates in the e(b) matrix for any given tabulate command.

    Answers to any part or all of the above greatly appreciated. There is just not enough examples of these commands in the mata manual or anywhere else for that matter. I reckon it must be simple syntax errors that don't appear as errors but I just don't know.

    Thankyou

    Darren




  • #2
    OK, it was syntax related, so I got the 1st bit sorted by renaming the e(cmd) macro:

    local t=e(cmd)

    /then bringing it into mata

    mata
    cmd=st_local("t")

    Creating the colvector is easy enough:
    z=t\t\t\t etc

    Can anyone help with a program that could create this colvector based on the size of the e(b) estimate matrix size??

    Much appreciated

    Regards

    Darren

    Comment


    • #3
      z = J(cols(st_matrix("e(b)")),1,cmd)

      Comment


      • #4
        regarding 1, try:
        Code:
        d=st_global("e(cmd)")
        Kind regards

        nhb

        Comment


        • #5
          Thanks Niels, Thanks Christophe

          Much appreciated

          Comment

          Working...
          X