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). Unit labels are inherited from
the underlying joint matrix.
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,
sampford, systematic, poisson, srs, bernoulli, multinomial,
and systematic_mr, joint probabilities or pairwise expectations 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). lpm2 and scps
expose no joint probabilities, so sampling_cov() stops with an error
for them. See joint_inclusion_prob() and joint_expected_hits().
Some designs (notably systematic PPS) produce \(\pi_{ij} = 0\) for
pairs that never co-occur, and systematic_mr gives such pairs zero
pairwise expected hits. 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 (Tillé, 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.
Tillé, Y. (2006). Sampling Algorithms. Springer.
See also
joint_inclusion_prob() for the without-replacement joint
probabilities this is computed from, joint_expected_hits() for the
with-replacement analogue.
Examples
pik <- c(0.2, 0.4, 0.6, 0.8)
s <- unequal_prob_wor(pik, method = "cps")
# Raw covariance
sampling_cov(s)
#> [,1] [,2] [,3] [,4]
#> [1,] 0.16000000 -0.04887418 -0.06696685 -0.04415897
#> [2,] -0.04887418 0.24000000 -0.12415897 -0.06696685
#> [3,] -0.06696685 -0.12415897 0.24000000 -0.04887418
#> [4,] -0.04415897 -0.06696685 -0.04887418 0.16000000
# SYG check quantities
sampling_cov(s, weighted = TRUE)
#> [,1] [,2] [,3] [,4]
#> [1,] 0.8000000 -1.5702134 -1.2627357 -0.3812032
#> [2,] -1.5702134 0.6000000 -1.0718048 -0.2646564
#> [3,] -1.2627357 -1.0718048 0.4000000 -0.1133641
#> [4,] -0.3812032 -0.2646564 -0.1133641 0.2000000
# Covariance for sampled units only
sampling_cov(s, sampled_only = TRUE)
#> 3 4
#> 3 0.24000000 -0.04887418
#> 4 -0.04887418 0.16000000