-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_pval.ado
More file actions
25 lines (21 loc) · 764 Bytes
/
get_pval.ado
File metadata and controls
25 lines (21 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
version 13 /* That's right... I'm still on Stata 13... */
/* This program is a custom postestimation command that takes a coeffient value (coef),
its corresponding standard errors (se), the regression degree of freedom remaining (df_r),
and then computes the corressponding p-value. Rounding parameter is round (e.g. .001 rounds
to 3 decimal places).
e.g. To get pval of x rounded off to three decimal places,
reg y x
get_pval _b[x] _se[x] e(df_r) 0.001
local pval `r(pval)'
dis "`pval'"
*/
capture program drop get_pval
program define get_pval, rclass
args coef se df_r round
tempvar tstat
qui gen `tstat' = `coef'/`se'
local pval = 2*ttail(`df_r', abs(`tstat') )
local pval = round(`pval', `round')
*di `pval'
return local pval `pval'
end