You are on page 1of 10

Extra Notes on Hypothesis Testing

Hypothesis Testing for a Population Mean


To test hypotheses regarding the population mean, we use the following steps, provided that
The sample is obtained using simple random sampling or from a randomized experiment.
The sample has no outliers, and the population from which the sample is drawn is normally
distributed or the sample size, n, is large ( n 30 ).
Step 1: Determine the null and alternative hypotheses. The hypotheses can be structured in
one of three ways:

Step 2: Select a level of significance, , depending on the seriousness of making a Type I


error. We generally use = .05.
Step 3: Perform the Hypothesis test using either the Test Statistic (Classical) method or the
P-value method.

Clasical Approach for Testing a Population Mean


Compute the test statistic

t=

x 0
s/ n

which follows a N(0,1)


Determine the critical value, usually 1.96 for a two sided test, and 1.64 or -1.64 for a one sided test.
These values can be found using Stata; display invnorm(0.95) or display invnorm(.975) for example
Graph the rejection and non-rejection regions

H o : = 0

H o : = 0

H o : = 0

H a : 0

H a : > 0

H a : < 0

Reject if

Reject if

Reject if

| t |> z /2

t > z

t < z

Check to see if the value of the test statistic falls in the rejection region. If it does, then reject Ho
(and conclude Ha). If it does not fall in the rejection region, do not reject Ho.
State the conclusion in words.

P-Value Approach for Testing a Population Mean


Compute the test statistic

t=

x 0
s/ n

which follows a N(0,1)


The p-value is computed as the probability of a result as extreme and more extreme as the observed
tests statistics in the direction of the alternative hypothesis:.
Compute the P-Value

H o : = 0

H o : = 0

H o : = 0

H a : 0

H a : > 0

H a : < 0

x 0

p value = P Z >

s/ n

display

x 0

p value = P Z <

s/ n

display

x 0
p value = 2* P Z >

s/ n

display

x 0
1

normprob

x 0
s/ n
1 normprob abs

s / n

How to use the P-Value: For the preset value:


If the p-value
If p-value >

, reject Ho.
, cannot reject Ho.

State the conclusion in words.

x 0
normprob

s/ n

Finding P-Values graphically

STATA COMMAND
Testing the mean in Stata is easily done using the sample statistics and the ttesti command

Example for Testing a Population Mean


Problem: Test the claim that the mean amount spent by a customer at the Science Center Coffee Bar is
less than $5 at the 0.05 level of significance. A random sample of 34 customers had spent a mean of $4.43
and a standard deviation of $3.23.
Solution:
We want to test H o : = 5

Ha : < 5

Classical Approach
The test statistic is

t=

P-Value Approach
The test statistic is

x 0
4.43 5
=
= 1.03
s / n 3.23 / 34

t=

x 0
4.43 5
=
= 1.03
s / n 3.23 / 34

Because this is a left-tailed test, we compare the Because this is a left-tailed test, the P-Value is
test statistic value to -1.645.
found by calculating
Since -1.03 is NOT less than -1.645, we fail to
reject the null hypothesis.

p value = P ( Z < 1.03)

This can be found with a Normal table or using


Our conclusion-at the 5% level of confidence Stata:
. display normprob(-1.03)
there is insufficient evidence to conldue that tha
.151505
average bill at the Greenhouse Coffee Bar is less
than $5.
Since the p-value is greater than 0.05 we fail to
reject the null hypothesis.
Our conclusion-at the 5% level of confidence
there is insufficient evidence to conldue that tha
average bill at the Greenhouse Coffee Bar is less
than $5.

Note: This can all be easily done in Stata as follows


. ttesti 34 4.43 3.23 5
One-sample t test
-----------------------------------------------------------------------------|
Obs
Mean
Std. Err.
Std. Dev.
[95% Conf. Interval]
---------+-------------------------------------------------------------------x |
34
4.43
.5539404
3.23
3.303
5.557
-----------------------------------------------------------------------------mean = mean(x)
t = -1.0290
Ho: mean = 5
degrees of freedom =
33
Ha: mean < 5
Pr(T < t) = 0.1555

Ha: mean != 5
Pr(|T| > |t|) = 0.3110

Ha: mean > 5


Pr(T > t) = 0.8445

Note-Stata always uses the t distribution so their p-value will differ slightly from ours.

