STAT 516 hw 1

Author

Karl Gregory

Students in a statistics class were asked to feel their pulses and count the number of heartbeats they felt during a thirty-second time period. These were doubled in order to obtain beats per minute (bpm) measurements. These are stored in the vector hr in the R code below:

hr <- c(80, 118, 92, 84, 78, 84, 
        76, 82, 76, 88, 108, 90, 
        90, 90, 86, 70, 68, 46, 
        98, 56, 84, 80, 78, 66, 60)

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 X¯n, sample variance Sn2, and sample standard deviation Sn of the measurements.

xbar <- mean(hr)
svar <- var(hr)
sn <- sqrt(svar)
 Sample mean: 81.12  
 Sample variance: 238.6933 
 Sample standard deviation: 15.4497

3)

Assume that the resting heart rate measurements are drawn from a normal distribution with unknown mean, but with a known standard deviation of 16 beats per minute (bpm). Give a 99% confidence interval for the mean resting heart rate based on the measurements from the students.

n <- length(hr)
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 (72.87735, 89.36265).

4)

Now give a 99% confidence interval for the mean resting heart rate based on the measurements of the students, using the estimated standard deviation Sn in place of σ. That is, assume now that σ is unknown and must be estimated with Sn.

ta2 <- qt(1-alpha/2,n-1)
lo <- xbar - ta2 * sn / sqrt(n)
up <- xbar + ta2 * sn / sqrt(n)
The 99% confidence interval is (72.47762, 89.76238).

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 2 beats per minute with 95% confidence. Using Sn as a guess for σ, suggest a sample size which should be just large enough for the researcher.

M <- 2
alpha <- 0.05
za2 <- qnorm(1-alpha/2)
nr <- ceiling(za2^2 * sn^2 / M^2)
The required sample size is 230.

6)

A researcher wishes to know whether the mean resting heart rate for this population of students exceeds 80 bpm. Give

  1. The null and alternate hypotheses of interest,
  2. The value of the test statistic,
  3. The critical value for testing the hypothesis at significance level α=0.05,
  4. The decision whether or not to reject H0, and
  5. The p-value for testing these hypotheses based on the data.
# Testing H_0: \mu \leq 85 vs H_1: \mu > 85.
alpha <- 0.05
mu0 <- 80
Ttest <- (xbar - mu0)/(sn/sqrt(n))
ta <- qt(1-alpha,n-1)
pval <- 1 - pt(Ttest,n-1)
Testing H0: mu <= 80 vs H1: mu > 80 
Test statistic: 0.3624665
Critical value: 1.710882
Decision: Fail to reject H0 
p-value: 0.3600879

7)

A researcher wishes to know whether the mean resting heart rate for this population of students equal to 82 bpm.

  1. The null and alternate hypotheses of interest,
  2. The value of the test statistic,
  3. The critical value for testing the hypothesis at significance level α=0.10,
  4. The decision whether or not to reject H0, and
  5. The p-value for testing these hypotheses based on the data.
alpha <- 0.10
mu0 <- 82
Ttest <- (xbar - mu0)/(sn/sqrt(n))
ta2 <- qt(1-alpha/2,n-1)
pval <- 2*(1 - pt(abs(Ttest),n-1))
Testing H0: mu = 82 vs H1: mu != 82 
Test statistic: -0.2847951
Critical value: 1.710882
Decision: Fail to reject H0 
p-value: 0.7782442

8)

Suppose a researcher wants to test whether the mean resting heart rate in this population of students is greater than 75 bpm. If the true mean is 77 bpm or greater, the researcher would like to detect this with probability at least 90% while using a significance level of α=0.05. Using the sample standard deviation as an estimate of the unknown population standard deviation σ, give a recommended sample size for the researcher.

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 512.

9)

Suppose a researcher wants to test whether the mean resting heart rate in this population of students is equal to 78 bpm. If the true mean lies 2 bpm or more away from this value, the researcher would like to detect this with probability at least 80% while using a significance level of α=0.01. Using the sample standard deviation as an estimate of the unknown population standard deviation σ, give a recommended sample size for the researcher.

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 697.