Statalist The Stata Listserver


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

st: efficient way to generate frequency distribution using Mata


From   "Zurab Sajaia" <[email protected]>
To   "statalist" <[email protected]>
Subject   st: efficient way to generate frequency distribution using Mata
Date   Mon, 29 Jan 2007 13:08:05 -0500

Dear all,

At some point in my code, I need to generate aggregated frequency distribution matrix. So I have a dataset with around 4m observations and need to tabulate variable ind, which might have 10,000-100,000 distinct values (=1...100,000).

So far I do it by going through all rows like this:

for (i=1; i<=N; ++i) {
R[ind[i]] = R[ind[i]] + 1
}

where R is a columnvector of size 100,000 and N=4,000,000. I was wandering if there is some smart matrix operation (that I failed to find) to make this part faster? in my case speed will have higher priority then memory usage.

Thanks in advance,
Zurab

*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index