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?
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
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.
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.
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.
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?
Our sample data comes from a sample of 14 students, with a sample mean of 6.9 hours and a sample standard deviation of 1.3 hours.
#record the sample data
n <- 14
ybar <- 6.9
s <- 1.3
The standard error is the sample standard deviation divided by the square root of the sample size.
SE <- s / sqrt(n)
SE
## [1] 0.3474396
Our standard error is approximately 0.35. The t-model has degrees of freedom equal to 13 (n - 1).
We calculate our t-statistic as follows:
t <- (ybar - mu) / SE
t
## [1] -109.6593
The sample’s t-statistic is approximately -1.72. This means our sample mean is about 1.72 standard errors below the hypothesized mean.
We calculate the P-value, which represents the probability of getting a sample mean this low (or lower) if the null hypothesis is true.
Since our alternative hypothesis is one-sided (less than), we find the left-tail probability.
P_value <- pt(t, df = n - 1)
P_value
## [1] 5.659609e-21
Our P-value is approximately 0.05.
If we use a 5% significance level, the result is just significant enough to suggest that the laptop’s average streaming battery life may be less than 7.5 hours. Thus, we would reject the null hypothesis and conclude that the true average battery life is likely shorter than claimed. —
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?
Our Null Hypothesis is that the population mean is 75 bpm. Our Alternative Hypothesis is that the population mean is greater than 75 bpm. This is a one-sided alternative hypothesis.
# H0: mu = 75
# HA: mu > 75
# one-sided (right-tailed) test
mu <- 75
Our sample data come from 20 students, with a sample mean of 78.6 bpm and a sample standard deviation of 7.9 bpm.
n <- 20
ybar <- 78.6
s <- 7.9
The standard error is calculated as follows:
SE <- s / sqrt(n)
SE
## [1] 1.766494
The standard error is approximately 1.77. Our model is a t-model with 19 degrees of freedom.
Next, we calculate our t-statistic:
t <- (ybar - mu) / SE
t
## [1] 2.037935
Our t-statistic is approximately 2.03, meaning the sample mean lies about two standard errors above the hypothesized mean.
Since our alternative hypothesis is one-sided (greater than), we calculate the right-tail probability.
P_value <- 1 - pt(t, df = n - 1)
P_value
## [1] 0.0278621
Our P-value is approximately 0.028.
With a P-value of 0.028, which is less than 0.05, we reject the null hypothesis. This provides significant evidence that caffeine increases mean pulse rate above the standard resting rate of 75 bpm.