-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonesidetest.ado
62 lines (55 loc) · 1.33 KB
/
onesidetest.ado
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
capture program drop onesidetest
program define onesidetest, rclass
args varname side round star
if ("`e(cmd)'"!="regress") & ("`e(cmd)'"!="reghdfe") {
error 301
}
scalar var_coef = _b[`varname']
scalar var_se = _se[`varname']
scalar tstat = var_coef/var_se
if "`side'"=="right" {
scalar pval = ttail(e(df_r), tstat)
}
else if "`side'"=="left" {
scalar pval = 1 - ttail(e(df_r), tstat)
}
else {
dis in red "Choose 'left' or 'right' side."
exit
}
scalar list var_coef var_se tstat pval
if "`star'"=="star" {
if pval < 0.01 { /* sig. at 1 percent */
local StatStars = string(round(pval, `round')) + "\sym{***}"
}
else if 0.01 <= pval < 0.05 { /* sig. at 5 percent */
local StatStars = string(round(pval, `round')) + "\sym{**}"
}
else if 0.05 <= pval < 0.1 { /* sig. at 10 percent */
local StatStars = string(round(pval, `round')) + "\sym{*}"
}
else if 0.1 <= pval {
local StatStars = string(round(pval, `round'))
}
return local pval `StatStars'
}
else { /* just check for rounding, return, and end */
if "`round'"!= "" {
return local pval = round(pval, `round')
}
else {
return local pval = pval
}
}
end
/*
MWE
---
. sysuse auto
. reg price weight length
. onesidetest length right
var_coef = -97.960312
var_se = 39.174598
tstat = -2.500608
pval = .99264594
*/