Skip to contents

Print svyplan objects

Usage

# S3 method for class 'svyplan_n'
print(x, ...)

# S3 method for class 'svyplan_cluster'
print(x, ...)

# S3 method for class 'svyplan_prec'
print(x, ...)

# S3 method for class 'svyplan_varcomp'
print(x, ...)

# S3 method for class 'svyplan_power'
print(x, ...)

# S3 method for class 'svyplan_n'
format(x, ...)

# S3 method for class 'svyplan_cluster'
format(x, ...)

# S3 method for class 'svyplan_prec'
format(x, ...)

# S3 method for class 'svyplan_varcomp'
format(x, ...)

# S3 method for class 'svyplan_power'
format(x, ...)

# S3 method for class 'svyplan_n'
confint(object, parm, level = 0.95, ...)

# S3 method for class 'svyplan_prec'
confint(object, parm, level = 0.95, ...)

# S3 method for class 'svyplan_n'
as.integer(x, ...)

# S3 method for class 'svyplan_n'
as.double(x, ...)

# S3 method for class 'svyplan_cluster'
as.integer(x, ...)

# S3 method for class 'svyplan_cluster'
as.double(x, ...)

# S3 method for class 'svyplan_n'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  stringsAsFactors = FALSE,
  validRN = TRUE,
  ...
)

# S3 method for class 'svyplan_prec'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  stringsAsFactors = FALSE,
  validRN = TRUE,
  ...
)

# S3 method for class 'svyplan_varcomp'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  stringsAsFactors = FALSE,
  validRN = TRUE,
  ...
)

# S3 method for class 'svyplan_cluster'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  stringsAsFactors = FALSE,
  validRN = TRUE,
  ...
)

# S3 method for class 'svyplan_power'
as.integer(x, ...)

# S3 method for class 'svyplan_power'
as.double(x, ...)

# S3 method for class 'svyplan_power'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  stringsAsFactors = FALSE,
  validRN = TRUE,
  ...
)

# S3 method for class 'svyplan_strata'
print(x, ...)

# S3 method for class 'svyplan_strata'
format(x, ...)

# S3 method for class 'svyplan_strata'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  stringsAsFactors = FALSE,
  validRN = TRUE,
  ...
)

# S3 method for class 'svyplan_strata'
as.integer(x, ...)

# S3 method for class 'svyplan_strata'
as.double(x, ...)

Arguments

x

A svyplan object.

...

Additional arguments are not supported and produce an error.

object

A svyplan object (for confint methods).

parm

Ignored (included for S3 consistency with confint()).

level

Confidence level (default 0.95).

row.names, optional

Standard as.data.frame() arguments.

stringsAsFactors

Logical. Retained for compatibility when a result is converted through data.frame().

validRN

Logical. Accepted for compatibility with data.frame() in R 4.7.0 and later. Svyplan results already have valid row names.

Value

x (or object), invisibly. confint returns a 2-column matrix with the lower and upper confidence limits.

Details

confint

confint() computes a confidence interval for the estimated parameter (proportion or mean). For proportions, the interval type matches the method used to compute the sample size ("wald", "wilson", or "logodds"). For means, a symmetric z-interval is used (requires mu in the original call).

Constrained designs (n_cluster(), n_alloc(), multistage n_multi()) carry two representations: the continuous mathematical optimum in the top-level fields (n, cv, cost, ...) and the whole-unit field design in $operational, whose cost and precision are recomputed from the integer design. print() leads with the field design and shows the continuous optimum as a diagnostic.

as.integer(x) returns the operational design in the same shape as x$n: the named integer stage vector for svyplan_cluster objects, the operational total for allocation results, and the ceiled scalar otherwise. as.double(x) returns the continuous counterpart of the same shape. For svyplan_strata, both coercions return the total sample size. Boundary cutpoints remain available in $boundaries.

as.data.frame() returns the tabular form of a result, intended as the stable handoff to downstream packages (e.g. samplyr). For svyplan_n: the stratum allocation table ($detail) for n_alloc() results, the per-domain table ($domains, falling back to $detail) for n_multi() results, and a one-row summary (n, n_int, se, moe, cv) otherwise. For svyplan_cluster: the per-domain table when domains are present, otherwise a stage table with columns stage, n, and n_int, where n is the continuous optimum and n_int is the constraint-preserving operational design. For svyplan_prec, detail-bearing multi-indicator and allocation results return $detail. Single-indicator results return their sample size and precision measures in one row. For svyplan_varcomp, stratified results return $strata, while unstratified results return one row containing the two- or three-stage components. For svyplan_power, one row contains the two group sizes, their integer counterparts, power, effect, type, and the quantity that was solved for.

Examples

# confint on a proportion sample size
res <- n_prop(p = 0.3, moe = 0.05)
confint(res)
#>  2.5 % 97.5 %
#>   0.25   0.35

# confint at 90% level
confint(res, level = 0.90)
#>      5.0 %    95.0 %
#>  0.2580387 0.3419613

# confint on a mean (requires mu)
res_mean <- n_mean(var = 100, mu = 50, moe = 2)
confint(res_mean)
#>  2.5 % 97.5 %
#>     48     52

# confint on a precision result
prec <- prec_prop(p = 0.3, n = 400)
confint(prec)
#>      2.5 %    97.5 %
#>  0.2550916 0.3449084