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()orjoint_expected_hits().- weighted
If
FALSE(default), returns the raw covariance matrix. IfTRUE, 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 tojoint_inclusion_prob()orjoint_expected_hits(). DefaultFALSE.
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.
Accuracy depends on the underlying joint probabilities. For cps,
systematic, poisson, srs, and bernoulli, joint probabilities
are exact and so is the covariance. For brewer, sps, pareto,
and cube, they use the high-entropy approximation. For chromy,
they are simulation-based (see nsim). See joint_inclusion_prob()
and joint_expected_hits().
Some designs (notably systematic PPS) produce \(\pi_{ij} = 0\) for
pairs that never co-occur. When weighted = TRUE, the SYG quantity
\(1 - \pi_i \pi_j / \pi_{ij}\) is undefined for such pairs and
set to NA with a warning. The raw covariance (weighted = FALSE)
is unaffected. The Sen-Yates-Grundy estimator is not applicable
for these designs (Tille, 2006, Ch. 5).
References
Chromy, J.R. (2009). Some generalizations of the Horvitz-Thompson estimator. Proceedings of the Survey Research Methods Section, American Statistical Association.
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