Thanks to Kit Baum, an update to the -moremata- package is available
from the SSC Archive.
-moremata- provides various Mata add-ons.
To install the update, type
. ssc install moremata, replace
or use the -adoupdate- command.
The update adds a new function called -mm_cond()-, which extends
Mata's conditional operator to work with matrices.
For example the syntax
: x = (a ? b : c)
only works with a, b, and c being scalar. You can use -mm_cond()- to
relax this restriction and type
: x = mm_cond(a, b, c)
The arguments can now be matrices and a matrix containing
element-by-element evaluations is returned. The input matrices may
even have different dimensions (as long as they are "r-conformable").
Cheers,
ben
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/