Announcement

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

  • How to add a macro/string variable to a matrix

    I run a structural break test using the command estat sbsingle for a large number of regressions. I would like to generate a matrix called mbreak with the estimation results. I have no problem adding the p-value and test statistic from the return list to my matrix, but I have difficulties, adding the break date. The break date is stored in the results list as a macro r(breaktest). How can I add it to my matrix? The break date variable is in date format...

    It tried already:
    matrix mbreak[`x',4] = r(breakdate)

    or
    local Date = r(breakdate)
    matrix mbreak_`y'[`x',4] = `Date'

    But it doesn't work.

    Thanks in advance for your support!

  • #2
    matrix mbreak[`x',4] = `r(breakdate)' should work, shouldn't it?

    Comment


    • #3
      No, unfortunately I get the error message:
      2011q2 not found

      r(111);

      2011q2 is the break date...

      Comment


      • #4
        Matrices in Stata can only contain numeric results. A quarterly date can be (for Stata, is) numeric, which may possibly help you.

        Code:
        . di yq(2011, 2)
        205

        Comment


        • #5
          I found a solution:

          1. first transforming the date variable to a numerical variable
          2. running the test
          3. adding this numerical variable to the matrix
          4. transforming this matrix to a separate stata data file using svmat
          5. transforming the numerical date variable to a official date variable...

          Comment

          Working...
          X