Hypothesis test for the response variable in a least squares regression model I have an equation where time it takes to get to work is based on time it takes to depart, number of red lights hit, and number of trains you encounter. The model is shown below:
time=$\beta_1$+$\beta_2$depart+$\beta_3$reds+$\beta_4$trains+e
I want to do a hypothesis test on time being less than or equal to 20.
$H_0$: time<=20, $H_A$: time>20
I was wondering how you could do a question like this in Stata. I can post the data set if needed but I'd rather get an explanation on how to do it and try it out myself. 
 A: Using standard datasets is good practice when you can.
Here's an example where I will test the hypothesis that the average predicted price of cars--given mileage, weight, and length--is less or equal to \$5,500 (or $H_0: \mathbb E[Y \vert X] \le 5,500$): 
sysuse auto, clear
reg price mpg weight length 
margins, post
test _cons==5500
display "Ho: E[Y|X] <= 5500  p-value ="ttail(r(df_r),sign(_b[_cons]-5500)*sqrt(r(F)))

Here's is the intuition. First, run the regression and calculate the average expected price with margins. Do the the corresponding two-sided Wald test and use the results to calculate the test statistic and p-value for the one-sided test.
Here's the nitty gritty. The Wald test is an F test with 1 numerator degree of freedom and 70 denominator degrees of freedom (since we have 74 observations and 4 coefficients). The Student’s t distribution with d degrees of freedom squared is equivalent to the F distribution with 1 numerator degree of freedom and d denominator degrees of freedom. Since the original F test has 1 numerator degree of freedom, the square root of the F statistic is the absolute value of the t statistic for the one-sided test. We just need to determine whether this t statistic is positive or negative, which you can do with the sign() function applied to the differences. Then, using the ttail() function on the F statistic from the test command, you can calculate the p-value for the one-sided test.
For completeness, if you want to test $H_0: \mathbb E[Y \vert X] \ge 5,500$, you can use
display "Ho: E[Y|X] >= 5500  p-value ="1-ttail(r(df_r),sign(_b[_cons]-5500)*sqrt(r(F)))

