OJ

Hypothesis Testing Vocabulary

Hypothesis Testing

  • Inference includes estimation of confidence intervals and hypothesis testing.

Big Picture of Hypothesis Testing

  • Population: A statement is made about a population (e.g., average age is 50).
  • Sample: A random sample is selected from the population.
  • Sample Mean: The sample mean is calculated (e.g., 25).
  • Comparison: Compare the sample statistic to the statement about the population.
    • If the sample statistic is close to the statement, the hypothesis is likely true.
    • If the sample statistic is far from the statement, the hypothesis is rejected.

Null and Alternative Hypotheses

  • All hypothesis tests start with the null (H0) and alternative hypotheses.
  • Statistical packages like Stata require the user to specify these hypotheses correctly.
  • Null Hypothesis (H0): A status quo hypothesis; something that exists unless evidence suggests otherwise.
  • Alternative Hypothesis: Everything that is not the null hypothesis.

Procedure to Identify Hypotheses

  1. State the Question: E.g., The average age of the population (\mu) is equal to 50. \mu = 50
  2. State the Opposite: The opposite of \mu = 50 is \mu \neq 50.
  3. Identify the Alternative: The alternative hypothesis cannot have an equal sign.
    • Alternative can have only strictly greater ($>$), strictly less ($<$), or not equal (\neq) signs.
  4. State the Null (H0): The remaining statement becomes the null hypothesis.

Types of Tests

  • Two-Sided Test (Two-Tailed Test): Alternative hypothesis is "not equal to".
    • Null hypothesis: \mu = \mu_0
  • One-Sided Test: Alternative hypothesis has a direction (strictly greater or strictly less).
    • Left-Sided Test: Null hypothesis could be \mu \le \mu0, and the alternative is \mu > \mu0.
    • Right-Sided Test: Null hypothesis could be \mu \ge \mu0, and the alternative is \mu < \mu0.
  • Null and alternative hypotheses should be mutually exclusive and exhaustive.

Importance of the Alternative Hypothesis

  • The alternative hypothesis is crucial and influences many parts of the test.

Example Question 1

  • The mean score is greater than or equal to 80.
    1. \mu \ge 80
    2. Opposite: \mu < 80
    3. Alternative: \mu < 80
    4. Null: \mu \ge 80

Example Question 2

  • The mean score is less than 80.
    1. \mu < 80
    2. Opposite: \mu \ge 80
    3. Alternative: \mu < 80
    4. Null: \mu \ge 80

