Announcement

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

  • Obtain standard deviation after matrix calculation

    Dear Stata Users,

    Maybe somebody can help me out with this. After a regression, I want to calculate a specific term with the estimated parameters, using matrices. I know I can write, for example:

    Code:
    matrix A = (_b[est1]*_b[est2] \ _b[est3] + _b[est4])
    matrix B = (_b[est5], _b[est6])
    Now I want to multiply matrix A and matrix B, and obtain the standard deviation of the result. I tried the Delta method with
    Code:
    nlcom A * B
    , but this yields the error message "matrix operators that return matrices not allowed in this context". I know I could type
    Code:
    matrix AB = A*B
    and then extract the result with
    Code:
    scalar AtimesB = AB[1,1]
    , but how can I obtain the associated standard deviation then?

    Thank you very much in advance, your help is highly appreciated.

    Kind regards
    Stefan

  • #2
    Well, as you have discovered, -nlcom- does not accept matrices, and matrix calculations do not produce standard errors.

    Your particular instance is short enough that it is easy to just unwind the matrix product and directly put the resulting expression into -nlcom-

    Code:
    nlcom _b[est1]*_b[est2]*_b[est5] + (_b[est3] + _b[est4])*_b[est6]

    Comment


    • #3
      Thanks a lot for your answer. I just simplified matters by making up a very easy example. In my real problem, I have 8x8 matrices so that it would be convenient if I would not have to unwind the matrix product. But if there is no other solution, I can surely do that...

      Comment


      • #4
        Another problem occured now. In my matrix calculation, I need to derive the inverse matrix. Does anybody have a hint how to treat standard deviations while doing this?

        Thank you very much!

        Comment

        Working...
        X