Chapter 5: UE Chapter 5
Now that you can run regressions in Stata, we turn to thinking about hypothesis
testing and confidence intervals. In particular, this chapter covers Stata commands
for:
1) t-tests and p-values
2) Confidence Intervals
3) F-Tests and p-values
5.1 t-Tests and p-values
A hypothesis test gives us insight into what we know from an estimation of an
unknown parameter. With that in mind, it is not surprising that Stata automatically
provides the calculated t-values for each coefficient estimated in a regression. Let’s
see an example.
Recall the Woody’s restaurant example where the following model was proposed:
Y i=β 0 + β N N i+ β P P i+ β I I i +ε i
where:
Y = Sales: gross sales (in dollars) of the ith Woody’s location
N = Competition: the number of direct market competitors within a two-
mile radius of the ith Woody’s location
P = Population: the number of people living in a three-mile radius of the
ith Woody’s location
I = Income: the average household income of the population
measure in variable P
(the data set [Link] is available at
[Link]
The command in Stata to run the regression is:
regress Y N P I
The regression results are shown in Figure 5.1.
Using Stata 5-1
FIGURE 5.1
These match the results from Table 3.2, page 77, in Using Econometrics.
As I have said from the start, there are quite a few numbers presented in the
standard Stata output. The good news is they are all starting to make sense. At the
moment, we are interested in the column labeled “t” and indicated by the blue
arrow.
The t column provides the calculated t-value for each coefficient for a test against 0.
To illustrate, let’s perform the following 2-sided hypothesis test.
H o : β N =0
H a : βN ≠ 0
We are testing whether or not β N is statistically different than 0. To calculate the t-
statistic by hand, we use the estimated coefficient and the estimated standard error
with Equation 5.2 in the text:
^β − β
N H −9074.674−0
tN= o
= =−4.42
^
SE( β ) 2052.674
N
Our “by hand” approach gives us a calculated t-value of -4.42. That is exactly what
Stata provides in the output. Very convenient!
Two things to keep in mind: first, Stata provides the calculated t-value for every
estimated coefficient assuming the null hypothesis is testing against 0. Second, the t-
Using Stata 5-2
statistic for a one-sided test is the same as a two-sided test—the difference is how
you use it.
As noted in Using Econometrics (page 127) you can also perform hypothesis testing
using p-values. Recall the rule states that if the p-value is less than the significance
level selected (and standard significance levels are 1%, 5%, and 10%), you reject the
null hypothesis. If not, then you cannot reject the null. But there is the question of
calculating p-values.
Using Econometrics rightly indicates that nearly every software package
automatically reports p-values as a part of the standard regression output. That
includes Stata.
Looking back at Figure 5.1, the column next to the column labeled “t” is labeled “P>|
t|”. That column reports p-values.
For example, the p-value listed for I’s estimated coefficient is 0.025. But, as
cautioned in Using Econometrics, this p-value is for a two-sided hypothesis test. To
be precise, this reported p-value is associated with the following hypothesis:
H o : β I =0
H a : βI ≠ 0
Using a significance level of 5%, a p-value of 0.025 would lead us to reject the null
hypothesis. Thus, we conclude that there is evidence to suggest the impact of
average household income (I) on gross sales is not 0.
If instead you wanted to test a one-sided hypothesis such as:
H o : βI ≤ 0
H a : β I >0
Then you would have to divide the 0.025 by two to get the correct p-value of 0.0125.
5.2 Confidence Intervals
Just a hop, skip, and a jump from hypothesis testing is calculating a confidence
interval. As with t-tests and p-values, Stata automatically does much of the heavy
lifting.
Looking back to the Woody’s restaurant estimation reported in Figure 5.1, moving
right from the p-value column you find confidence intervals reported. The far right
two columns are named “[95% Conf. Interval]”. The lower and upper bounds of the
Using Stata 5-3
confidence interval are reported. Let’s calculate the confidence interval for the
coefficient on P as an example.
To calculate a 95% confidence interval, use Equation 5.9 in the text:
C . I .= ^β P ±t c∗SE ( β^ P )=0.3546684 ± 2.045∗0.0726806=(0.20604 , 0.50330)
Note that the value used for tc is 2.045. Why? A 95% confidence interval uses a 5%
two-sided t-critical value. Since this regression has 33 observations, the degrees of
freedom would be 29 (or 33-3-1). The t-critical value (see Appendix B, Table B-1 in
Using Econometrics), is 2.045.
Looking to the results we see that the confidence interval calculated by hand
matches (nearly) what Stata produced. At the fifth decimal place there is a bit of
discrepancy. This, at first glance, might trouble you. It shouldn’t. Stata has an
advantage over us mere mortals. It can be much more precise in its calculations. It
does not have to round coefficient estimates nor is it limited by a physical table for
t-statistics. For example, while we used 2.045 for the 95% two-sided critical value
with 29 degrees of freedom, if we had used a table that rounded to the fourth
decimal place, we would have used 2.0452.
Stata’s ability to be “more precise” will lead hand-calculated confidence intervals to
sometimes be different than Stata-generated values. Normally, the differences
should be small but it can cause confusion if you don’t expect it.
It is great that Stata automatically produces 95% confidence intervals as a part of
the regression output. But what if you were interested in a 90% confidence interval
or a 99% confidence interval? Nicely, Stata can help us out. The 95% confidence
interval is the default in Stata but we can ask for a different one.
To do so, we add a short command after the regression command: “level(##)”. Using
the Woody’s restaurant model, to ask for a 90% confidence interval, the command
would be:
regress Y N P I , level(90)
The result of this estimation is shown in Figure 5.2.
Using Stata 5-4
FIGURE 5.2
Much of the output is identical: the estimated betas, the standard errors, the R2, etc.
The only difference is the reported confidence interval. This time, as we asked, we
got a 90% confidence interval.
If we wanted to be crazy, we could ask for 93% confidence interval. To do so, what
should we type? How about:
regress Y N P I , level(93)
The result can be seen in Figure 5.3. You can ask for any confidence interval you
please and Stata will happily oblige without question.
Using Stata 5-5
FIGURE 5.3
5.3 F-Tests and p-values
The t-test is great for testing a single coefficient against a single hypothesized value.
But when you want to test multiple coefficients at the same time, that is, when you
want to test a joint hypothesis, you have to appeal to an F-test. Stata makes this a
snap. Let’s start with the “easy” way of doing F-tests in Stata.
Consider the F-test of overall significance. Continuing with the Woody’s restaurant
example, our null and alternative hypotheses would be:
H o : β N =β P =β I =0
H a : H o is not true
The F-statistic is 15.65, calculated using the ESS and RSS from the Stata regression
output and Equation 5.11 on page 144 of Using Econometrics. However, if you look
back to Figure 5.3 (or Figure 5.2 or Figure 5.1) you will see that Stata automatically
provides the F-statistic and its p-value. In the top right corner, right below “Number
of obs” you’ll see “F(3, 29) = 15.65”.
What are the 3 and 29 in the parentheses? Those are the degrees of freedom for the
F-statistic: 3 is the number of independent variables (K using the notation of Using
Econometrics) and 29 is the number of observations minus the number of
independent variables minus one (or N-K-1).
Using Stata 5-6
Right below where the overall F-statistic is reported, you see “Prob > F”. This is none
other than the p-value associated with the overall F-Test. As can be seen in Figure
5.3, the p-value is 0.0000. You use this p-value as you would for a t-test: if the p-
value is less than or equal to the significance level, you reject the null hypothesis. We
reject the null in this case and conclude that there is evidence that at least one slope
coefficient is not 0.
The F-test is quite flexible and can be used for more than the overall significance
test. In fact, any joint hypothesis test that involves two or more estimated
coefficients is fair game. Using Econometrics gives an example of testing seasonal
dummies (page 146).
Let’s see a couple examples of F-tests using the Woody’s example. First, let’s test the
following hypotheses:
H o : β P =β I =0
H a : H o is not true
This test is similar to the overall significance test but does not include the coefficient
on competition (N). The alternative hypothesis is that at least one of the coefficients
is not 0.
Stata does not automatically report this test. We have to ask for it. The good news is
that is pretty easy.
First, you need to run the estimation. This puts the regression results in Stata’s
memory. So, give the command:
regress Y N P I
With the estimation performed, you will then use the “test” command in Stata.
Specifically, give the command:
test P = I = 0
Figure 5.4 shows what you should see in Stata, starting with the regression results
followed by the test:
Using Stata 5-7
FIGURE 5.4
The regression results show what we have seen before. What we are most
interested in at the moment is the test statement at the bottom. The important items
to pick out are the F-statistic (22.68) and the p-value (0.0000). Since the p-value is
less than all conventional significance levels (like 1%, 5%, and 10%), we reject the
null hypothesis. This shocks just about no one.
Let’s consider another, perhaps more interesting, joint hypothesis test. Consider the
question of whether a one-unit change in P has the same impact on Y as does a one-
unit change in I. That might seem like a silly question but comparing the effect of
different variables on the dependent variable is pretty common in applied work (as
an example, think about a company wondering what form of advertising spending is
most effective on a product’s sales).
In this case, does such a test even make sense, though? You can look at the estimated
coefficients and quickly say that 0.3546684 is certainly not the same as 1.287923.
But let’s test whether we can formally, statistically say that they are in fact different.
Using Stata 5-8
To do so, let’s perform the following hypothesis test:
H o : β P =β I
H a : H o is not true
Stata makes this test pretty simple. After estimating the model, you would type the
following command:
test P = I
The result of this test is shown in Figure 5.5.
FIGURE 5.5
What does the test mean? If we use a 5% significance level, since the p-value
(0.1157) is greater than the significance level (0.05) then we cannot reject the null
hypothesis. That implies there is no evidence to suggest that the effect of P and I on
Y are statistically different.
This is one of those moments that drives home an important point: coefficient
estimates are simply point estimates. While 1.287923 looks very, very precise it is
not precise in a statistical sense. Though it might not be obvious at this point, this
issue dovetails with the concept of confidence intervals. In fact, if you look at the
95% confidence intervals for the two coefficients (Figure 5.1) you see that they
overlap. Well, they more than overlap. The confidence interval for β P is entirely
contained within the confidence interval of β I ! This gives some insight into why we
couldn’t reject the null hypothesis that the coefficients are the same.
Using Stata 5-9
Using Stata 5-10