6 Hypothesis testing

Suppose you wanted to determine whether the mean waiting time in the drive-through line of a fast-food restaurant is less than 5 minutes, or whether the majority of consumers are optimistic about the economy.

In both cases you are interested in making an inference about how the value of a parameter relates to a specific numerical value.

Is it less than, equal to, or greater than the specified number? This type of inference, called a test of hypothesis.

6.1 The elements of a test of hypothesis

Suppose building specifications in a certain city require that the average breaking strength of residential sewer pipe be more than 2,400 pounds per foot of length (i.e., per linear foot). Each manufacturer who wants to sell pipe in this city must demonstrate that its product meets the specification.

Note that we are interested in making an infer- ence about the mean \(\mu\) of a population. However, in this example we are less interested in estimating the value of m than we are in testing a hypothesis about its value.It means, we want to decide whether the mean breaking strength of the pipe exceeds 2,400 pounds per linear foot.

A statistical hypothesis is a statement about the numerical value of a population parameter.

We define two hypotheses:

The null hypothesis, denoted H0, represents the hypothesis that will be accepted unless the data provide convincing evidence that it is false. This usually represents the "status quo"" or some claim about the population parameter that the researcher wants to test.
The alternative (research) hypothesis, denoted Ha, represents the hypothesis that will be accepted only if the data provide convincing evidence of its truth. This usu- ally represents the values of a population parameter for which the researcher wants to gather evidence to support.

In our example:

  • Null hypothesis (H0): \(\mu\) < 2,400 (i.e., the manufacturer>s pipe does not meet specifications)
  • Alternative (research) hypothesis (H1): \(\mu\) > 2,400 (i.e., the manufacturer>s pipe meets specifications)

How can the city decide when enough evidence exists to conclude that the manufacturer’s pipe meets specifications?

Because the hypotheses concern the value of the population mean \(\mu\), it is reasonable to use the sample mean \(\bar{x}\) to make the inference, just as we did when forming confidence intervals for \(\mu\).

The city will conclude that the pipe meets specifications only when the sample mean \(\bar{x}\) convincingly indicates that the population mean exceeds 2,400 pounds per linear foot.

To decide, we compute a test statistic, i.e., a numerical value computed from the sample. Here, the test statistic is the z-value that measures the distance (in units of the standard deviation) between the value of \(\bar{x}\) and the value of \(\mu\) specified in the null hypothesis.

The idea is that if the hypothesis that \(\mu\) equals 2,400 can be rejected in favor of \(\mu\) > 2,400, then \(\mu\) less than or equal to 2,400 can certainly be rejected. Thus, the test statistic is:

\[ z = \frac{\bar{x}- 2400}{\sigma\sqrt{n}} \]

Note that a value of \(z = 1\) means that \(\bar{x}\) is 1 standard deviation above \(\mu = 2,400\); a value of z = 1.5 means that \(\bar{x}\) is 1.5 standard deviations above \(\mu = 2,400\); and so on.

The test statistic is a sample statistic, computed from information provided in the sample, that the res

To illustrate the use of the test, suppose we test 50 sections of sewer pipe and find the mean and standard deviation for these 50 measurements to be:

df <- tibble(
x = rnorm(50, 2460, 200)
)
mean(df$x)
## [1] 2485.492
sd(df$x)
## [1] 184.7366
t.test(x =df$x , mu=2400, alternative =  "greater")
## 
##  One Sample t-test
## 
## data:  df$x
## t = 3.2723, df = 49, p-value = 0.0009792
## alternative hypothesis: true mean is greater than 2400
## 95 percent confidence interval:
##  2441.691      Inf
## sample estimates:
## mean of x 
##  2485.492

We need to read the p-value. If the p-value is lower than 0.05, we can reject H0. In our case, we cannot reject H0. The true mean is not greater than 2400.