hr <- c(75,77,86,108,61,46,82,78,81,
79,55,67,63,94,76,56,69,79,
66,78,77,91,82,80,73,62,76,80,83)STAT 516 hw 1
Students in a statistics class were asked to feel their pulses and count the number of heartbeats they felt during two thirty-second time periods separated by several minutes. For each student the two counts were added together in order to obtain a beats per minute (bpm) measurement. These bpm measurements are stored in the vector hr in the R code below:
1)
Check whether it appears the measurements come from a normal distribution by making a normal quantile-quantile plot.
qqnorm(scale(hr))
abline(0,1)2)
Report the sample mean
xbar <- mean(hr)
svar <- var(hr)
sn <- sqrt(svar)
n <- length(hr) Sample mean: 75.17241
Sample variance: 158.2192
Sample standard deviation: 12.57852
Sample size: 29
3)
Assume that the resting heart rate measurements are drawn from a normal distribution with unknown mean, but with a known standard deviation of
sigma <- 16
alpha <- 0.01
za2 <- qnorm(1-alpha/2)
lo <- xbar - za2 * sigma / sqrt(n)
up <- xbar + za2 * sigma / sqrt(n)The 99% confidence interval is (67.5193, 82.82553).
4)
Now give a
ta2 <- qt(1-alpha/2,n-1)
lo <- xbar - ta2 * sn / sqrt(n)
up <- xbar + ta2 * sn / sqrt(n)The 99% confidence interval is (68.71806, 81.62677).
5)
Suppose a researcher wished to estimate the mean resting heart rate of this population of students with a margin of error no greater than
M <- 2
alpha <- 0.05
za2 <- qnorm(1-alpha/2)
nr <- ceiling(za2^2 * sn^2 / M^2)The required sample size is 152.
6)
A researcher wishes to know whether the mean resting heart rate for this population of students exceeds
- The null and alternate hypotheses of interest.
- The value of the test statistic.
- The critical value for testing the hypothesis at significance level
. - The p-value for testing these hypotheses based on the data.
- The decision whether or not to reject
.
alpha <- 0.05
mu0 <- 73
Ttest <- (xbar - mu0)/(sn/sqrt(n))
ta <- qt(1-alpha,n-1)
pval <- 1 - pt(Ttest,n-1)
dec <- ifelse(pval < alpha, "Reject H0", "Fail to reject H0")i. Testing H0: mu <= 73 vs H1: mu > 73
ii. Test statistic: 0.9300621
iii. Critical value: 1.701131
iv. p-value: 0.1801444
v. Decision: Fail to reject H0
7)
A researcher wishes to know whether the mean resting heart rate for this population of students equal to
- The null and alternate hypotheses of interest.
- The value of the test statistic.
- The critical value for testing the hypothesis at significance level
. - The p-value for testing these hypotheses based on the data.
- The decision whether or not to reject
.
alpha <- 0.10
mu0 <- 70
Ttest <- (xbar - mu0)/(sn/sqrt(n))
ta2 <- qt(1-alpha/2,n-1)
pval <- 2*(1 - pt(abs(Ttest),n-1))
dec <- ifelse(pval < alpha, "Reject H0", "Fail to reject H0")i. Testing H0: mu = 70 vs H1: mu != 70
ii. Test statistic: 2.214434
iii. Critical value: 1.701131
iv. p-value: 0.03511043
v. Decision: Reject H0
8)
Suppose a researcher wants to test whether the mean resting heart rate in this population of students is greater than
alpha <- 0.05
mu_star <- 77
mu0 <- 75
gamma_star <- 0.9
beta_star <- 1 - gamma_star
za <- qnorm(1-alpha)
zb <- qnorm(1 - beta_star)
nr <- ceiling(sn^2 *(za + zb)^2/(mu_star - mu0)^2)
mu <- seq(72,80,length=500)
gm <- 1 - pnorm(za - (mu - mu0)/(sn/sqrt(nr)))
plot(gm ~mu,type ="l")
abline(h = gamma_star,lty = 3)
abline(v = mu_star,lty = 3)
abline(v = mu0,col="gray")
abline(h = alpha,col="gray")The required sample size is 339.
9)
Suppose a researcher wants to test whether the mean resting heart rate in this population of students is equal to
alpha <- 0.01
mu_star <- 80 # pick a value 2 blm away from mu0
mu0 <- 78
gamma_star <- 0.80
beta_star <- 1 - gamma_star
za2 <- qnorm(1-alpha/2)
zb <- qnorm(1 - beta_star)
nr <- ceiling(sn^2 *(za2 + zb)^2/(mu_star - mu0)^2)
mu <- seq(74,82,length=500)
gmr <- 1 - pnorm(za2 - (mu - mu0)/(sn/sqrt(nr)))
gml <- pnorm(-za2 - (mu - mu0)/(sn/sqrt(nr)))
gm <- gmr + gml
plot(gm ~mu,type ="l")
abline(h = gamma_star,lty = 3)
abline(v = mu0 + 2,lty = 3)
abline(v = mu0 - 2,lty = 3)
abline(v = mu0,col="gray")
abline(h = alpha,col="gray")The required sample size is 462.