## The 95% bootstrap interval is:quantile(mboot, c(0.025, 0.975))
2.5% 97.5%
144.200 167.305
Sample mean
(m <-mean(obs))
[1] 155.6
Sample variance
(v <-var(obs))
[1] 395.1556
Sample standard deviation
(s <-sd(obs))
[1] 19.87852
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.
Calculate a 95% confidence interval for \(\pi\)
How can we get a narrower confidence interval?
We computed a 95% interval, what if we want a 90% confidence interval?
or a 99% confidence interval?
Solution
[1] 0.3232643 0.5167357
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%.
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.42n <-100SE <-sqrt(p*(1-p)/n)z <-qnorm(0.95)c(p - z*SE, p + z*SE)
[1] 0.3388168 0.5011832
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.
Compute a 95% confidence interval of the object’s mean weight
Compute a 90% confidence interval of the object’s mean weight
Hint
Because the measurement error standard deviation is known, a normal-based confidence interval can be used.
Solution
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.
Compute a 95% confidence interval of the sample mean weight
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.
Solution
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/150n <-150z <-qnorm(0.975)SE <-sqrt(p*(1-p)/n)## 95% CIc(p - z*SE, p + z*SE)