cal.estimates: Quick Estimates of Auxiliary Variables Totals

aux.estimatesR Documentation

Quick Estimates of Auxiliary Variables Totals

Description

Quickly estimates the totals of the auxiliary variables of a calibration model.

Usage

aux.estimates(design,
              calmodel = if (inherits(template, "pop.totals"))
                         attr(template, "calmodel"), 
              partition = if (inherits(template, "pop.totals")) 
                          attr(template, "partition") else FALSE,
              template = NULL)

Arguments

design

Object of class analytic (or inheriting from it) containing survey data and sampling design metadata.

calmodel

Formula defining the linear structure of the calibration model.

partition

Formula specifying the variables that define the "calibration domains" for the model (see ‘Details’); FALSE (the default) implies no calibration domains.

template

An object of class pop.totals, be it a template or the actual known totals data frame for the calibration task.

Details

The main purpose of function aux.estimates is to make easy the task of estimating the totals of all the auxiliary variables involved in a calibration model (separately inside distinct calibration domains, if specified). Even if such totals can be estimated also by repeatedly invoking function svystatTM, this may reveal very tricky in practice, because real-world calibration tasks (e.g. in the field of Official Statistics) can simultaneously involve hundreds of auxiliary variables. Moreover, total estimates provided by function svystatTM are always complemented by sampling errors, whose estimation is very computationally demanding.

Function aux.estimates, on the contrary, only provides estimates of totals (i.e. without associated sampling errors), thus being very quick to be executed. Moreover, aux.estimates is able to compute, in just a single shot, all the totals of the auxiliary variables of a calibration model, no matter how complex the model is. Lastly, as a third strong point, the totals estimated by aux.estimates will be returned exactly in the same standard format in which the known population totals for the related calibration task need to be represented (see pop.template, population.check, fill.template).

It may be useful to point out that, besides having been designed to handle auxiliary variables involved in calibration models, function aux.estimates could be also used for computing general estimates of totals inside subpopulations in a very effective way (see ‘Examples’).

Value

An object of class pop.totals, thus inheriting from class data.frame storing the estimated totals in a standard format.

Author(s)

Diego Zardetto

See Also

e.svydesign to bind survey data and sampling design metadata, svystatTM for calculating estimates and standard errors of totals, e.calibrate for calibrating weights, pop.template for constructing known totals data frames in compliance with the standard required by e.calibrate, population.check to check that the known totals data frame satisfies that standard, fill.template to automatically fill the template when a sampling frame is available.

Examples

# Load sbs data:
data(sbs)

# Build a design object:
sbsdes<-e.svydesign(data=sbs,ids=~id,strata=~strata,weights=~weight,fpc=~fpc)

# Now suppose you have to perform a calibration process which
# exploits as auxiliary information:
#  i) the total number of employees (emp.num)
#     by class of number of employees (emp.cl) crossed with nace.macro; 
# ii) the total number of enterprises (ent)
#     by region crossed with nace.macro;

# Build a template for the known totals:
pop<-pop.template(sbsdes,
     calmodel=~emp.num:emp.cl + region -1,
     partition=~nace.macro)

# Use the fill.template function to automatically compute
# the totals from the universe (sbs.frame) and safely fill
# the template:
pop<-fill.template(sbs.frame,template=pop)
pop

# You can now use aux.estimates to verify how much difference
# exists between the target totals and the initial HT estimates:
aux.HT<-aux.estimates(sbsdes,template=pop)
aux.HT 

# If you calibrate, ...
sbscal<-e.calibrate(sbsdes,pop)

# ... you can verify that CAL estimates exactly match the known totals:
aux.CAL<-aux.estimates(sbscal,template=pop)
aux.CAL

# Recall that you can also use aux.estimates for computing
# general estimates of totals inside subpopulations (even
# not related to any calibration task).
# E.g. estimate the total of value added inside areas:
aux.estimates(sbsdes,~va.imp2-1,~area)

# ...and compare to svystatTM (notice also
# the increased execution time):
svystatTM(sbsdes,~va.imp2,~area) 

DiegoZardetto/ReGenesees documentation built on Dec. 16, 2024, 2:03 p.m.