Learn R Programming

Icarus

Icarus (Icarus Calibrates And Reweights Units in Samples) is an R package providing useful functions for calibration and reweighting estimators in survey sampling. The former name of this package was gaston.

Cite

To cite Icarus in publications use: Rebecq, Antoine (2017). Icarus: an R package for calibration in survey sampling. R package version 0.3.0.

Install

You can use the following instruction to install icarus (from CRAN):

install.packages("icarus")

However, if you wish to install the latest version of icarus, you can use devtools and install directly from this github repo:

install.packages("devtools")
library(devtools)
install_github("haroine/icarus")

Short example

In this example, we perform calibration (with the "raking" method) on the test dataset data_employees included in icarus:

library(icarus)

N <- 300 ## Population size
## Compute the Horvitz-Thompson estimator (returns 1.666667)
weightedMean(data_employees$movies, data_employees$weight, N)

## Add calibration margins
mar1 <- c("category",3,80,90,60)
mar2 <- c("sex",2,140,90,0)
mar3 <- c("department",2,100,130,0)
mar4 <- c("salary", 0, 470000,0,0)
margins <- rbind(mar1, mar2, mar3, mar4)
## Compute calibration weights
wCal <- calibration(data=data_employees, marginMatrix=margins, colWeights="weight"
                           , method="raking", description=FALSE)
                           
## Value of the calibrated estimator: 2.471917
weightedMean(data_employees$movies, wCal, N)

Copy Link

Version

Install

install.packages('icarus')

Monthly Downloads

918

Version

0.3.2

License

GPL-3

Maintainer

Antoine Rebecq

Last Published

May 27th, 2023

Functions in icarus (0.3.2)

table_margins_2

Margins for calibration of test population
regroupCalibrationModalities

Regroup calibration modalities
poptest_calmar_nr

Calibration with nonresponse on population test - made on Calmar2
weightedTotal

Weighted estimator for total
weightedMean

Weighted estimator for the mean
regroupModalities

Regroup elements of a vector
table_margins_1

Margins for calibration of test population
newMarginMatrix

Create empty margin matrix
poptest_calmar

Calibration on population test - made on Calmar2
marginStats

Stats for initial weights, calibrated weights, and margins.
dataPop

Test population for Icarus.
calibrationMarginStats

Stats for initial weights, calibrated weights, and margins.
calibration

Calibration on margins
colToDummies

Changes a column containing multiple values to a matrix of columns containing the dummies corresponding to each value.
calWeights_movies

Calibration weights for data_employees
HTmean

Weighted estimator for the mean
data_employees

A small example sample for calibration with Icarus
addMargin

Adds a margin to marginMatrix
HTtotal

Weighted estimator for total