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" <>
To   <>
Subject   st: access subsets of a matrix
Date   Wed, 27 Apr 2005 17:08:28 -0400


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


*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index