Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: mata: Colon operators result in matrix output to screen?


From   Thomas Masterson <masterso@levy.org>
To   statalist@hsphsun2.harvard.edu
Subject   st: mata: Colon operators result in matrix output to screen?
Date   Mon, 03 Dec 2007 11:03:35 -0800

A mata question: when I use the function affinity() [code below]
I get the results I expect, but the colon comparison operations
result in the resulting matrix being written to the Stata results
window [quite a nuisance for logging purposes]. Any thoughts why
this happens?

Thanks!
Tom

real colvector affinity(real rowvector ai, real matrix aj, real 
rowvector sd) {
   real matrix aij, upper, lower

   aij = J(rows(aj), 1, 0)
   upper = J(rows(aj), cols(aj), 0)
   lower = J(rows(aj), cols(aj), 0)

   upper = aj
   printf("upper has %4.0g columns and %9.0g rows\n", cols(upper), 
rows(upper))

   lower = aj

   // These two operations print out the entire resulting matrix to the 
screen
   upper:<= ai+sqrt(sd)
   lower:>= ai-sqrt(sd)

   upper:& lower

   aij = rowsum(upper)
   printf("aij has %4.0g columns and %9.0g rows\n", cols(aij), rows(aij))
   return(aij)
}

-- 
*********************************************
   Thomas Masterson
   Research Scholar
   Distribution of Income and Wealth Project
   Levy Economics Institute of Bard College
   Annandale-on-Hudson, NY  12504
   (845) 758-7715
   http://www.levy.org
*********************************************

*
*   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/



© Copyright 1996–2022 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index