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

RE: st: p>t value extraction


From   "Maarten Buis" <M.Buis@fsw.vu.nl>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: p>t value extraction
Date   Wed, 16 Feb 2005 16:49:14 +0100

Oeps. my code contained an error, use: -gen p = 2*ttail(63,abs(t))- instead of -ttail(63,t)-

May: Why are you using e(N) (number of observations) as the degrees the degrees of freedom instead of number of observations - number of explanatory variables minus one?

-------begin correct code ---
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 = 2*ttail(63,abs(t))
--------- end correct code-----

Or use May's code

 clear
 sysuse auto
 regress mpg len turn head gear
 qui{
 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
 }
 list

*
*   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