Visualize sampling fractions per stratum or power curves from svyplan results.
Arguments
- x
A svyplan object.
- ...
Additional graphical parameters passed to
barplot()(for strata) orplot()(for power and the budget frontier). These override the defaults, so you can setmain,col,ylab,xlab,ylim, etc.- npoints
Number of points in the grid: the power curve (default 101) or the budget frontier (default 25, since each point is a solve).
- newdata
Optional one-column data frame of
budgetvalues forplot.svyplan_n(). The default sweeps from the cheapest design that meets the hard targets up to twice the fitted budget.
Details
plot.svyplan_strata() draws a bar chart of per-stratum sampling
fractions (f = n / N) using barplot(). This shows how
intensively each stratum is sampled, under Neyman allocation,
high-variance strata get higher fractions. A dashed horizontal line
marks the overall sampling fraction (n / N). Defaults:
col = "grey40", ylab = "Sampling fraction (f)", las = 2.
plot.svyplan_power() draws the power-vs-sample-size curve using
plot(). The solved point is shown as a filled dot, with dashed
reference lines at the computed power and sample size, and a dotted
line at the significance level. Defaults: ylim = c(0, 1),
type = "l", xlab = "Sample size (per group)", ylab = "Power".
plot.svyplan_n() draws the budget frontier for a fixed-budget joint
allocation (n_alloc() with objective and budget): what precision
each budget buys on the objective indicator, over the range where the
hard targets remain fundable. The fitted design is a filled dot. The
curve is the same one predict() returns as a table, so read exact
numbers there. Its shape is the point: the objective falls as
1 / cost, so the marginal return on budget flattens, and the plot
shows where. Other svyplan_n results have no frontier to draw and
produce an error naming what is plottable.
See also
predict.svyplan for the sensitivity grids these curves are
drawn from, and strata_bound(), power_prop(), n_alloc() for the
results that are plottable.
Examples
# Sampling fraction per stratum
set.seed(1907)
sb <- strata_bound(rlnorm(2000, 6, 1), n_strata = 4, n = 200,
method = "cumrootf")
plot(sb)
# Custom color
plot(sb, col = "steelblue")
# Power curve with defaults
pw <- power_prop(p1 = 0.30, p2 = 0.40, power = 0.80)
plot(pw)
# Custom line width and color
plot(pw, lwd = 2, col = "darkred")
# Budget frontier: what each budget buys on the objective indicator
frame <- data.frame(
stratum = c("A", "B", "C"),
N = c(4000, 3000, 3000),
unit_cost = c(1, 1.2, 1.5)
)
measures <- data.frame(
stratum = rep(frame$stratum, 2),
name = rep(c("vaccination", "income"), each = 3),
p = c(0.5, 0.4, 0.6, rep(NA, 3)),
mean = c(rep(NA, 3), 50, 55, 60),
sd = c(rep(NA, 3), 10, 12, 15)
)
targets <- data.frame(name = "vaccination", cv = 0.05)
fit <- n_alloc(frame, measures = measures, targets = targets,
objective = "income", budget = 4000)
plot(fit)