Computes the matrix of pairwise expectations \(E(n_i n_j)\) for a with-replacement sampling design, where \(n_k\) is the number of times unit \(k\) is selected.
Usage
joint_expected_hits(x, ...)
# S3 method for class 'wr'
joint_expected_hits(x, sampled_only = FALSE, nsim = 10000L, ...)
# S3 method for class 'wor'
joint_expected_hits(x, ...)
# Default S3 method
joint_expected_hits(x, ...)Arguments
- x
A with-replacement design object (class
"wr").- ...
Additional arguments passed to methods (e.g.,
nsimfor simulation-based methods).- sampled_only
If
TRUE, return only the submatrix for units selected at least once (requiresnrep = 1). Useful when N is large but the number of distinct selected units is manageable. DefaultFALSE.- nsim
Number of simulations for Chromy's pairwise expectations (default 10000).
Value
A symmetric N x N matrix (or n_s x n_s if
sampled_only = TRUE, where n_s is the number of distinct
selected units). Diagonal entries are \(E(n_i^2)\) and
off-diagonal entries are \(E(n_i n_j)\).
Details
The computation depends on the method:
- Exact
multinomial(\(E(n_i n_j) = n(n-1) p_i p_j\)) andsrs(\(E(n_i n_j) = n(n-1)/N^2\)).- Simulation
chromy: estimated by Monte Carlo (controlled bynsim, default 10 000).
When sampled_only = TRUE, only the submatrix for units with
hits > 0 is returned. All methods compute it directly without
allocating the full N x N matrix.
See also
joint_inclusion_prob() for the without-replacement analogue,
sampling_cov() for the covariance matrix.
Examples
x <- c(40, 80, 50, 60, 70)
hits <- expected_hits(x, n = 3)
s <- unequal_prob_wr(hits, method = "chromy")
joint_expected_hits(s)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.3934 0.2617 0.1633 0.2023 0.1595
#> [2,] 0.2617 0.8069 0.3425 0.4526 0.5570
#> [3,] 0.1633 0.3425 0.4987 0.1592 0.3324
#> [4,] 0.2023 0.4526 0.1592 0.5918 0.3695
#> [5,] 0.1595 0.5570 0.3324 0.3695 0.7092
# Only the submatrix for selected units
joint_expected_hits(s, sampled_only = TRUE)
#> [,1] [,2] [,3]
#> [1,] 0.3963 0.1636 0.2111
#> [2,] 0.1636 0.4929 0.1659
#> [3,] 0.2111 0.1659 0.6058