Example Problem: Coffee and Concentration

A nutritionist claims that students who drink coffee before studying focus for an average of 45 minutes before losing concentration. A sample of 18 students who drank coffee lasted an average of 52.3 minutes, with a standard deviation of 12.1 minutes. Is there evidence that the average focus time is greater than 45 minutes?

Hypotheses and sample information

Our Null Hypothesis is that the population average is 45 minutes. Our Alternative Hypothesis is that the population average is greater than 45 minutes. This is a one-sided alternative hypothesis.

# H0 is that mu = 45 minutes
# HA is that mu is greater than 45 minutes (mu > 45)
# HA is a one-sided alternative hypothesis

#record the hypothesized mean
mu <- 45

Our sample data, as described in the problem, comes from a sample of 18 students. The sample average was 52.3 minutes, and the sample standard deviation was 12.1 minutes.

#record the sample data
n <- 18
ybar <- 52.3
s <- 12.1

Calculating Standard Error, our t-model, and our t-statistic

Our standard error is our sample standard deviation, divided by the square root of our sample size.

#calculate SE
SE <- s/sqrt(n)

SE
## [1] 2.851997

Therefore, we see that our standard error in this problem is approximately 2.85.

Our model is the t-model, with degrees of freedom equal to 17 (that is, the sample size minus 1). Our t-model is centere at mu=45, and with spread given by SE=2.85.

Given this t-model, our sample mean has the following t-statistic:

#calculate the t-statistic for our sample
t <- (ybar - mu)/SE

t
## [1] 2.55961

Therefore, our sample’s t-statistic is approximately 2.56. Our given sample sits above the center of the t-model, specifically 2.56 measurements of the SE above the center.

P-value

We wish to calculate the P-value, which tells us the chance of getting a sample with a t-statistic as large (or larger) than ours if the null hypothesis is true.

Our alternative hypothesis was one-sided, focusing on the “greater than” side (i.e., the right side) of the t-model.

P_value <- 1-pt(t, df=n-1)

P_value
## [1] 0.01015207

We see that our P-value is approximately 0.01.

Conclusion

Based on our P-value of 0.01, our conclusion is that, if the null hypothesis were true, the chances of getting a sample with a t-statistic as large as ours would occur only 1% of the time. This is very small, and well below a threshold of 0.05. This leads us to reject the null hypothesis and accept the alternative hypothesis. It is likely that the average focus time is greater than 45 minutes.


Problem 1: Laptop Battery Drain.

A tech reviewer claims that a certain laptop model averages 7.5 hours of battery life when streaming video. A group of 14 students test the same model under identical conditions and find a mean battery life of 6.9 hours with a standard deviation of 1.3 hours. Is there evidence that the average streaming battery life is less than 7.5 hours?

# H0 is that mu = 7.5 hours
# HA is that mu is less than 7.5 hours (mu > 7.5)
# HA is a one-sided alternative hypothesis

#record the hypothesized mean
mu <- 7.5

Our sample data, as described in the problem, comes from a sample of 14 students. The sample average was 6.9 hours, and the sample standard deviation was 1.3 hours

#record the sample data
n <- 14
ybar <- 6.9
s <- 1.3

Calculating Standard Error, our t-model, and our t-statistic

Our standard error is our sample standard deviation, divided by the square root of our sample size.

#calculate SE
SE <- s/sqrt(n)

SE
## [1] 0.3474396

Therefore, we see that our standard error in this problem is approximately 0.3474396.

Our model is the t-model, with degrees of freedom equal to 13 (that is, the sample size minus 1). Our t-model is centere at mu=7.5, and with spread given by SE=0.3474396.

Given this t-model, our sample mean has the following t-statistic:

#calculate the t-statistic for our sample
t <- (ybar - mu)/SE

t
## [1] -1.726919

We wish to calculate the P-value, which tells us the chance of getting a sample with a t-statistic as large (or larger) than ours if the null hypothesis is true.

Our alternative hypothesis was one-sided, focusing on the “greater than” side (i.e., the right side) of the t-model.

P_value <- 1-pt(t, df=n-1)

P_value
## [1] 0.9460749

We see that our P-value is approximately 0.9460749.

Conclusion

Because the P-value (0.946) is much larger than our significance level α=0.05, we fail to reject the null hypothesis. There is no statistical evidence to support the claim that the laptop’s average streaming battery life is less than 7.5 hours.

Problem 2: Caffeine and Pulse Rate.

A health science student measures the resting pulse rate of 20 classmates 20 minutes after drinking a cup of coffee. The sample mean is 78.6 beats per minute, with a standard deviation of 7.9. The standard resting rate for college-aged adults is 75 bpm. Do the data suggest that caffeine increases mean pulse rate above 75 bpm?

# H0 is that mu = 75 bpm
# HA is that mu is more than 75 bpm (mu < 75)
# HA is a one-sided alternative hypothesis

#record the hypothesized mean
mu <- 75

Our sample data, as described in the problem, comes from a sample of 20 students. The sample average was 78.6 bpm, and the sample standard deviation was 7.9 bpm

#record the sample data
n <- 20
ybar <- 78.6
s <- 7.9

Calculating Standard Error, our t-model, and our t-statistic

Our standard error is our sample standard deviation, divided by the square root of our sample size.

#calculate SE
SE <- s/sqrt(n)

SE
## [1] 1.766494

Therefore, we see that our standard error in this problem is approximately 1.766494

Our model is the t-model, with degrees of freedom equal to 19 (that is, the sample size minus 1). Our t-model is centere at mu=75, and with spread given by SE=1.766494

Given this t-model, our sample mean has the following t-statistic:

#calculate the t-statistic for our sample
t <- (ybar - mu)/SE

t
## [1] 2.037935

We wish to calculate the P-value, which tells us the chance of getting a sample with a t-statistic as large (or larger) than ours if the null hypothesis is true.

Our alternative hypothesis was one-sided, focusing on the “greater than” side (i.e., the right side) of the t-model.

P_value <- 1-pt(t, df=n-1)

P_value
## [1] 0.0278621

We see that our P-value is approximately 0.0278621.

Conclusion

The P-value is 0.028, which is less than our significance level α=0.05.Therefore, we reject the null hypothesis.