Hypothesis Testing for a Population Proportion


To test hypotheses regarding the population proportion, we use the following steps, provided that
The sample is obtained using simple random sampling or from a randomized experiment.

np0 (1 p0 ) 10
Step 1: Determine the null and alternative hypotheses. The hypotheses can be structured in
one of three ways:

Step 2: Select a level of significance, , depending on the seriousness of making a Type I


error. We generally use = .05.
Step 3: Perform the Hypothesis test using either the Test Statistic (Classical) method or the
P-value method.

Clasical Approach for Testing a Population Proportion


Compute the test statistic

t=

p p0
p0 (1 p0 )
n

which follows a N(0,1)


Determine the critical value, usually 1.96 for a two sided test, and 1.64 or -1.64 for a one sided test.
These values can be found using Stata; display invnorm(0.95) or display invnorm(.975) for example
Graph the rejection and non-rejection regions

H o : p = p0

H o : p = p0

H o : p = p0

H a : p p0

H a : p > p0

H a : p < p0

Reject if

Reject if

Reject if

| t |> z / 2

t > z

t < z

Check to see if the value of the test statistic falls in the rejection region. If it does, then reject Ho
(and conclude Ha). If it does not fall in the rejection region, do not reject Ho.
State the conclusion in words.

P-Value Approach for Testing a Population Proportion


Compute the test statistic

t=

p p0
p0 (1 p0 )
n

which follows a N(0,1)


The p-value is computed as the probability of a result as extreme and more extreme as the observed
tests statistics in the direction of the alternative hypothesis:.
Compute the P-Value

H o : p = p0

H o : p = p0

H o : p = p0

H a : p p0

H a : p > p0

H a : p < p0

p value =

2* P Z >

display

p p0

p0 (1 p0 )

1 normprob abs

p value =

p value =

PZ >

display

PZ <

display

p p0
1 normprob

p0 (1 p0 )

How to use the P-Value: For the preset


If the p-value
If p-value >

p p0

p0 (1 p0 )

, reject Ho.
, cannot reject Ho.

State the conclusion in words.

value:

p p0

p0 (1 p0 )

p p0
1 normprob

p0 (1 p0 )

p p0

p0 (1 p0 )

Finding P-Values graphically

STATA COMMAND
Testing the mean in Stata is easily done using the sample statistics and the ttesti command

Example for Testing a Population Proportion


Problem: Test the claim that more than 60% of all college statistics students are female at the 0.05 level
of significance. A random sample of 114 college statistics students revealed that 81 of them were female.
Solution:
We want to test H o : p = 060

H a : p > 0.60

Classical Approach
The test statistic is

t=

p p0
p0 (1 p0 )
n

P-Value Approach
The test statistic is

81
0.6
114
= 2.41 =
0.6(0.4)
114

t=

p p0
p0 (1 p0 )
n

81
0.6
114
= 2.41
0.6(0.4)
114

Because this is a right-tailed test, we compare Because this is a right-tailed test, the P-Value is
the test statistic value to 1.645.
found by calculating
Since 2.41 is LARGER than 1.645, we reject the
null hypothesis.

p value = P ( Z > 2.41)

This can be found with a Normal table or using


Our conclusion-at the 5% level of confidence Stata:
. display 1-normprob(2.41)
there is there is sufficient sample evidence to
.00797626
support the claim that more than 60% of all
college statistics students are female.
Since the p-value is less than 0.05 we reject the
null hypothesis.
Our conclusion-at the 5% level of confidence
there is there is sufficient sample evidence to
support the claim that more than 60% of all
college statistics students are female.

Note: This can all be easily done in Stata as follows


. prtesti 114 81 0.6,count
One-sample test of proportion
x: Number of obs =
114
-----------------------------------------------------------------------------Variable |
Mean
Std. Err.
[95% Conf. Interval]
-------------+---------------------------------------------------------------x |
.7105263
.0424759
.6272752
.7937775
-----------------------------------------------------------------------------p = proportion(x)
z =
2.4089
Ho: p = 0.6
Ha: p < 0.6
Pr(Z < z) = 0.9920

Ha: p != 0.6
Pr(|Z| > |z|) = 0.0160

Ha: p > 0.6


Pr(Z > z) = 0.0080

You might also like