Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: how to summarize a big matrix

From   Matthew Baker <>
Subject   Re: st: how to summarize a big matrix
Date   Tue, 9 Apr 2013 08:49:03 -0400

Wu --

The mata function sum() adds up everything in an arbitrary matrix, I
believe, so you might get your matrix into mata and compute the sum
that way, and then return the result as a scalar to stata. For

mat Z=1,2,3 \ 4,5,6 \7,8,9
display sum

For even very large matrices, the mata "sum" function is quite fast, I
have found.

Hope that helps!

Matt Baker

On Mon, Apr 8, 2013 at 4:40 PM, Wu Zhang <> wrote:
> Hi there,
>    I am required to investigate the elements of a big matrix(1000X1000); what I am trying to do now is to VEC the matrix and change it into a variable, then use "sum" in stata. But that is very slow.
>   I am just wondering whether there is an easier way to summarize the matrix directly? By the way, the matrix is symmetric.
> Thank you very much!
> Wu
> *
> *   For searches and help try:
> *
> *
> *

Dr. Matthew J. Baker
Department of Economics
Hunter College and the Graduate Center, CUNY
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index