Statalist


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

st: RE: Matrix command - vecdiag?


From   "Brent Fulton" <[email protected]>
To   <[email protected]>
Subject   st: RE: Matrix command - vecdiag?
Date   Sun, 2 Sep 2007 18:04:59 -0700

Hi Tiago,

I'm fairly sure you cannot store a non-numeric value in a matrix (as opposed
to a list in R that accepts strings). However, you could store your file
names as row names in the matrix. Inside your loop, add:

local rownames1 = "`rownames1' `u'_replication_number_`i'.dta"

Then outside your loop, add:

matrix rownames M = `rownames1'

Note that a space precedes the first rowname. I'm not sure if that matters,
but you could use the following the first time through your loop.

local rownames1 = "`u'_replication_number_`i'.dta"

Best,
Brent Fulton



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Sunday, September 02, 2007 3:19 PM
To: [email protected]
Subject: st: Matrix command - vecdiag?

Dear Statalisters,

I have the following do file (and a lot of .dta files):


clear
set obs 100
tempname M
forvalues i = 1/100 {
forvalues u = 1(0.1)1.6  {
	use "C:\TEST\RR=`u'_replication_number_`i'.dta"
	set more off
	quietly summarize A
	matrix `M' = nullmat(`M') \ ( r(mean),  r(N))
        clear
}
}
svmat double `M' , name(results)


-svmat- saves results as:

results1 results2
1.2 56
1.3 85


Nonetheless, I would like to add to the matrix a third collumm, which will
have the name of the .dta file. For example,

results1 results2 results3
1.2 56 RR=1.2_replication_number_1.dta
1.3 85 RR=1.2_replication_number_2.dta
.
.
.

Is this difficult to do without changing much my simple do file? I have
tried the vecdiag option, unsuccessfully, however.

I will be very grateful for any help again.

Best,

Tiago




*
*   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/

*
*   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