weights: Retrieve Sampling Units Weights

weightsR Documentation

Retrieve Sampling Units Weights

Description

Extracts the current weights of units belonging to a survey design object.

Usage

weights(object, ...)

Arguments

object

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

...

Arguments for future expansion.

Details

The current weights of object are, by definition, those weights that would be used for estimation purposes on that object (e.g. by functions svystatTM, svystatR, svystatS, svystatSR, svystatQ, svystatB, svystatL, ...). The nature of such weights depends on the class of object: calibrated weights for class cal.analytic and direct weights otherwise.

Value

A vector of weights, whose components are positionally tied to the sampling units belonging to object.

Note

If object has undergone multiple, subsequent calibration steps, the function will return the output weights generated by the last calibration step.

Author(s)

Diego Zardetto

See Also

Function g.range to asses the range of the g-weights of a calibrated design object.

Examples

# Creation of the object to be calibrated:
data(data.examples)
exdes<-e.svydesign(data=example,ids=~towcod+famcod,strata=~SUPERSTRATUM,
     weights=~weight)

# Retrieve the weights and summarize their distribution:
summary(weights(exdes))

# Now calibrate (global solution) on the joint distribution of sex
# and marstat (totals in pop03):
excal.1st<-e.calibrate(design=exdes,df.population=pop03,
           calmodel=~marstat:sex-1,calfun="linear",bounds=bounds)

# Retrieve the current weights (i.e. the calibrated ones) and
# summarize their distribution:
summary(weights(excal.1st))

# Now calibrate once again, this time on the marginal distribution
# of age in 5 classes (age5c) inside provinces (procod) (totals in pop06p)
# with the partitioned solution, the logit distance and bounds=c(0.5, 1.5):
excal.2nd<-e.calibrate(design=excal.1st,df.population=pop06p,
           calmodel=~age5c-1,partition=~procod,calfun="logit",
           bounds=c(0.5, 1.5))

# Notice that the print method correctly takes the calibration chain
# into account:
excal.2nd

# Now retrieve the current weights (i.e. the ones generated by the second
# calibration step) and summarize their distribution:
summary(weights(excal.2nd))

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