Estimation

The ASTA team

Point and interval estimates

Point and interval estimates

Point estimators: Bias

Point estimators: Consistency

Point estimators: Efficiency

Notation

Confidence intervals

Confidence Interval

Confidence interval for the mean (known standard deviation)

\[Z=\frac{\bar{X}-\mu}{\sigma/\sqrt{n}} \sim \texttt{norm(0,1)}.\]

Confidence interval (unknown standard deviation)

\[ T=\frac{\bar{X}-\mu}{S/\sqrt{n}} \sim \texttt{t}(n-1).\]

Calculation of critical \(t\)-value in R

qdist("t", p = 1 - 0.025, df = 4)

## [1] 2.776445

Example: Confidence interval for mean

stats <- favstats( ~ mpg, data = mtcars)
stats
##   min     Q1 median   Q3  max     mean       sd  n missing
##  10.4 15.425   19.2 22.8 33.9 20.09062 6.026948 32       0
qdist("t", 1 - 0.025, df = 32 - 1, plot = FALSE)
## [1] 2.039513
t.test( ~ mpg, data = mtcars, conf.level = 0.95)
## 
##  One Sample t-test
## 
## data:  mpg
## t = 18.857, df = 31, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
##  17.91768 22.26357
## sample estimates:
## mean of x 
##  20.09062

Example: Plotting several confidence intervals in R

An experiment was conducted to measure and compare the effectiveness of various feed supplements on the growth rate of chickens. Newly hatched chicks were randomly allocated into six groups, and each group was given a different feed supplement. Their weights in grams after six weeks are given along with feed types.

cwei <- favstats( weight ~ feed, data = chickwts)
se <- cwei$sd / sqrt(cwei$n) # Standard errors
tscore <- qdist("t", p = .975, df = cwei$n - 1, plot = FALSE) # t-scores for 2.5% right tail probability
cwei$lower <- cwei$mean - tscore * se
cwei$upper <- cwei$mean + tscore * se
cwei[, c("feed", "mean", "lower", "upper")]
##        feed     mean    lower    upper
## 1    casein 323.5833 282.6440 364.5226
## 2 horsebean 160.2000 132.5687 187.8313
## 3   linseed 218.7500 185.5610 251.9390
## 4  meatmeal 276.9091 233.3083 320.5099
## 5   soybean 246.4286 215.1754 277.6818
## 6 sunflower 328.9167 297.8875 359.9458
gf_errorbarh(feed ~ lower + upper, data = cwei) %>% 
  gf_point(feed ~ mean)

Confidence interval for proportion

Example: Point and interval estimate for proportion

library(mosaic)
tally( ~ sex, data = Chile)
## sex
##    F    M 
## 1379 1321
tally( ~ sex, data = Chile, format = "prop")
## sex
##         F         M 
## 0.5107407 0.4892593

Example: Confidence intervals for proportion in R

prop.test( ~ sex, data = Chile, correct = FALSE)
## 
##  1-sample proportions test without continuity correction
## 
## data:  Chile$sex  [with success = F]
## X-squared = 1.2459, df = 1, p-value = 0.2643
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.4918835 0.5295675
## sample estimates:
##         p 
## 0.5107407

Example: Chile data

We could also have computed a 99% confidence interval for the proportion of females in Chile:

Confidence interval for variance

Example: confidence interval for a variance

stats <- favstats( ~ mpg, data = mtcars)
stats
##   min     Q1 median   Q3  max     mean       sd  n missing
##  10.4 15.425   19.2 22.8 33.9 20.09062 6.026948 32       0
qdist("chisq", 1 - 0.025, df = 32 - 1 )

## [1] 48.23189
qdist("chisq",  0.025, df = 32 -1)

## [1] 17.53874

Determining sample size

Determining sample size

Sample size for proportion

Example

Sample size for mean