Announcement

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

  • Scalar (element by element) multiplication/division of two Matrices

    Hi Everyone,

    How can I multiply/divide two matrices (datasets) in Stata or Mata (1000x1000 or 1000 var/1000 obs) in scalar way (ie element by element)? I mean, for example ( 9 6 3 / 8 4 2) / (3 2 1 / 4 4 2) = ( 3 3 3 / 2 1 1) . Thanks in advance

  • #2
    Originally posted by Cosku Mihci View Post
    How can I multiply/divide two matrices (datasets) in . . . Mata . . . element by element)?
    For matrices take a look here. And for datasets start here.

    Comment


    • #3
      For multiplication, Stata has the -hadamard- function. See -help hadamard()-

      Mata has what are termed "colon operators" that permit a wide selection of "element-wise" calculations (multiplication, division, addition, etc.) See -help [M-2] op_colon-

      Note, by the way, that the way you have written matrices will not work in Stata or Mata, since elements of rows need to be separated by commas and rows need to be separated by backslashes.

      Comment

      Working...
      X