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

st: Re: passing matrix to program


From   baum <[email protected]>
To   [email protected]
Subject   st: Re: passing matrix to program
Date   Wed, 18 Sep 2002 08:38:51 -0400

--On Wednesday, September 18, 2002 2:33 -0400 Matt wrote:

Is there a way of passing a  matrix as an argument to a program ? My
first hunch (below) didn't work


program define simulerpox
syntax, duration(int) pattern(matrix)
...
end


Because my matrix really is a vector, I have thought about passing it as
a numlist . However, my understanding is that I cannot easily get access
to the  individual element of the numlist whereas this is possible with
the matrix using the "el" function

matrix input patmat = (0.5 \ 2\ 3)
display el(patmat,1,1)

Any suggestions?

. program define passmat,rclass
 1. di "matrix is named `1'"
 2. mat list `1'
 3. end

.
.
end of do-file

. mat list b

b[1,2]
        bmnew       _cons
y1   .98579374  -.00004187

. passmat b
matrix is named b

b[1,2]
        bmnew       _cons
y1   .98579374  -.00004187



________________________________________________________________________
Christopher F Baum, Boston College Economics, Chestnut Hill MA 02467 USA
[email protected]                       http://fmwww.bc.edu/ec-v/baum.fac.html
*
*   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