# NOT RUN {
## EXAMPLE 1:
## Hospital episodes (Levy and Lemeshow 1999, page 176 -- 178)
## We plan to take a sample of the members of a health maintenance
## organisation (HMO) for purposes of estimating the average number
## of hospital episodes per person per year. The sample will be selected
## from membership lists according to age (under 45 years, 45 -- 64 years,
## 65 years and over). The number of members in each strata are 600, 500,
## and 400 (respectively). Previous data estimates the mean number of
## hospital episodes per year for each strata as 0.164, 0.166, and 0.236
## (respectively). The variance of these estimates are 0.245, 0.296, and
## 0.436 (respectively). How many from each strata should be sampled to be
## 95% that the sample estimate of hospital episodes is within 20% of the
## true value?
strata.n <- c(600, 500, 400)
strata.xbar <- c(0.164, 0.166, 0.236)
strata.sigma <- sqrt(c(0.245, 0.296, 0.436))
epi.ssstrataestc(strata.n, strata.xbar, strata.sigma, epsilon.r = 0.20,
conf.level = 0.95)
## The number allocated to the under 45 years, 45 -- 64 years, and 65 years
## and over stratums should be 223, 186, and 149 (a total of 558). These
## results differ from the worked example provided in Levy and Lemeshow where
## certainty is set to approximately 99%.
# }
Run the code above in your browser using DataLab