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, statalist.org is already up and running.


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

Re: st: Append new row to existing matrix


From   Jorge Eduardo Pérez Pérez <perez.jorge@ur.edu.co>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Append new row to existing matrix
Date   Sat, 24 Mar 2012 19:20:46 -0400

clear
set obs 100
gen y=uniform()
forv i=1(1)100 {
	qui gen x`i'=uniform()
	qui reg y x`i'
	matrix b=e(b)
	if `i'==1 matrix betas=b
	else matrix betas=(betas \ b)
	drop x`i'	
}
matrix list betas

Also, take a look at -statsby-
_______________________
Jorge Eduardo Pérez Pérez



On Sat, Mar 24, 2012 at 7:11 PM, Sandy Y.  Zhu <sandy.zhu@yale.edu> wrote:
> Hi guys:
>
> How can I append a new row to an existing matrix? Basically, I'm
> trying to update the matrix in a loop,
>
> I have:
>
> for i=1 to 900
> {reg y x1 x2 x3
> mat beta=e(b)
>
> append e(b) to an existing matrix}
>
> Basically, I  have 900 regressions to run, and I  need to save the
> beta values from each regression. I would like to save them all in a
> matrix, so the first row in the matrix saves the betas from the 1st
> regression, the 2nd row would save the coefficients from the 2nd
> regression, etc....
>
>
> Thank you!
>
> --
> Yours sincerely,
>
> Sandy Y. Zhu
> *
> *   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/
>
>


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index