HTstrata {sampling}R Documentation

The Horvitz-Thompson estimator for a stratified design

Description

Computes the Horvitz-Thompson estimator of the population total for a stratified design.

Usage

HTstrata(y,pik,strata)

Arguments

y vector of the variable of interest; its length is equal to n, the sample size.
pik vector of the first-order inclusion probabilities for the sampled units; its length is equal to n, the sample size.
strata vector of size n, with elements indicating the unit stratum.

See Also

HTestimator

Examples

# Swiss municipalities data base
data(swissmunicipalities)
# the variable 'REG' has 7 categories in the population; it is used as stratification variable
# computes the population stratum sizes
table(swissmunicipalities$REG)
# do not run
#  1   2   3   4   5   6   7
# 589 913 321 171 471 186 245
# the sample stratum sizes are given by size=c(30,20,45,15,20,11,44)
# the method is simple random sampling without replacement (equal probability, without replacement)
st=strata(swissmunicipalities,stratanames=c("REG"),size=c(30,20,45,15,20,11,44), method="srswor")
# extracts the observed data
# the order of the columns is different from the order in the swsissmunicipalities database
x=getdata(swissmunicipalities, st)
# computes the HT estimator of the variable Pop020 
HTstrata(x$Pop020,x$Prob,x$Stratum)

[Package sampling version 0.9 Index]