Skip to contents

Compute the effective sample size, adjusting for design effects. This is an S3 generic that mirrors design_effect().

Usage

effective_n(x = NULL, ...)

# S3 method for class 'numeric'
effective_n(
  x,
  ...,
  y = NULL,
  x_cal = NULL,
  prob = NULL,
  strata_id = NULL,
  cluster_id = NULL,
  stages = NULL,
  method = "kish"
)

# Default S3 method
effective_n(
  x = NULL,
  ...,
  delta = NULL,
  psu_size = NULL,
  n = NULL,
  method = "cluster"
)

Arguments

x

A numeric vector of survey weights (for diagnostic methods), or NULL (for the "cluster" planning method).

...

Additional arguments passed to methods.

y

Outcome variable (for "henry", "spencer", "cr").

x_cal

Calibration covariate (for "henry").

prob

1-draw selection probabilities (for "spencer").

strata_id

Stratum IDs (for "cr").

cluster_id

Cluster IDs (for "cr").

stages

Integer vector of stages per stratum (for "cr").

method

For numeric weights: one of "kish" (default), "henry", "spencer", or "cr". For planning (no weights): "cluster" (default and only option).

delta

ICC / homogeneity measure, scalar or svyplan_varcomp.

psu_size

Mean PSU size (scalar).

n

Total sample size (required for the cluster method).

Value

A numeric scalar.

Methods (by class)

  • effective_n(numeric): Method for numeric weights vector.

  • effective_n(default): Planning method (no weights needed).

See also

design_effect() for the underlying design effect computation.

Examples

# Effective sample size from weights (Kish)
set.seed(1)
w <- runif(100, 1, 5)
effective_n(w, method = "kish")
#> [1] 89.26748

# Planning: effective n given cluster design
effective_n(delta = 0.05, psu_size = 25, n = 800, method = "cluster")
#> [1] 363.6364