Shapiro-Wilk normality test
data: uniform.data
W = 0.93903, p-value = 0.0001683
11 Hypothesis test: Introduction and testing one population parameter
11.1 Definition
A statistical hypothesis is a statement about the parameters of one or more populations.
Example 1: A manufacturer claims that the mean life of a smartphone is more than 1.5 years.
Example 2: A local courier service claims that they deliver a ordered product within 30 minutes on average.
Example 3: A sports drink maker claims that the mean calorie content of its beverages is 72 calories per serving.
11.2 Types of hypothesis
Statistical hypothesis are stated in two forms- (i) Null hypothesis (\(H_0\)) and (ii) Alternative hypothesis (\(H_1\)).
Both null and alternative hypothesis are the written about the parameter of interest based on the claim.
We will always state the null hypothesis as an equality claim.
However, when the alternative hypothesis is stated with the “<” sign, the implicit claim in the null hypothesis can be taken as ” ≥ “ or “=” sign.
When the alternative hypothesis is stated with the “>” sign, the implicit claim in the null hypothesis can be taken as “≤” or “=” sign.
11.3 Developing hypotheses
To develop or state null and alternative hypothesis, at first we have to clearly identify the “claim” about population parameter. Now we will see some examples.
Example 1: A manufacturer claims that the mean life of a smartphone is more than 1.5 years.
Hypothesis:
\(H_0:\mu=1.5\)
\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ H_1: \mu>1.5 \ \ (claim)\)
Example 2: A local courier service claims that they deliver a ordered product within 30 minutes on average.
Hypothesis:
\(H_0: \mu=30\)
\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ H_1: \mu<30 \ \ (claim)\)
Example 3: A sports drink maker claims that the mean calorie content of its beverages is 72 calories per serving.
Hypothesis:
\(\ \ \ \ \ \ \ \ \ \ \ \ \ \ H_0: \mu=72 \ \ (claim)\)
\(H_1: \mu \ne 72\)
11.4 Types of test based on alternative hypothesis \(H_1\)
\(H_1: \mu< \mu_0\) (Lower tailed)
\(H_1: \mu> \mu_0\) (Upper tailed)
\(H_1: \mu \ne \mu_0\) (Two-tailed)
11.5 Types of error in hypothesis test
While testing a statistical hypothesis concerning population parameter we commit two types of errors.
Type I error occurs when we reject a TRUE \(H_0\)
Type II error occurs when we FAIL to reject a FALSE \(H_0\)
The Level of significance is the probability of comiting Type I error. It is denoted by \(\alpha\).
\[ \alpha= P(Type \ \ I \ \ error) \]
- The probability of committing a Type II error, denoted by \(\beta\).
\[ \beta =P(Type \ \ II \ \ error) \]
Type I error is more serious than Type II error. Because rejecting a TRUE statement is more devastating than FAIL to reject a FALSE statement. So, we always try to keep our probability of Type I error as small as possible (1% or at most 5%). For more detail see (Keller 2014).
So, how these hypotheses will be tested?
To test a hypothesis we have to determine
a test-statistic; and
Critical/Rejection region based on the sampling distribution of test-statistic for a given \(\alpha\) ;
If the value of test-statistic falls in Critical/Rejection region, then we reject Null (\(H_0\)) hypothesis; otherwise not.
11.6 Hypothesis testing concerning population mean (\(\mu\))
The following two hypotheses tests are used concerning population mean (\(\mu\)):
1. One sample z-test (with known \(\sigma\))
2. One sample t-test (with unknown \(\sigma\))
11.6.1 One sample z-test
When sampling is from a normally distributed population or sample size is sufficiently large and the population variance is known, the test statistic for testing \(H_0: \mu=\mu_0\) at \(\alpha\) is
\[ z=\frac{\bar x-\mu_0}{\sigma /\sqrt n} \]
Decision (Critical value approach): If calculated \(z\) falls in rejection region (CR) , then reject \(H_0\) . Otherwise, do not reject \(H_0\).
For lower tailed test, reject \(H_0\) if \(z<-z_\alpha\) ;
For upper tailed test, reject \(H_0\) if \(z> z_\alpha\) ;
For two-tailed test, reject \(H_0\) if \(z<-z_{\alpha/2}\) or \(z>z_{\alpha/2}\) .
Problem 10.1 The waiting time for customers at MacBurger Restaurants follows a normal distribution with a mean of 3 minutes and a standard deviation of 1 minute. At the Warren Road MacBurger, the quality-assurance department sampled 50 customers and found that the mean waiting time was 2.75 minutes. At the 0.05 significance level, can we conclude that the mean waiting time is less than 3 minutes?
Problem 10.2 At the time she was hired as a server at the Grumney Family Restaurant, Beth Brigden was told, “You can average $80 a day in tips.” Assume the population of daily tips is normally distributed with a standard deviation of $3.24. Over the first 35 days she was employed at the restaurant, the mean daily amount of her tips was $84.85. At the 0.01 significance level, can Ms. Brigden conclude that her daily tips average more than $80?
Problem 10.3 The manufacturer of the X-15 steel-belted radial truck tire claims that the mean mileage the tire can be driven before the tread wears out is 60,000 miles. Assume the mileage wear follows the normal distribution and the standard deviation of the distribution is 5,000 miles. Crosset Truck Company bought 48 tires and found that the mean mileage for its trucks is 59,500 miles. Is Crosset’s experience different from that claimed by the manufacturer at the 0.05 significance level?
11.6.2 One sample t-test
When sampling is from a normally distributed population or sample size is sufficiently large and the population variance is unknown, the test statistic for testing \(H_0: \mu=\mu_0\) at \(\alpha\) is
\[ t=\frac{\bar x-\mu_0}{s /\sqrt n} \]
Test statistic \(t\) follows a Student’s 𝑡 distribution with \((n - 1)\) degrees of freedom.
Decision (Critical value approach): If calculated \(t\) falls in rejection region (CR) , then reject \(H_0\) . Otherwise, do not reject \(H_0\).
For lower tailed test, reject \(H_0\) if \(t<-t_\alpha\) ;
For upper tailed test, reject \(H_0\) if \(t> t_\alpha\) ;
For two-tailed test, reject \(H_0\) if \(t<-t_{\alpha/2}\) or \(t>t_{\alpha/2}\) .
Problem 10.4 Annual per capita consumption of milk is 21.6 gallons (Statistical Abstract of the United States: 2006). Being from the Midwest, you believe milk consumption is higher there and wish to support your opinion. A sample of 16 individuals from the Midwestern town of Webster City showed a sample mean annual consumption of 24.1 gallons with a standard deviation of \(s=4.8\) .
a) Develop a hypothesis test that can be used to determine whether the mean annual consumption in Webster City is higher than the national mean.
b) Test the hypothesis at \(\alpha=0.05\) .
c) Draw a conclusion.
Problem 10.5 The mean length of a small counterbalance bar is 43 millimeters. The production supervisor is concerned that the adjustments of the machine producing the bars have changed. He asks the Engineering Department to investigate. Engineer selects a random sample of 10 bars and measures each. The results are reported below in millimeters.
42, 39, 42, 45, 43, 40, 39, 41, 40, 42
Is it reasonable to conclude that there has been a change in the mean length of the bars?
11.7 Normality test
In parametric (distribution based ) hypothesis test the checking normality assumption of study variable is a common practice especially when the sample size is small (\(n<30\)). For large samples, the Central Limit Theorem (CLT) often makes this test robust to non-normality.
The normality assumption is checked in two ways:
a) Graphically
b) Numerically using some normality tests
a) Graphical procedure to check normality
We often plot the data (i.e., histogram, density plot, boxplot) to explore so called bell-shaped of the data. But the most popular and effective way to check normality is Q-Q plot (Quantile- Quantile plot).
b) Normality test
A number of normality tests are available; of them a common test is Shapiro-Wilk test of normality suitable for small to medium sample size (3 to 5000) (Shapiro and Wilk 1965; Royston 1982).
Shapiro-Wilk Test Statistic W
\[ W=\frac{(\sum_{i=1}^n a_i x_{(i)})^2}{\sum_{i=1}^n (x_i-\bar x)^2} \]
Where,
\(x_{(i)}\) : the \(i^{th}\) order statistic (i.e., the i-th smallest value in the sample)
\(\bar x\): the sample mean
\(a_i\) : constants calculated based on the expected values and variances of order statistics from a standard normal distribution (Tabulated in Shapiro Wilk Table)
\(n\): sample size
Hypotheses:
Null Hypothesis \(H_0\): The data are normally distributed.
Alternative \(H_1\): The data are not normally distributed.
We reject \(H_0\) if the p-value is less than our significance level (e.g., 0.05).
Almost all statistical software and package routinely provide the Shapiro-Wilk test.
In R Shapiro-Wilk test is available as shapiro.test .
The p-value<0.05 implies (reject \(H_0\)) that the data is not normally distributed.
Shapiro-Wilk normality test
data: normal.data
W = 0.99212, p-value = 0.83
The p-value>0.05 implies (do not reject \(H_0\)) that the data is normally distributed.