This function demonstrates the advantage of ratio estimation when further information (ratio) about x and y is available.
sample.ratio(
X = runif(50, 0, 5),
R = 1,
Y = R * X + rnorm(X),
size = length(X)/2,
p.col = c("blue", "red"),
p.cex = c(1, 3),
p.pch = c(20, 21),
m.col = c("black", "gray"),
legend.loc = "topleft",
...
)
the X variable (ancillary)
the population ratio Y/X
the Y variable (whose mean we what to estimate)
sample size
point colors, magnification and symbols for the population and sample respectively
color for the horizontal line to denote the sample mean of Y
legend location: topleft, topright, bottomleft,
bottomright, ... (see legend
)
other arguments passed to plot.default
A list containing
X population
Y population
population ratio
ratio calculated from samples
population mean of Y
simple sample mean of Y
sample mean of Y via ratio estimation
From this demonstration we can clearly see that the ratio estimation is generally better than the simple sample average when the ratio R really exists, otherwise ratio estimation may not help.
Examples at https://yihui.org/animation/example/sample-ratio/
sample
, sample.simple
,
sample.cluster
, sample.strat
,
sample.system