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

st: Re: p>t value extraction


From   "Maarten Buis" <M.Buis@fsw.vu.nl>
To   "Statalist@Hsphsun2. Harvard. Edu (E-mail)" <statalist@hsphsun2.harvard.edu>
Subject   st: Re: p>t value extraction
Date   Wed, 16 Feb 2005 16:27:56 +0100

Dear Dejan,
> I did regressions over the huge set of data and would like to have betas and reg. coefficients 
> placed in the "data browser" window what I managed to do using eclass command such as 
> ereturn list and save it as matrix, but I have a problem to do the same thing with the p>t values as 
> I cannot extract it from ereturn list.

Stata provides all the information you need to compute the "p-values" yourself. The p-values are the significance levels at which you would reject the null hypothesis (beta=0) from the t-test, which is no more than your parameter divided by the standard error. You have already found the matrix of parameters (e(b)). the variance-covariance matrix is stored in e(V), the diagonal are the variances. These can be extracted using -vecdiag- taking the square root of these will produce the standard errors. All you have to do now is devide the parameters by the standard error and let stata look the p-values up in a t-table (using -ttail(degrees of freedom, t-value)-). The appropriate degrees of freedom are the number of observations minus the number of explanatory variables minus 1. Below is an example using the well known auto dataset. Cut those between begin example and end example and paste them in the do-file editor and run.


----------------begin example----------
sysuse auto, clear
reg price mpg rep78 headroom trunk weight
matrix a = vecdiag(e(V))
matrix b = (e(b)\a)'
svmat b
rename b1 beta
gen se = sqrt(b2)
gen t = beta/se
gen p = ttail(63,t)
--------end example---------


Hope this helps,
Maarten

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index