User: \section{Q4}
[20pt]: A study was conducted to investigate whether a new type of exercise program can improve the average sleep quality of adults, measured in hours per night, compared to the known average sleep quality of 7.2 hours. Fifteen participants were recruited and asked to follow the new exercise program. Their sleep quality (in hours per night) was recorded and stored in the sleep.xlsx file.

\begin{enumerate}[label = (\roman*)]
    \item {[10pt] Test the hypothesis that the new exercise program improves the average sleep quality by at least 0.3 hours per night at a significance level of 0.01. Write down your null and alternative hypotheses.}

    \item {[10pt] If you re-design the experiment (with the same hypotheses as in (a)), how many par-
ticipants in total are you going to recruit to ensure a power of 0.90? For this question, we
assume the standard deviation of sleep quality is 0.8 hours, and the new exercise program
improves the average sleep quality by 0.5 hours per night.}
\end{enumerate}



\section{Q4}
[20pt]: A study was conducted to investigate whether a new type of exercise program can improve the average sleep quality of adults, measured in hours per night, compared to the known average sleep quality of 7.2 hours. Fifteen participants were recruited and asked to follow the new exercise program. Their sleep quality (in hours per night) was recorded and stored in the sleep.xlsx file.

\begin{enumerate}[label = (\roman*)]
    \item {[10pt] Test the hypothesis that the new exercise program improves the average sleep quality by at least 0.3 hours per night at a significance level of 0.01. Write down your null and alternative hypotheses.}

    \item {[10pt] If you re-design the experiment (with the same hypotheses as in (a)), how many par-
ticipants in total are you going to recruit to ensure a power of 0.90? For this question, we
assume the standard deviation of sleep quality is 0.8 hours, and the new exercise program
improves the average sleep quality by 0.5 hours per night.}
\end{enumerate}



\section{Q4}
[20pt]: A study was conducted to investigate whether a new type of exercise program can improve the average sleep quality of adults, measured in hours per night, compared to the known average sleep quality of 7.2 hours. Fifteen participants were recruited and asked to follow the new exercise program. Their sleep quality (in hours per night) was recorded and stored in the sleep.xlsx file.

\begin{enumerate}[label = (\roman*)]
    \item {[10pt] Test the hypothesis that the new exercise program improves the average sleep quality by at least 0.3 hours per night at a significance level of 0.01. Write down your null and alternative hypotheses.}

    \item {[10pt] If you re-design the experiment (with the same hypotheses as in (a)), how many par-
ticipants in total are you going to recruit to ensure a power of 0.90? For this question, we
assume the standard deviation of sleep quality is 0.8 hours, and the new exercise program
improves the average sleep quality by 0.5 hours per night.}
\end{enumerate}
Assistant:  Let'sLet's address each part of the question step-by-step.

---

### Given Information
- Known average sleep quality (population mean before intervention): \(\mu_0 = 7.2\) hours
- Sample size: \(n = 15\)
- Significance level: \(\alpha = 0.01\)
- Standard deviation (for power analysis): \(\sigma = 0.8\)
- Hypothesized improvement: at least 0.3 hours (for hypothesis test), and 0.5 hours (for power analysis)
- The data file **sleep.xlsx** should contain the sleep quality data of the 15 participants after following the exercise program. (You will need to load this data to perform the test.)

---

## (i) Hypothesis Testing to check if new exercise program improves sleep quality by at least 0.3 hours

---

### Step 1: Define the null and alternative hypotheses

The problem states the goal is to test if the program improves the sleep quality by **at least** 0.3 hours. So the hypotheses can be set up as:

\[
H_0: \mu \leq 7.5 \quad \text{(no improvement or less than 0.3 hours improvement)},
\]
\[
H_a: \mu > 7.5 \quad \text{(improvement of more than 0.3 hours)}.
\]

Explanation: Since improvement of at least 0.3 hours means target sleep quality is \(7.2 + 0.3 = 7.5\) hours. The null hypothesis assumes the mean sleep quality is at most 7.5 (no sufficient improvement), the alternative assumes it is greater than 7.5 (meaning sufficient improvement).

---

### Step 2: Calculate sample mean \(\bar{x}\) and sample standard deviation \(s\)

You will read the data from **sleep.xlsx**, then compute:

