varSYG: Sen-Yates-Grundy variance estimator

varSYGR Documentation

Sen-Yates-Grundy variance estimator


varSYG computes the Sen-Yates-Grundy variance estimator.


varSYG(y = NULL, pikl, precalc = NULL)



A (sparse) numerical matrix of the variable(s) whose variance of their total is to be estimated.


A numerical matrix of second-order inclusion probabilities.


A list of pre-calculated results (analogous to the one used by varDT).


varSYG aims at being an efficient implementation of the Sen-Yates-Grundy variance estimator for sampling designs with fixed sample size. It should be especially useful when several variance estimations are to be conducted, as it relies on (sparse) matrix linear algebra.

Moreover, in order to be consistent with varDT, varSYG has a precalc argument allowing for the re-use of intermediary results calculated once and for all in a pre-calculation step (see varDT for details).


  • if y is not NULL (calculation step) : a numerical vector of size the number of columns of y.

  • if y is NULL (pre-calculation step) : a list containing pre-calculated data (analogous to the one used by varDT).

Difference with varHT from package sampling

varSYG differs from sampling::varHT in several ways:

  • The formula implemented in varSYG is solely the Sen-Yates-Grundy estimator, which is the one calculated by varHT when method = 2.

  • varSYG introduces several optimizations:

    • matrixwise operations allow to estimate variance on several interest variables at once

    • Matrix::TsparseMatrix capability yields significant performance gains.


Martin Chevalier



# Simple random sampling case
N <- 1000
n <- 100
y <- rnorm(N)[as.logical(srswor(n, N))]
pikl <- matrix(rep((n*(n-1))/(N*(N-1)), n*n), nrow = n)
diag(pikl) <- rep(n/N, n)
varSYG(y, pikl)
sampling::varHT(y = y, pikl = pikl, method = 2)

gustave documentation built on Sept. 19, 2022, 9:06 a.m.