help mata mm_which()
-------------------------------------------------------------------------------

Title

mm_which() -- Positions of nonzero elements

Syntax

real vector mm_which(real vector v)

Description

mm_which() returns the position of the nonzero elements in v.

Remarks

Example:

: x = uniform(10,1) : x 1 +---------------+ 1 | .6942035381 | 2 | .9866539028 | 3 | .339872522 | 4 | .4785448909 | 5 | .1890356159 | 6 | .2186723398 | 7 | .495693512 | 8 | .7756144393 | 9 | .733696372 | 10 | .4224797708 | +---------------+

: mm_which(x:>.5) 1 +-----+ 1 | 1 | 2 | 2 | 3 | 8 | 4 | 9 | +-----+

Conformability

mm_which(v) v: 1 x c or r x 1 result: 1 x c1 or r1 x 1.

Diagnostics

mm_which(0) returns J(0,0,.).

Source code

mm_which.mata

Author

Ben Jann, ETH Zurich, jann@soz.gess.ethz.ch

Also see