Hi Alexis,
The ' after a matrix is the transpose, so it flips the matrix around.
For instance, by default Stata saves the parameter estimates in e(b)
as a row vector as you can see below:
. matrix list e(b)
e(b)[1,3]
mpg foreign _cons
y1 -294.19553 1767.2922 11905.415
I added the ' when making the matrix b to turn it into a column
vector:
. matrix b = e(b)'
. matrix list b
b[3,1]
y1
mpg -294.19553
foreign 1767.2922
_cons 11905.415
I did this because I wanted to create a new variable in the dataset
with the parameter estimates in it (to create the t-values). If I
hadn't transposed the vector I would have gotten three variables
b1 b2 b3 with one valid observation each. Now I get one variable
b1 with three valid observations.
Hope this helps,
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: Alexis Furuichi [mailto:furuichi@Princeton.EDU]
Sent: vrijdag 16 maart 2007 16:51
To: Maarten Buis
Subject: RE: st: saving values not returned by ereturn
Hi Mr. Buis,
Thank you very much for your response, it is very helpful! One question I
have is, what does ' do? Some of the matrix commands seem to have it at the
end. Thank you so much for your help!
Alexis
-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Maarten buis
Sent: Thursday, March 15, 2007 6:24 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: saving values not returned by ereturn
--- Satomi Furuichi <furuichi@Princeton.EDU> wrote:
> Does anyone know how to save p-values from a regression?
-regress- will store the parameter estimates, the variance covariance
matrix and the degrees of freedom, and these are all the incredients
you need to compute the p-values: The diagonal elements are the
variances of the sampling distribution of the paramter estimates, take
the square root and you have the standard errors. Divide the parameter
estimates by the standard error and you get the t-value. Look the
t-value up in the t-table with the appropriate number of degrees of
freedom and you have the p-value. The example below shows how can use
this to make in Stata two more matrices, one for the t-values and one
for the p-values.
*----------- begin example ---------------------
sysuse auto, clear
reg price mpg foreign
matrix V = e(V)
matrix b = e(b)'
/* just a fancy way of taking the square roots */
/* of the variances */
matrix se = vecdiag(cholesky(diag(vecdiag(V))))'
svmat b
svmat se
gen t = b1/se1
gen p = 2*ttail(e(df_r),abs(t))
/* Get the column names (variable names) from */
/* the original parameter matrix so I can stick */
/* it on the other matrices */
local col: colnames e(b)
mkmat p in 1/3, matrix(p)
matrix p = p'
matrix colnames p = `col'
matrix list p
mkmat t in 1/3, matrix(t)
matrix t = t'
matrix colnames t = `col'
matrix list t
*-------------- end example -------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
Hope this helps,
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/
-----------------------------------------
___________________________________________________________
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more
at the Yahoo! Mail Championships. Plus: play games and win prizes.
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
*
* 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/