OGC
OGC

Reputation: 274

How do I calculate the p-value of a one-tailed test in Stata?

I have the following model: ln(MPG_{i}) = \beta _{0} + \beta {1}WEIGHT{i} + \beta {1}FOREIGN{i} + \beta {3}FOREIGN{i} * WEIGHT_{i} + \varepsilon_{i,j}

I want to use the test command to test whether the coefficient on $\beta_{3} >0.5$ in STATA.

I have used the following code and obtain this result:

test 1.foreign#c.weight = 0.5001

( 1) 1.foreign#c.weight = .5001

   F(  1,    70) = 4.9e+07
        Prob > F =    0.0000

So we reject our null, since the p-value is very small.

But the problem is that this for a two-tailed test.

My goal is to get the t-test value for this left-tailed test and then to store it. And then use the t-test to compute its p-value.

After computing the p-value, I decide whether or not to reject the null. I am certain that I would reject the null and the p-value would be quite small. Just need some help in figuring out how to code it the right way.

EDIT: I have tried using these commands:

lincom _b[forweight] - 0.5
display invttail(71, 0.5)

The last command spits out a value of 0. Now is this the p-value of the left-sided t-test?

Upvotes: 2

Views: 6287

Answers (1)

dimitriy
dimitriy

Reputation: 9470

This is covered in this FAQ.

Here's the relevant code for testing that a coefficient is 0.5:

sysuse auto, clear
gen ln_mpg = ln(mpg)
regress ln_mpg i.foreign##c.weight
test _b[1.foreign#c.weight]=.5 
local sign_wgt = sign(1.foreign#c.weight)
display "Ho: coef <= 0.5  p-value = " ttail(r(df_r),`sign_wgt'*sqrt(r(F)))
display "Ho: coef >= 0.5  p-value = " 1-ttail(r(df_r),`sign_wgt'*sqrt(r(F)))

Upvotes: 5

Related Questions