Skip to contents

Computes the sampling covariance matrix used in variance estimation.

Usage

sampling_cov(x, ...)

# S3 method for class 'wor'
sampling_cov(x, weighted = FALSE, sampled_only = FALSE, ...)

# S3 method for class 'wr'
sampling_cov(x, weighted = FALSE, sampled_only = FALSE, ...)

# Default S3 method
sampling_cov(x, ...)

Arguments

x

A sampling design object (class "sondage_sample").

...

Additional arguments passed to joint_inclusion_prob() or joint_expected_hits().

weighted

If FALSE (default), returns the raw covariance matrix. If TRUE, returns the weighted check quantities used in the Sen-Yates-Grundy variance estimator.

sampled_only

If TRUE, compute only the submatrix for sampled units. Passed to joint_inclusion_prob() or joint_expected_hits(). Default FALSE.

Value

A symmetric N x N matrix (or n x n if sampled_only = TRUE). For WOR designs with weighted = FALSE, off-diagonal entries are typically negative for well-behaved designs. With weighted = TRUE, off-diagonal entries are typically non-positive (entries where \(\pi_{ij} = 0\) are set to NA).

Details

For without-replacement designs: \(\Delta_{ij} = \pi_{ij} - \pi_i \pi_j\).

For with-replacement designs: \(E(n_i n_j) - E(n_i) E(n_j)\).

When weighted = TRUE, returns the Sen-Yates-Grundy check quantities: \(1 - \pi_i \pi_j / \pi_{ij}\) for WOR, \(1 - E(n_i) E(n_j) / E(n_i n_j)\) for WR.

Exact vs. approximate joint probabilities. The accuracy of the covariance matrix depends on the accuracy of the underlying joint probabilities. For cps, systematic, poisson, srs, and bernoulli, the joint probabilities are exact and so is the covariance matrix. For brewer, sps, and pareto, the joint probabilities are based on the high-entropy approximation, so the covariance matrix is also approximate. For chromy, the pairwise expectations are simulation-based (controlled by nsim). See joint_inclusion_prob() and joint_expected_hits() for details.

Zero joint inclusion probabilities. Some designs (notably systematic PPS) can produce \(\pi_{ij} = 0\) for pairs of units that never co-occur in the same sample. When weighted = TRUE, the quantity \(1 - \pi_i \pi_j / \pi_{ij}\) is undefined for such pairs. These entries are set to NA and a warning is issued. The raw covariance (weighted = FALSE) is unaffected, since \(\Delta_{ij} = 0 - \pi_i \pi_j\) is finite.

Implications for variance estimation. The Sen-Yates-Grundy variance estimator requires all pairwise \(\pi_{ij} > 0\) in the observed sample. It is not applicable for designs with zero joint probabilities (a well-known limitation; see Tille, 2006, Ch. 5). Consider alternative variance estimators for such designs, e.g. successive-differences or Hartley-Rao approximations.

References

Chromy, J.R. (2009). Some generalizations of the Horvitz-Thompson estimator. Memorial JSM.

Tille, Y. (2006). Sampling Algorithms. Springer.

Examples

pik <- c(0.2, 0.3, 0.5)
s <- unequal_prob_wor(pik, method = "cps")

# Raw covariance
sampling_cov(s)
#>       [,1]  [,2]  [,3]
#> [1,]  0.16 -0.06 -0.10
#> [2,] -0.06  0.21 -0.15
#> [3,] -0.10 -0.15  0.25

# SYG check quantities
sampling_cov(s, weighted = TRUE)
#> Warning: Some joint inclusion probabilities are zero while marginal probabilities are positive. The Sen-Yates-Grundy variance estimator is not applicable for this design (e.g. systematic sampling). Affected entries are set to NA. Consider using an approximation-based variance estimator instead.
#>      [,1] [,2] [,3]
#> [1,]  0.8   NA   NA
#> [2,]   NA  0.7   NA
#> [3,]   NA   NA  0.5

# Covariance for sampled units only
sampling_cov(s, sampled_only = TRUE)
#>      [,1]
#> [1,] 0.21