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

st: access subsets of a matrix


From   "Jens Hainmueller" <[email protected]>
To   <[email protected]>
Subject   st: access subsets of a matrix
Date   Wed, 27 Apr 2005 17:08:28 -0400

Hi,

I am new to Stata programming so I have a problem to translate the following
line of mathlab code into Stata code.

lambda(z==0) = - normpdf(X(z==0,:)*gamma)

Here lambda is an (nx1) matrix, X is (nxk), gamma is (kx1), z is (nx1), and
for example X(z==0) denotes subset of the matrix X for which (z==1), i.e.
the condition in parenthesis holds true.

In Stata, how can I access this subset of my X matrix? It should be
something like:

matrix lambda = -normde(X[if z==1]*gamma)

but I can't Stata to access the matrix subsets as I need it. Thanks for your
help.

Best,
Jens


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