[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"

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):

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))
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.



*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index