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

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.

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))
#> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 95.5 218.8 321.3 308.0 362.3 931.2
# 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))
#> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 94.44 218.49 317.75 306.10 361.09 932.01
# 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
#> Calibrated, Stratified 2 - Stage Cluster Sampling Design (with replacement) #> - [55] strata #> - [1307, 2372] clusters #> #> Call: #> 2: e.calibrate(design = excal.1st, df.population = pop06p, calmodel = ~age5c - #> 1, partition = ~procod, calfun = "logit", bounds = c(0.5, #> 1.5)) #> 1: e.calibrate(design = exdes, df.population = pop03, calmodel = ~marstat:sex - #> 1, calfun = "linear", bounds = bounds)
# Now retrieve the current weights (i.e. the ones generated by the second # calibration step) and summarize their distribution: summary(weights(excal.2nd))
#> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 95.98 231.59 294.78 312.56 370.24 880.11