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

Re: st: p>t value extraction

From   May Boggess <>
Subject   Re: st: p>t value extraction
Date   16 Feb 2005 09:23:48 -0600

On Wedmesday, Dejan wrote:

> 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

The test statistics and p-values are not in the saved results since they
can be calculated from the coefficients and the standard errors. 

Here is an example of how to save the coefficients and standard errors
into a dataset and then calculate test statistics, p-values and
confidence intervals from them:

 sysuse auto
 regress mpg len turn head gear
 drop _all
 mat b=e(b)'
 mat se= vecdiag(cholesky(diag(vecdiag(e(V)))))'
 gen vars=""
 local names: rownames b
 tokenize `names'
 local num : word count `names'
 set obs `num'
 forvalues i=1/`num'{
  replace vars= "``i''" in `i'
 svmat b
 svmat se
 rename b1 coef
 rename se1 se
 gen t=coef/se
 gen pvalue=2*ttail(e(N),abs(t))
 gen lb=coef-invttail(e(N),0.025)*se
 gen ub=coef+invttail(e(N),0.025)*se 


*   For searches and help try:

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