To do one-sided tests on coefficients, you can
- perform the corresponding two-sided test on the coefficients (or sometimes just look at the regression output)
- use the results to get a p-value for the one-sided test. This step can done in two ways, either by using using the reverse cumulative Student's t distribution directly or by doing some arithmetic on the p-value from the two-sided test.
If you are testing differences of coefficients (since a=b is equivalent to a-b=0), the approach is the same as doing single coefficients. You need to do a two-sided test of the difference:
sysuse auto, clear
regress price mpg weight
gen high_mpg = mpg>20
gen high_weight = weight>3000
reg price high_mpg high_weight foreign
/* Test H0: diff = 0 */
test high_weight - foreign = 0
display r(p)
display r(F)
/* The ttail approach works when the actual coefficient difference is positive or negative */
local sign_diff = sign(_b[high_weight] - _b[foreign] - 0)
display "p-value for Ha: diff < 10 = " ttail(r(df_r),`sign_diff'*sqrt(r(F)))
display "p-value for Ha: diff > 10 = " 1-ttail(r(df_r),`sign_diff'*sqrt(r(F)))
/* Can also do it by hand like this if diff is positive (like above) */
display "p-value for Ha: diff < 0 = " r(p)/2
display "p-value for Ha: diff > 0 = " 1-r(p)/2
/* if difference is negative, you can still do it by hand */
/* but need to flip the p-value division rules since we are on the other */
/* side of the distribution */
/* Test H0': diff2 = -400 */
test high_mpg - foreign = -400
local sign_diff2 = sign(_b[high_mpg] - _b[foreign] + 400)
display "p-value for Ha': diff2 < 0 = " ttail(r(df_r),`sign_diff2'*sqrt(r(F)))
display 1-r(p)/2
display "p-value for Ha': diff2 > 0 = " 1-ttail(r(df_r),`sign_diff2'*sqrt(r(F)))
display r(p)/2
If your test returns r(chi2) instead of r(F), you need to swap the ttail part for
normal(`sign_diff'*sqrt(r(chi2)))