joint_calib_create_matrix {jointCalib} | R Documentation |
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
where \(x_{ij}\) is the \(i\)th row of the auxiliary variable \(X_j\), \(N\) is the population size, \(Q_{x_j, \alpha}\) is the known population \(\alpha\)th quantile, and \(l\) is set to -1000 (by default).
In case of linear
interpolation elements of \(A\) are created as follows
\(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) = \max \left\lbrace\left\lbrace{x_{i j}}, i \in s \mid x_{i j} \leqslant t\right\rbrace \cup \lbrace-\infty\rbrace \right\rbrace,\] \[U_{x_{j}, r}(t) = \min \left\lbrace\left\lbrace{x_{i j}}, i \in s \mid x_{i j}>t\right\rbrace \cup \lbrace\infty\rbrace \right\rbrace,\] \[\beta_{x_{j}, r}(t) = \frac{t-L_{x_{j}, s}(t)}{U_{x_{j}, s}(t)-L_{x_{j}, s}(t)},\]\(i=1,...,r\), \(j=1,...,k\), \(t \in \mathbb{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 |
control |
a control parameter for creation of |
Value
Return matrix A
Author(s)
Maciej Beręsewicz
References
Harms, T. and Duchesne, P. (2006). On calibration estimation for quantiles. Survey Methodology, 32(1), 37.
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)
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)