Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: Keeping values in upper triangle of matrix


From   Michael Betz <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Keeping values in upper triangle of matrix
Date   Wed, 7 Dec 2011 03:36:13 +0000

Awesome Brendan, that's the command I needed! I'm having a problem now with the next step, getting the column vector into Stata. When I use -st_matrix- Stata freezes up. I'm trying to put a 4729350x1 column vector, so I don't know if I'm running into a size problem. I'm using Stata 11 SE. My revised code is below.

foreach x of varlist amenityscale-wages{
	use "Merged1993", clear
	mkmat `x'

	mata: a=st_matrix("`x'")
	mata: b=J(3075,3075,1)
	mata: c=b:*a
	mata: d=c:-a'
	mata: e=vech(d)
	mata: st_matrix("`x'", e)		//This is the step where Stata freezes up

	svmat `x'
	keep `x'
	if `j'>0 merge 1:1 _n using "Finalmat93_00", nogen
	save "Finalmat93_00", replace	
	local j=`j'+1
}

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Brendan Halpin
Sent: Tuesday, December 06, 2011 5:36 PM
To: [email protected]
Subject: Re: st: Keeping values in upper triangle of matrix

On Tue, Dec 06 2011, Michael Betz wrote:

> I wondered if there was a way to
> save all the elements of the upper triangle of the matrix as a column
> vector. 

Check out the vech() function in Mata. 


Brendan
-- 
Brendan Halpin,   Department of Sociology,   University of Limerick,   Ireland
Tel: w +353-61-213147  f +353-61-202569  h +353-61-338562;  Room F1-009 x 3147
mailto:[email protected]    ULSociology on Facebook: http://on.fb.me/fjIK9t
http://teaching.sociology.ul.ie/bhalpin/wordpress         twitter:@ULSociology
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index