Determining One-Sided vs. Two-Sided Test

  • Based on the alternative hypothesis.
  • One-sided: Alternative points left ($
  • Two-sided: Alternative states the value could be either too high or too low (\neq).

Example: Average Earnings

  • Test the average earnings of $40,000.
    1. \mu = 40,000
    2. Opposite: \mu \neq 40,000
    3. Alternative: \mu \neq 40,000 (Two-sided)
    4. Null: \mu = 40,000
  • If the question indicates a direction (greater, less, smaller, larger), it is a one-sided test.
  • If the question indicates equal or not equal, it is a two-sided test.

Significance Level

  • Denoted by \alpha
  • Alpha (\alpha) is the probability of a Type I error.
  • Type I error: Rejecting H0 when H0 is actually true.
  • Typical alpha values: 0.05, 0.01, 0.10 (corresponding to 95%, 99%, and 90% confidence intervals).

Type I and Type II Errors

H0 is TrueAlternative is True
Accept H0CorrectType II Error ($\beta$)
Accept AlternativeType I Error ($\alpha$)Correct
  • We choose a small \alpha to minimize the chance of making a Type I error.

Test Statistic

  • A sample statistic that is standardized to determine how far away it is from the null hypothesis.
  • If the test statistic is far from the null, we reject the null.
  • Denoted as T.
  • T distribution gets very close to Z distribution when the sample size is large.

Calculating the T Statistic

  • Standardize the sample mean: T = \frac{\bar{X} - \mu_0}{SE(\bar{X})}
    • \bar{X} = sample mean
    • \mu_0 = value under the null hypothesis
    • SE(\bar{X}) = standard error of the sample mean
  • This test statistic has a T distribution with n-1 degrees of freedom.

Example Calculation

  • Sample size (n) = 171
  • Sample mean = 41413
  • Standard error of the mean = 1952
  • Test hypothesis: Average earnings are 40,000.

T = \frac{41413 - 40000}{1952} = 0.724

  • T distribution with 170 degrees of freedom.

Approaches to State the Test Decision

  1. P-value approach
  2. Rejection-regions (critical-regions) approach

P-Value Approach

  • How likely is it to obtain a test statistic of 0.724 or greater from the T distribution?
  • P-value: The probability of obtaining a test statistic at least as large in absolute value as the one observed.
  • Formula: P-value = P(|T_{n-1}| > t)
Calculating P-Value for Two-Sided Tests
  1. Sketch the T distribution.
  2. Place the value of the test statistic on the graph.
  3. Shade the area in the tails greater than the absolute value of the test statistic.
  • Alternative approach: P-value is twice the area of the tail in the direction of the sign of T.
Calculating P-Value for One-Tailed Tests
  • Go in the direction of the alternative.
  • If the alternative is \mu > \mu_0, shade the area to the right of the test statistic.
  • If the alternative is \mu < \mu_0, shade the area to the left of the test statistic.
Using the P-Value
  • Compare the P-value to the level of significance \alpha.
  • If P-value < \alpha, reject H0.
  • If P-value > \alpha, fail to reject H0.
Example
  • P-value = 0.47
  • \alpha = 0.05
  • P-value > \alpha, so fail to reject H0.

Critical Regions Approach

  • Compare the test statistic to the critical value.
  • Critical regions: Range of values for the test statistic for which H0 will be rejected.
  • If the test statistic falls in the rejection region, reject H0.
Determining Rejection Region
  • For two-sided tests, split \alpha into two tails (\alpha/2 in each tail).
  • For one-tailed tests, the entire \alpha is in one tail.
Example
  • Two-sided test at \alpha = 0.05: \alpha/2 = 0.025 in each tail.
  • Critical value from t-table: c = 1.974.
Decision Rule
  • If absolute value of test statistic > C, reject H0.
  • If absolute value of test statistic < C, fail to reject H0.
  • In the example, the test statistic was 0.724, which is not in the rejection region, so fail to reject.
    Note: Both approaches (P-value and critical regions) should lead to the same decision.

Hypothesis Testing in Stata

Confidence Interval

  • Command: mean earnings
    • Provides the mean, standard error, and 95% confidence interval.
    • The numbers are also available by using return list
  • To specify a different confidence level, use the level option, e.g., mean earnings, level(99).

Calculating the Test Statistic

  • Use the display command as a calculator.
    • display (41412.69 - 40000) / 1952.103

Calculating the P-Value

  • Use the ttail command to get the probability from the T distribution.
    • help ttail to learn the syntax.
    • display ttail(170, 0.724) * 2 (for a two-tailed test).

T-Test Command in Stata

  • Command: ttest earnings == 40000
    • Specifies the null hypothesis as equality.
    • Stata provides information about the test, including the sample size, mean, standard deviation, standard error, and confidence interval.
    • Stata performs all three tests (left-sided, right-sided, and two-sided) and provides the corresponding p-values.
    • Always look at the output and ensure the test is what you want to use.
    • Verify that Stata has calculated sample size, sample mean, and standard deviation as you expect.
    • If you cannot generate the same numbers it is an indication you need more help before attempting the test.
    • The mean, for two sample tests can be calculated differently, so make sure you know what the mean represents.

Practice Problems

Gas Prices

  • Average price for all California gas stations: 3.81
  • Test that the average price in Yolo County is neither higher nor lower than in California.
  • Question: One-sided or two-sided test?
  • Answer: Two-sided test (because it could be higher or lower, i.e., not equal).

Steps

  1. Question: \mu \neq 3.81
  2. Opposite: \mu = 3.81
  3. Alternative: \mu \neq 3.81
  4. Null: \mu = 3.81

P Value Approach

  • P value is the probability that T is greater than 5.256 times 2
  • So the numbers are close to zero, so you reject H0 at alpha = 0.05
  • Found the evidence that the average gas prices in your account were not $3.81 at that point in time.