uweights {hbsae} | R Documentation |
Compute unit weights underlying the small area estimates or their aggregate.
Description
The small area estimates can be interpreted as weighted sums of the response variable. This function computes the weights corresponding to the aggregated small area estimates or the weights corresponding to a specific small area estimate. The weights applied to the response variable need not exactly reproduce the Hierarchical Bayes estimate since the latter is averaged over the posterior distribution for the variance ratio whereas the weights are evaluated at the posterior mean. Under the default prior for the fixed effects, the weights applied to the design matrix reproduce the corresponding population numbers.
Usage
uweights(x, areaID = NULL, forTotal = FALSE)
Arguments
x |
sae object. |
areaID |
if left unspecified ( |
forTotal |
if |
Value
An object of class weights
.
See Also
Examples
d <- generateFakeData()
# compute small area estimates
sae <- fSAE(y0 ~ x + area2, data=d$sam, area="area", popdata=d$Xpop,
method="hybrid", keep.data=TRUE)
# compute unit weights
w <- uweights(sae, forTotal=TRUE)
summary(w) # summary statistics
plot(w) # histogram of weights
# checks
all.equal(sum(w * sae$y), sum(EST(sae) * sae$Narea))
all.equal(colSums(w * as.matrix(sae$X)), colSums(sae$Xp * sae$Narea))