weights | R Documentation |
Extracts the current weights of units belonging to a survey design object.
weights(object, ...)
object |
Object of class |
... |
Arguments for future expansion. |
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.
A vector of weights, whose components are positionally tied to the sampling units belonging to object
.
If object
has undergone multiple, subsequent calibration steps, the function will return the output weights generated by the last calibration step.
Diego Zardetto
Function g.range
to asses the range of the g-weights of a calibrated design object.
# 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.