Announcement

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

  • Divide a matrix

    Hello,

    How can I devide a matrix by an other matrix (not a division by scalar) ?
    By the way, I tried : mat xxx = zz * 1/yy , without résult...

    Thank you for your answer
    Marc

  • #2
    You can do it by pushing into Mata, doing the work there, and pulling the results out of Mata:

    Code:
    . matrix X = (4, 8 \ 16, 32)
    
    . matrix Y = (2, 2 \ 4,4)
    
    . mata: st_matrix("XoverY", st_matrix("X") :/ st_matrix("Y"))
    
    . matrix li XoverY
    
    symmetric XoverY[2,2]
        c1  c2
    r1   2
    r2   4   8
    There is also a clunky 1999 vintage program matewd

    STB-50 dm69 . . . . . . . . . . . . . . . . . . Further new matrix commands
    (help matdelrc, matewm, matmad, matpow if installed) . . . N. J. Cox
    7/99 pp.5--9; STB Reprints Vol 9, pp.29--34
    collection of new matrix commands providing additional matrix
    checking, management, element-wise operators, maximum absolute
    difference, and power


    You're better off learning some Mata!

    Comment


    • #3
      Thank you, I'm Mata Happy !

      Comment


      • #4
        Hi,

        I would like to sum two variables of my sample and then divide these two results together. Finally I would like to export both sum and the result of the division.

        I found a way for both sum but I do not find how to proceed for the division. I have the following code :

        Code:
        .estpost tabstat VARIABLE1 if year == 2008, statistics(sum)
        .esttab, wide nonumber cell("sum(label(Total Variable1 in 2008))")
        .mat II = e(sum)'
        .estpost tabstat VARIABLE2 if year == 2008, statistics(sum)
        .esttab, wide nonumber cell("sum(label(Total Variable2 in 2008))")
        .mat JJ = e(sum)'
        .putexcel set "name.xlsx", replace
        .putexcel A3 = "2008"
        .putexcel B3 = matrix(II)
        .putexcel C3 = matrix(JJ)

        Thank you in advance.

        David

        Comment

        Working...
        X