Learn R Programming

jointCalib (version 0.1.0)

joint_calib_create_matrix: An internal function to create an A matrix for calibration of quantiles

Description

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())

Value

Return matrix A

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.

Author

Maciej Beręsewicz

References

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

Examples

Run this code
# 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)
colSums(A)

# Create matrix with linear interpolation
A <- joint_calib_create_matrix(x, N, quants, control_calib(interpolation="linear"))
head(A)
colSums(A)

# 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)
colSums(B)

Run the code above in your browser using DataLab