Statalist The Stata Listserver


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

st: RE: absolute values from a matrix


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   st: RE: absolute values from a matrix
Date   Thu, 9 Nov 2006 16:02:12 +0100

mata
: w = (1 , -1 \ 2,-2)
: 
: w
        1    2
    +-----------+
  1 |   1   -1  |
  2 |   2   -2  |
    +-----------+

: abs(w)
       1   2
    +---------+
  1 |  1   1  |
  2 |  2   2  |
    +---------+

: w2 = abs(w)

: w2
       1   2
    +---------+
  1 |  1   1  |
  2 |  2   2  |
    +---------+

HTH,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434 

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Tom Boonen
Sent: donderdag 9 november 2006 15:59
To: [email protected]
Subject: st: absolute values from a matrix

Hi,

is there an elegant way to create a matrix that contains the absolute
values of the entries of another matrix?

Something like:

matrix w = (1 , -1 \ 2, -2)
matrix list w

*w[2,2]
*c1  c2
*r1   1  -1
*r2   2  -2

* But then:

. matrix w = abs(w)
type mismatch
r(109);

Any ideas? Thank you very much!

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