0% found this document useful (0 votes)
14 views13 pages

R Sampling Package Overview

This document describes the R sampling package, which was written by Alina Matei and Yves Tillé to apply sampling theory directly in R. The package contains functions for simple random sampling, stratified sampling, unequal probability sampling, and balanced sampling. It also includes several data sets of municipalities that can be used in examples and exercises. The document provides several exercises demonstrating how to use functions in the package to select samples according to different designs and estimate population quantities.

Uploaded by

Ivan Cordova
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views13 pages

R Sampling Package Overview

This document describes the R sampling package, which was written by Alina Matei and Yves Tillé to apply sampling theory directly in R. The package contains functions for simple random sampling, stratified sampling, unequal probability sampling, and balanced sampling. It also includes several data sets of municipalities that can be used in examples and exercises. The document provides several exercises demonstrating how to use functions in the package to select samples according to different designs and estimate population quantities.

Uploaded by

Ivan Cordova
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

The R `sampling' package

Alina Matei and Yves Tillé


University of Neuchâtel

Euskal Estatistika Erakundea


XXIII Seminario Internacional de Estadística
November 2010

Alina Matei and Yves Tillé () The R `sampling' package November 2010 1 / 13
Introduction and aim The R language

The R language

Shareware available on [Link]


The Comprehensive R Archive Network
Installation: 10 minutes
All the manuels are available in pdf
Everyone can write an additional package (600 packages are available)
Packages are loaded directly from R.
The manual of the package is available online and in pdf.
Package `sampling' written by Matei and Tillé.

Alina Matei and Yves Tillé () The R `sampling' package November 2010 2 / 13
Introduction and aim History of the package

Continuous distributions

EFTA course for public statisticians (April 2005).


Objective : to apply directly the theory with the R language.
Theory + Exercices with a laptop and R.
Writing of a large set of procedures.
Finally, decision of submitting the package to the CRAN.

Alina Matei and Yves Tillé () The R `sampling' package November 2010 3 / 13
Content of the package Topics

Content of the package

Stratication, two-stage, unequal probabilities, balanced sampling


Estimation: calibration and regression estimator
Tools : computation of inclusion probabilities, crossing strata
Data bases, Swiss municipalities, Belgian municipalities.

Alina Matei and Yves Tillé () The R `sampling' package November 2010 4 / 13
Content of the package Tools

Tools

writesample: return the list of all the samples of xed sample size
cleanstrata: renumbering of the strata
disjonctive return a matrix wit 0 and 1 that is the disjonctive
representation of the stratum.
inclusionprobabilities: compute unequal inclusion probabilities
from an auxiliary variable variable.

Alina Matei and Yves Tillé () The R `sampling' package November 2010 5 / 13
Content of the package Data bases

Data bases

MU284 A data frame with 284 municipalities on the following 11


variables : populations, political results.
swissmunicipalities: 2896 Swiss municipalities. Surfaces and
population.
belgianmunicipalities: 589 Belgian municipalities 11 variables,
population and taxes.

Alina Matei and Yves Tillé () The R `sampling' package November 2010 6 / 13
Content of the package Simple random sampling

Simple random sampling

srswor: Simple random sampling with replacement.


srswor1: Simple random sampling without replacement (sequential
method).
srswr: Simple random sampling with replacement.

Alina Matei and Yves Tillé () The R `sampling' package November 2010 7 / 13
Content of the package Unequal probability sampling

Unequal probability sampling

UPbrewer,
UPmaxentropy, (set of function)
UPmidzuno, UPmidzunopi2,
UPmultinomial,
UPpivotal, UPrandompivotal,
UPpoisson,
UPsampford,
UPsystematic, UPrandomsystematic, UPsystematicpi2,
UPtille, UPtillepi2,

Alina Matei and Yves Tillé () The R `sampling' package November 2010 8 / 13
Content of the package Balanced sampling

Balanced sampling

Design that satises the balancing equations


X xk X
= xk ,
πk
k ∈S k ∈U

where xk is a vector of auxiliary variables.


Cube algorithm: ight phase and landing phase.
samplecube, fastflightcube, landingcube
Complex survey balancedstratification balancedcluster
balancedtwostage

Alina Matei and Yves Tillé () The R `sampling' package November 2010 9 / 13
Content of the package Balanced sampling

Exercises

Exercise
Compute inclusion probabilities 200 Belgian municipalities with inclusion
probabilities proportional to the population in 2004.

Alina Matei and Yves Tillé () The R `sampling' package November 2010 10 / 13
Content of the package Balanced sampling

Exercises

Exercise
Use the Belgian database. Select a sample of 200 municipalities with
unequal probabilities proportional to the number of inhabitants in 2004.
with Poisson sampling
with a method of unequal probabilities and xed sample size
with simple random sampling.
Compute the Horvitz-Thompson estimators of the taxable income for 50
samples and draw a boxplot of the estimators for each method.

Alina Matei and Yves Tillé () The R `sampling' package November 2010 11 / 13
Content of the package Balanced sampling

Exercises

Exercise
Use the database of Swiss municipalities, and select a stratied balanced
sample. A balanced sample is rst selected in each strata. Next the results
of the ight phase are merged and a ight phase is applied again on the
whole population. Finally, a landing phase is applied on all the population.
Use the following balancing variables: HApoly, Surfacesbois, P00BMTOT,
P00BWTOT, POPTOT, Pop020, Pop2040, Pop4065, Pop65P, H00PTOT.
The sample size is 400 and the municipalities must be selected with
inclusion probabilities proportional to POPTOT. The stratication variable
is REG (swiss regions). Next, print the names of the selected municipalities.

Alina Matei and Yves Tillé () The R `sampling' package November 2010 12 / 13
Content of the package Balanced sampling

Exercises

Exercise
Use the Belgian database. Select a sample of 200 municipalities with
unequal probabilities proportional to the number of inhabitants in 2004
with Poisson sampling design. Next calibrate the sample by means of the
raking ratio estimator on the variables:
mean(Men03), mean(Women03), Dimen, Diwom, TaxableIncome,
Totaltaxation, averageincome, medianincome.
The division by the means is necessary to avoid too large numbers.
Compute the Horvitz-Thompson estimators and the calibrated estimators
for the calibration variables. Limit the variation of the g-weights between
0.5 and 1.5.

Alina Matei and Yves Tillé () The R `sampling' package November 2010 13 / 13

You might also like