Statalist


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

Re: st: Basic matrix functions


From   Tirthankar Chakravarty <[email protected]>
To   [email protected]
Subject   Re: st: Basic matrix functions
Date   Wed, 27 Jan 2010 19:44:53 +0530

<>

There are probably many ways to do this, but here is one:

*****************************
clear*
set matsize 1000
mat define example = matuniform(1000,14)

// extract the 77th row (say)
mat define example2 = example[77, 1...]
mat list example2

// append in a loop
forv i=1/100 {
	mat define example3 = (nullmat(example3) \ matuniform(1,14))
}
mat list example3

// calculate the standard deviation of each column (using Mata)
mata: st_matrix("example4", diagonal(sqrt(variance(st_matrix("example3")))))
mat list example4
*****************************


On Wed, Jan 27, 2010 at 7:21 PM, XU Moqi <[email protected]> wrote:
> Dear list,
>
> I'm struggling to use the matrix functions:
>
> 1) I have a nx14 matrix called A and would like to extract a new matrix
> that consists of line i of Matrix A.
>
> 2) I'm running a loop, and in each stage, I create a new 1x14 matrix. I
> would like to append this line to a matrix B.
>
> 3) Then I would like to calculate the standard deviation of each column
> of matrix B.
>
> Thank you very much for your help!
>
> Moqi
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>



-- 
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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