\[
\bar{x} = \frac{1}{n} \sum_{i=1}^n x_i,
\]
\[
s = \sqrt{\frac{1}{n-1} \sum_{i=1}^n (x_i - \bar{x})^2}
\]

---

### Step 3: Perform a one-sample t-test (right-tailed)

The test statistic is:

\[
t = \frac{\bar{x} - 7.5}{s / \sqrt{n}}
\]

The degrees of freedom is \(df = n-1 = 14\).

---

### Step 4: Determine the critical value

At significance level \(\alpha = 0.01\) for a one-sided t-test with df = 14, the critical t-value \(t_{\alpha, df}\) can be obtained from t-distribution tables or software.

---

### Step 5: Decision

- If \(t > t_{\alpha, df}\), reject \(H_0\), conclude the program significantly improves sleep quality by at least 0.3 hours.
- Else, fail to reject \(H_0\).

---

### Summary for Part (i):

\[
\boxed{
\begin{cases}
H_0: \mu \leq 7.5, \\
H_a: \mu > 7.5.
\end{cases}
}
\]

Perform a one-sided t-test. Based on the data in sleep.xlsx, calculate sample mean and sample standard deviation, then compute the test statistic \(t\). Compare to critical value at \(\alpha=0.01\).

---

## (ii) Power Analysis: Calculate required sample size for desired power

---

### Step 1: Define parameters for sample size calculation

- Significance level: \(\alpha = 0.01\), one-sided test
- Power: \(1 - \beta = 0.90\)
- Effect size (true mean difference): \(\delta = 0.5\) hours improvement
- Standard deviation: \(\sigma = 0.8\)
- Null mean: \(\mu_0 = 7.5\) (since testing improvement of 0.3 hours, the test threshold is 7.5)
- Alternative mean: \(\mu_a = 7.2 + 0.5 = 7.7\)

Effectively, the difference to detect is:

\[
d = \mu_a - \mu_0 = 7.7 - 7.5 = 0.2\text{ hours}
\]

---

### Step 2: Calculate standardized effect size

\[
\text{Effect size} = \frac{d}{\sigma} = \frac{0.2}{0.8} = 0.25
\]

Note: This is the **minimum detectable difference** over the null hypothesis mean (7.5). 

---

### Step 3: Use the formula for sample size for one-sample t-test (approximate with z-distribution)

Sample size formula for a one-sided test:

\[
n = \left( \frac{ z_{1-\alpha} + z_{1-\beta} }{ \delta / \sigma } \right)^2
\]

Where:

- \(z_{1-\alpha}\) is the critical z-value for significance level 0.01 (one-sided)
- \(z_{1-\beta}\) is the z-value for power \(1 - \beta = 0.90\)

Lookup values:

- \(z_{1-0.01} = z_{0.99} \approx 2.33\)
- \(z_{0.90} \approx 1.28\)

---

### Step 4: Calculate sample size \(n\)

\[
n = \left( \frac{2.33 + 1.28}{0.25} \right)^2 = \left( \frac{3.61}{0.25} \right)^2 = (14.44)^2 = 208.5
\]

---

Therefore, you would need approximately **209 participants** in total to ensure a power of 0.90 to detect an improvement of 0.5 hours in average sleep quality at \(\alpha=0.01\).

---

**Note:** Since this is a one-sample test, the total sample size equals the group size because it is a single group measured against a known mean.

---

# **Summary**

| Part | Task | Result |
|-------|------|--------|
| (i) | Hypotheses | \( H_0: \mu \leq 7.5 \), \(H_a: \mu > 7.5\) |
| (i) | Test type | One-sided one-sample t-test at \(\alpha=0.01\) |
| (i) | Test statistic | \( t = \frac{\bar{x} - 7.5}{s/\sqrt{15}} \) |
| (ii) | Sample size formula | \( n = \left( \frac{z_{1-\alpha} + z_{1-\beta}}{\delta/\sigma} \right)^2 \) |
| (ii) | Computed sample size | \( \approx 209 \) participants |

---

If you want, I can help with:

- Performing the t-test if you provide the data from **sleep.xlsx**.
- Writing the code in R/Python to perform these calculations.
- More detailed explanation of assumptions or underlying theory.
User: the sample size formula is not taught, use another formula instead.
Assistant: