| Wk {TeachingSampling} | R Documentation |
Computes the calibration weights for the estimation of the population total of several variables of interest
Wk(x,tx,Pik,ck)
x |
Vector, matrix or data frame containig the recollected auxiliary information for every unit in the selected sample |
tx |
Vector containing the populations totals of the auxiliary information |
Pik |
A vetor containing inclusion probabilities for each unit in the sample |
ck |
A vector of weights induced by the structure of variance of the supposed model |
The calibration weights satisfy the following expression
sum_{kin S}w_kx_k=sum_{kin U}x_k
The function returns a matrix of calibrated weights.
Hugo Andrés Gutiérrez Rojas hugogutierrez@usantotomas.edu.co
Sarndal, C-E. and Swensson, B. and Wretman, J. (1992), Model Assisted Survey Sampling. Springer.
Guti'errez, H. A. (2009), Estrategias de muestreo: Dise~no de encuestas y estimaci'on de par'ametros.
Editorial Universidad Santo Tom'as
############
## Example 1
############
# Draws a simple random sample without replacement
data(Marco)
data(Lucy)
dim(Marco)
N <- dim(Marco)[1]
n <- 400
sam <- sample(N,n)
# The information about the units in the sample is stored in an object called data
data <- Lucy[sam,]
attach(data)
names(data)
# Vector of inclusion probabilities
Pik<-rep(n/N,n)
##############################
x <- rep(1,n)
ck <- rep(1,n)
tx <- c(N)
wk <- Wk(x,tx,Pik,ck)
sum(wk*x)
##############################
x <- Employees
tx <- c(151950)
ck <- x
wk <- Wk(x,tx,Pik,ck)
sum(wk*x)
##############################
x <- Taxes
tx <- c(28654)
ck <- rep(1,n)
wk <- Wk(x,tx,Pik,ck)
sum(wk*x)
##############################
x <- data.frame(Employees, Taxes)
tx <- c(151950, 28654)
ck <- matrix(1, n, 2)
wk <- Wk(x,tx,Pik,ck)
sum(wk[,1]*x[,1])
sum(wk[,1]*x[,2])
sum(wk[,2]*x[,2])
sum(wk[,2]*x[,1])
##############################
x <- data.frame(Employees, Taxes)
tx <- c(151950, 28654)
ck <- x
wk <- Wk(x,tx,Pik,ck)
sum(wk[,1]*x[,1])
sum(wk[,1]*x[,2])
sum(wk[,2]*x[,2])
sum(wk[,2]*x[,1])
##############################
x <- cbind(1,Taxes)
tx <- c(N,28654)
ck <- x
wk <- Wk(x,tx,Pik,ck)
sum(wk[,1]*x[,1])
sum(wk[,1]*x[,2])
sum(wk[,2]*x[,2])
sum(wk[,2]*x[,1])