HH {TeachingSampling} | R Documentation |
Computes the Hansen-Hurwitz Estimator estimator of the population total for several variables of interest
HH(y, pk)
y |
Vector, matrix or data frame containig the recollected information of the variables of interest for every unit in the selected sample |
pk |
A vetor containing selection probabilities for each unit in the selected sample |
The Hansen-Hurwitz estimator is given by
sum_{i=1}^mfrac{y_i}{p_i}
where y_i is the value of the variables of interest for the ith unit, and p_i is its corresponding selection probability. This estimator is restricted to with replacement sampling designs.
The function returns a data matrix whose columns correspond to the estimated parameters of the variables of interest
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 ############ # Vector U contains the label of a population of size N=5 U <- c("Yves", "Ken", "Erik", "Sharon", "Leslie") # Vectors y1 and y2 give the values of the variables of interest y1<-c(32, 34, 46, 89, 35) y2<-c(1,1,1,0,0) y3<-cbind(y1,y2) # The population size is N=5 N <- length(U) # The sample size is m=2 m <- 2 # pk is the probability of selection of every single unit pk <- c(0.9, 0.025, 0.025, 0.025, 0.025) # Selection of a random sample with replacement sam <- sample(5,2, replace=TRUE, prob=pk) # The selected sample is U[sam] # The values of the variables of interest for the units in the sample y1[sam] y2[sam] y3[sam,] # The Hansen-Hurwitz estimator HH(y1[sam],pk[sam]) HH(y2[sam],pk[sam]) HH(y3[sam,],pk[sam]) ############ ## Example 2 ############ # Uses the Marco and Lucy data to draw a simple random sample with replacement data(Marco) data(Lucy) N <- dim(Marco)[1] m <- 400 sam <- sample(N,m,replace=TRUE) # The vector of selection probabilities of units in the sample pk <- rep(1/N,m) # The information about the units in the sample is stored in an object called data data <- Lucy[sam,] attach(data) names(data) # The variables of interest are: Income, Employees and Taxes # This information is stored in a data frame called estima estima <- data.frame(Income, Employees, Taxes) HH(estima, pk)