Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: Extracting specific elements from a matrix


From   Dani Tilley <[email protected]>
To   [email protected]
Subject   st: Re: Extracting specific elements from a matrix
Date   Mon, 5 Jul 2010 14:10:15 -0700 (PDT)

Much appreciated Martin. Incidentally, how do you go about creating an empty vector in Stata? I noticed that -generate- creates a new variable of length N,but what if I want a variable of length 10? I tried macro and local but they appear to hold strings rather than floats. 



----- Original Message ----

<>

Either talk to the coeff as "_b" (-help _variables-) or define a 
-matrix-
and extract from it:

***********
sysuse auto, clear
reg price weight length rep78

di _b[weight]

mat A=e(b)
di A[1,1]
***********


HTH
Martin
From: Dani Tilley <[email protected]>
To: [email protected]
Sent: Mon, July 5, 2010 4:36:25 PM
Subject: Extracting specific elements from a matrix

Hi,

I need to extract the first element of a matrix of coefficients and store it on a variable, and repeat the process i times. I can set up the for loop and do the storing, but I don't know how to access element [i,j] of a matrix A.

In particular, my matrix is e(b), the vector of coefficients from a regression with k explanatory variables. I tried -e(b)[1,1]- but that didn't take me far.

Any help is appreciated.

Thanks,
DF Tilley


      
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index