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)

## The 95% bootstrap interval is:
quantile(mboot, c(0.025, 0.975))
   2.5%   97.5% 
144.200 167.305 
  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

\[m \pm t_{\alpha/2, n-1} \frac{s}{\sqrt{n}}\]

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

Exercise 2 The 95% confidence interval for a proportion can be computed using the formula \(p \pm z SE,\) where \(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] 0.3232643 0.5167357
  1. A narrower confidence interval can be obtained by increasing the sample size. It can also be made narrower by lowering the confidence level, for example from 95% to 90%.

  2. Change the z number,

The approximate confidence interval for a proportion is

\[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 object’s mean weight
  2. Compute a 90% confidence interval of the object’s mean weight

Because the measurement error standard deviation is known, a normal-based confidence interval can be used.

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

  1. Compute a 95% confidence interval of the sample mean weight
## 95% confidence interval
m <- 43
sigma <- 2.3
n <- 10
z <- qnorm(0.975)
c(m - z*sigma/sqrt(10), m + z*sigma/sqrt(10))
[1] 41.57447 44.42553
  1. Compute a 90% confidence interval of the sample mean weight
z <- qnorm(0.95)
c(m - z*sigma/sqrt(10), m + z*sigma/sqrt(10))
[1] 41.80366 44.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 the proportion of smokers; \(p=25/150=1/6\).

The approximate confidence interval for a proportion is

\(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