Skip to contents

joint_calib_create_matrix is function that creates an A = [a_ij] matrix for calibration of quantiles. Function allows to create matrix using logistic interpolation (using stats::plogis, default) or linear (as in Harms and Duchesne (2006), i.e. slightly modified Heavyside function).

In case of logistic interpolation elements of A are created as follows

a_i j = 1(1 + (-2l(x_ij-Q_x_j, )))N,

where x_ij is the ith row of the auxiliary variable X_j, N is the population size, Q_x_j, is the known population th quantile, and l is set to -1000 (by default).

In case of linear interpolation elements of A are created as follows

a_i j= cases N^-1, & x_i j L_x_j, r (Q_x_j, ),
N^-1 _x_j, r(Q_x_j, ), & x_i j=U_x_j, r(Q_x_j, ),
0, & x_i j>U_x_j, r (Q_x_j, ), cases

i=1,...,r, j=1,...,k, where r is the set of respondents, k is the auxiliary variable index and

L_x_j, r(t) = x_i j, i s x_i j t - , U_x_j, r(t) = x_i j, i s x_i j>t , _x_j, r(t) = t-L_x_j, s(t)U_x_j, s(t)-L_x_j, s(t),

i=1,...,r, j=1,...,k, t R.

Usage

joint_calib_create_matrix(X_q, N, pop_quantiles, control = control_calib())

Arguments

X_q

matrix of variables for calibration of quantiles,

N

population size for calibration of quantiles,

pop_quantiles

a vector of population quantiles for X_q,

control

a control parameter for creation of X_q matrix.

Value

Return matrix A

References

Harms, T. and Duchesne, P. (2006). On calibration estimation for quantiles. Survey Methodology, 32(1), 37.

Author

Maciej Beręsewicz

Examples

# Create matrix for one variable and 3 quantiles
set.seed(123)
N <- 1000
x <- as.matrix(rnorm(N))
quants <- list(quantile(x, c(0.25,0.5,0.75)))
A <- joint_calib_create_matrix(x, N, quants)
head(A)
#>               [,1]         [,2]  [,3]
#> [1,]  3.417662e-33 1.000000e-03 0.001
#> [2,] 1.221974e-176 1.000000e-03 0.001
#> [3,]  0.000000e+00 0.000000e+00 0.000
#> [4,] 3.168423e-307 2.389406e-30 0.001
#> [5,]  0.000000e+00 7.091618e-56 0.001
#> [6,]  0.000000e+00 0.000000e+00 0.000
colSums(A)
#> [1] 0.2502323 0.4999654 0.7498815

# Create matrix with linear interpolation
A <- joint_calib_create_matrix(x, N, quants, control_calib(interpolation="linear"))
head(A)
#>      [,1]  [,2]  [,3]
#> [1,]    0 0.001 0.001
#> [2,]    0 0.001 0.001
#> [3,]    0 0.000 0.000
#> [4,]    0 0.000 0.001
#> [5,]    0 0.000 0.001
#> [6,]    0 0.000 0.000
colSums(A)
#> [1] 0.24975 0.49950 0.74925

# Create matrix for two variables and different number of quantiles

set.seed(123)
x1 <- rnorm(N)
x2 <- rchisq(N, 1)
x <- cbind(x1, x2)
quants <- list(quantile(x1, 0.5), quantile(x2, c(0.1, 0.75, 0.9)))
B <- joint_calib_create_matrix(x, N, quants)
head(B)
#>              [,1]          [,2]          [,3]  [,4]
#> [1,] 1.000000e-03  7.889542e-30  1.000000e-03 0.001
#> [2,] 1.000000e-03 1.614292e-242  1.000000e-03 0.001
#> [3,] 0.000000e+00  0.000000e+00  0.000000e+00 0.001
#> [4,] 2.389406e-30  0.000000e+00  0.000000e+00 0.000
#> [5,] 7.091618e-56  0.000000e+00 1.360616e-132 0.001
#> [6,] 0.000000e+00  0.000000e+00  1.000000e-03 0.001
colSums(B)
#> [1] 0.49996541 0.09961593 0.74980652 0.89987264