Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Matrix subscripts using row and column names


From   West Addison <wastata@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Matrix subscripts using row and column names
Date   Wed, 16 Jul 2003 16:52:00 -0700 (PDT)

I am fairly new to Stata, and am having a problem
using row and column name subscripts to refer to a
single element of a matrix.  I must be missing
something fairly obvious, but I can't seem to get it
to work.  At the bottom of page 155 of the Stata 7
User's Guide, the following example is given:

generate sdif = dif / sqrt(V["price","price"])

However, when I try to execute this statement (in
Stata 7), I get the following error message:

matrix operators that return matrices not allowed in
this context
r(509);

Can anyone point out to me what my mistake is?

Here is a copy of my Stata log:


. matrix V = (1,2,3\4,5,6\7,8,9)

. matrix colnames V = junk1 junk2 price

. matrix rownames V = junk1 junk2 price

. matrix list V

V[3,3]
       junk1  junk2  price
junk1      1      2      3
junk2      4      5      6
price      7      8      9

. input dif

           dif
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. end

. list

           dif
  1.         1
  2.         2
  3.         3
  4.         4
  5.         5

. generate sdif = dif / sqrt(V["price","price"])
matrix operators that return matrices not allowed in
this context
r(509);


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index