Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: saving values not returned by ereturn


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: saving values not returned by ereturn
Date   Thu, 15 Mar 2007 22:24:17 +0000 (GMT)

--- Satomi Furuichi <[email protected]> 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/



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