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)}.\]

Unknown standard deviation

Confidence interval (unknown standard deviation)

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

cwei <- favstats( weight ~ feed, data = chickwts)
se <- cwei$sd / sqrt(cwei$n) # Standard errors
tscore <- qt(p = .975, df = cwei$n - 1) # t-scores for 2.5% right tail probability (qdist cannot take multiple df's)
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_errorbar(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 interpretation

Confidence interval for the variance

The sample variance

The \(\chi^2\)-distribution

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