Exercises: Point and interval estimates

Exercise 1 You measure the Hb value in 10 50-year old men and get the following observations; 145, 165, 134, 167, 158, 176, 156, 189, 143, 123 g/L.

  1. Compute a 95% bootstrap interval for the mean Hb value.
  2. Compute the sample mean Hb value
  3. Compute the sample variance
  4. Compute the sample standard deviation
  5. Assume that Hb is normally distributed and compute a point estimate and a 95% confidence interval for the mean Hb value.
obs <- c(145, 165, 134, 167, 158, 176, 156, 189, 143, 123)
mboot <- replicate(1000, {
  x <- sample(obs, size=10, replace=TRUE)
  mean(x)
})
hist(mboot)

## 95% confidence interval
quantile(mboot, c(0.025, 0.975))
 2.5% 97.5% 
144.6 167.5 
  1. Sample mean
(m <- mean(obs))
[1] 155.6
  1. Sample variance
(v <- var(obs))
[1] 395.1556
  1. Sample standard deviation
(s <- sd(obs))
[1] 19.87852
  1. The point estimate is the sample mean, \(m=155.6\).

The sample size is small (\(n=10\)) and the population standard deviation unknown, hence we use the t-statistic;

\[T = \frac{\bar X - \mu}{\frac{s}{\sqrt{n}}}\] and compute the 95% confidence interval as

\[\mu = m \pm t_{\alpha/2} \frac{s}{\sqrt{n}}\]

n <- length(obs)
t <- qt(0.975, df=9)
##95% confidence interval 
c(m - t*s/sqrt(n), m + t*s/sqrt(n))
[1] 141.3798 169.8202

Exercise 2 The 95% confidence interval for a proportion can be computed using the formula \(\pi = p \pm z SE,\) where \(\pi\) is the population prportion, \(p\) the sample proportion and the standard error \(SE = \sqrt{\frac{p(1-p)}{n}}\). \(z=1.96\) for a 95% confidence interval.

We study the proportion of pollen allergic people in Uppsala and in a random sample of size 100 observe 42 pollen allergic people.

  1. Calculate a 95% confidence interval for \(\pi\)
  2. How can we get a narrower confidence interval?
  3. We computed a 95% interval, what if we want a 90% confidence interval?
  4. or a 99% confidence interval?
  1. See lecture notes

  2. Calculate a 90% confidence interval instead. Or sample more people than 100.

  3. Change the z number,

\[\pi = p \pm z SE\]

For a 90% confidence interval use z=1.64

p <- 0.42
n <- 100
SE <- sqrt(p*(1-p)/n)
z <- qnorm(0.95)
c(p - z*SE, p + z*SE)
[1] 0.3388168 0.5011832
  1. or a 99% confidence interval?
z <- qnorm(0.995)
c(p - z*SE, p + z*SE)
[1] 0.2928678 0.5471322

Exercise 3 A scale has a normally distributed error with mean 0 and standard deviation 2.3 g. You measure an object 10 times and observe the mean weight 43 g.

  1. Compute a 95% confidence interval of the objects weight
  2. Compute a 90% confidence interval of the objects weight

The measured weight is a random variable \(X \sim N(\mu, \sigma)\). You know that \(\sigma = 2.3\), \(\mu\) is the weight of the object.

  1. Compute a 95% confidence interval of the sample weight
## 95% confidence interval
m <- 42
sigma <- 2.3
n <- 10
z <- qnorm(0.975)
c(m - z*sigma/sqrt(10), m + z*sigma/sqrt(10))
[1] 40.57447 43.42553
  1. Compute a 90% confidence interval of the sample weight
z <- qnorm(0.95)
c(m - z*sigma/sqrt(10), m + z*sigma/sqrt(10))
[1] 40.80366 43.19634

Exercise 4 You observe 150 students at BMC of which 25 are smokers. Compute a 95% confidence interval for the proportion of smokers among BMC students.

Point estimate of proportion smokers; \(p=25/150=1/6\).

\(\pi = p \pm z SE\)

p <- 25/150
n <- 150
z <-qnorm(0.975)
SE <- sqrt(p*(1-p)/n)
## 95% CI
c(p - z*SE, p + z*SE)
[1] 0.1070269 0.2263065