Statalist The Stata Listserver


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

st: define a matrix using its names of columns and rows


From   Val�rie Orozco <[email protected]>
To   [email protected]
Subject   st: define a matrix using its names of columns and rows
Date   Wed, 02 Aug 2006 13:48:27 +0200

I have a matrix toto like

toto[3,2]
b1 b2
a1 0 0
a2 0 0
a3 0 0

Does anyone know how I can use the names of columns and rows of the matrix to replace some elements.
Instead of doing mat toto[2,1] = -1, I would to write "mat toto["a2", "b1"] = -1" (but this last one is wrong since I have the error "type mismatch") ???

What's surprising is that creating a matrix from another works : for example
. mat titi = J(5,4 , 1)
. mat list titi
titi[5,4]
c1 c2 c3 c4
r1 1 1 1 1
r2 1 1 1 1
r3 1 1 1 1
r4 1 1 1 1
r5 1 1 1 1

. mat titi[2,1] = toto["a2","b2"]
. mat list titi
titi[5,4]
c1 c2 c3 c4
r1 1 1 1 1
r2 0 1 1 1
r3 1 1 1 1
r4 1 1 1 1
r5 1 1 1 1

Than k you.

val�rie

--

***********************
Val�rie Orozco
INRA ESR Toulouse - FRANCE
ESR INRA - BP52627 - 31326 Castanet Tolosan Cedex [email protected]
05-61-28-50-97
***********************




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