# Lecture_32
Author: Zheyuan Wu
Date: 2023-04-10

#### Zheyuan Wu

#### 2023-04-10

### Hypothesis test for Means (continue from last week)

Example: The Centers for Disease Control (CDC) reported on trends in weight, height and body mass index from the 1960’s through 2002. The general trend was that Americans were much heavier and slightly taller in 2002 as compared to 1960. In 2002, the mean weight for men was reported at 191 pounds. Suppose that an investigator hypothesizes that weights are even higher in 2006 (i.e., that the trend continued over the subsequent 4 years). A random sample of 45 American males was recruited in 2006 and their weights were measured. The sample mean weight was 197.1 pounds, and the sample standard deviation was 25.6 pounds. Use \(\alpha\) = 0.01.

Let \(X_1,...,X_n\) be a simple random sample form a population and let \(\bar X\) and \(S^2\) denote the sample mean and sample variance, respectively.

1. State the hypotheses

\[ H_0:\mu=\mu_0~~~H_0:\mu=\mu_0~~~H_0:\mu=\mu_0\\ H_a:\mu>\mu_0~~~H_a:\mu<\mu_0~~~H_a:\mu\neq \mu_0\\ \]

Example:

\[ H_0:\mu=191,H_a:\mu>191 \]

because they already assumes that the weights are higher

2. Compute the test statistic

\[ T_{H_0}={\bar X-\mu_0\over S/\sqrt{n}} \]

\(S/\sqrt{n}\) is the standard error of \(\bar X\).

Condition: the population is normal or \(n\geq 30\)

Example:

\[ n=45\geq 30,\bar X=197.1,\mu_0=191,S=25.6 \]

\[ T_{H_0}={197.1-191\over 25.6/\sqrt{45}}=1.598 \]

3. Reach a conclusion

- If \(H_0\) is true, \(T_{H_0}\sim T_{n-1}\)
- We want to determine if the observed value of \(T_{H_0}\) is unusual for a \(T_{n-1}\) random variable.
- If the observed value of \(T_{H_0}\) is unusual (determined by \(\alpha\)), then we reject \(H_0\).

1. Rejection rule or region:
   \(H_a:\mu>\mu_0\)

- Reject \(H_0\) if \(T_{H_0}\geq T_{n-1,\alpha}\)
  \(H_a:\mu<\mu_0\)
- Reject \(H_0\) if \(T_{H_0}\leq -T_{n-1,\alpha}\)
  \(H_a:\mu\neq\mu_0\)
- Reject \(H_0\) if \(T_{H_0}\geq T_{n-1,\alpha/2}~or~T_{H_0}\leq -T_{n-1,\alpha/2}\Leftrightarrow |T_{H_0}|\geq T_{n-1,\alpha/2}\)

2. p-value:
   \(H_a:\mu>\mu_0\)

- p-value = \(P(T\geq T_{H_0})\)
  \(H_a:\mu<\mu_0\)
- p-value = \(P(T\leq -T_{H_0})\)
  \(H_a:\mu\neq\mu_0\)
- p-value=\(P(T\geq abs(T_{H_0}))+P(T\leq -abs(T_{H_0}))\)

Reject \(H_0\) if p-value\(\leq \alpha\)

Example:

\[ \alpha=0.01,T_{H_0}=1.598,n=45(df=44)\\ H_a:\mu>191 \]

1. Reject rule Since \(T_{H_0}=1.598<2.414\), do not reject \(H_0\).

2. P value fail to reject \(H_0\).

3. State the conclusion in the context of the problem.

Example:

We do not have sufficient evidence to conclude that the average weight in 2006 was greater than that in 2001.

We can use R to compute test statistics and p-values

Example: Suppose we want to test

\(H_0:\mu=25\)

\(H_a:\mu\neq 25\)

using the data:

\[ 22.76~24.08~31.23~25.28~25.52~31.86~26.84~19.94~22.25~23.22 \]

    x <- c(22.76, 24.08, 31.23, 25.28, 25.52, 31.86, 26.84, 19.94, 22.25, 23.22)
    t.test(x,mu=25,alternative = "two.sided")

    ##
    ##  One Sample t-test
    ##
    ## data:  x
    ## t = 0.24708, df = 9, p-value = 0.8104
    ## alternative hypothesis: true mean is not equal to 25
    ## 95 percent confidence interval:
    ##  22.56965 28.02635
    ## sample estimates:
    ## mean of x
    ##    25.298

    # or "greater" or "less"