nonresponse.Rd
Functions to simplify the construction of non-reponse weights by combining strata with small numbers or large weights.
nonresponse(sample.weights, sample.counts, population)
sparseCells(object, count=0,totalweight=Inf, nrweight=1.5)
neighbours(index,object)
joinCells(object,a,...)
# S3 method for nonresponse
weights(object,...)
table of sampling weight by stratifying variables
table of sample counts by stratifying variables
table of population size by stratifying variables
object of class "nonresponse"
Cells with fewer sampled units than this are "sparse"
Cells with higher non-response weight than this are "sparse"
Cells with average sampling weight times non-response weight higher than this are "sparse"
Number of a cell whose neighbours are to be found
Cells to join
When a stratified survey is conducted with imperfect response it is desirable to rescale the sampling weights to reflect the nonresponse. If some strata have small sample size, high non-response, or already had high sampling weights it may be desirable to get less variable non-response weights by averaging non-response across strata. Suitable strata to collapse may be similar on the stratifying variables and/or on the level of non-response.
nonresponse()
combines stratified tables of population size,
sample size, and sample weight into an object. sparseCells
identifies cells that may need combining. neighbours
describes the
cells adjacent to a specified cell, and joinCells
collapses
the specified cells. When the collapsing is complete, use
weights()
to extract the nonresponse weights.
nonresponse
and joinCells
return objects of class "nonresponse"
,
neighbours
and sparseCells
return objects of class "nonresponseSubset"
data(api)
## pretend the sampling was stratified on three variables
poptable<-xtabs(~sch.wide+comp.imp+stype,data=apipop)
sample.count<-xtabs(~sch.wide+comp.imp+stype,data=apiclus1)
sample.weight<-xtabs(pw~sch.wide+comp.imp+stype, data=apiclus1)
## create a nonresponse object
nr<-nonresponse(sample.weight,sample.count, poptable)
## sparse cells
sparseCells(nr)
#> sparseCells(nr)
#> Cells: 3 5 7 11
#> Indices:
#> sch.wide comp.imp stype
#> 3 "No" "Yes" "E"
#> 5 "No" "No" "H"
#> 7 "No" "Yes" "H"
#> 11 "No" "Yes" "M"
#> Summary:
#> NRwt wt n
#> 3 Inf Inf 0
#> 5 3.2 108 3
#> 7 Inf Inf 0
#> 11 Inf Inf 0
## Look at neighbours
neighbours(3,nr)
#> `[.nonresponse`(object, nbour.index)
#> Cells: 4 7 1
#> Indices:
#> sch.wide comp.imp stype
#> 4 "Yes" "Yes" "E"
#> 7 "No" "Yes" "H"
#> 1 "No" "No" "E"
#> Summary:
#> NRwt wt n
#> 4 0.92 31.1 112
#> 7 Inf Inf 0
#> 1 1.04 35.2 12
neighbours(11,nr)
#> `[.nonresponse`(object, nbour.index)
#> Cells: 12 9 7
#> Indices:
#> sch.wide comp.imp stype
#> 12 "Yes" "Yes" "M"
#> 9 "No" "No" "M"
#> 7 "No" "Yes" "H"
#> Summary:
#> NRwt wt n
#> 12 1.290 43.6 14
#> 9 0.916 31.0 8
#> 7 Inf Inf 0
## Collapse some contiguous cells
nr1<-joinCells(nr,3,5,7)
## sparse cells now
sparseCells(nr1)
#> sparseCells(nr1)
#> Cells: 3 11
#> Indices:
#> sch.wide comp.imp stype
#> 3 "No" "Yes" "E"
#> 11 "No" "Yes" "M"
#> Summary:
#> NRwt wt n
#> 3 3.78 128 3
#> 11 Inf Inf 0
nr2<-joinCells(nr1,3,11,8)
nr2
#> Call: nonresponse(sample.weight, sample.count, poptable)
#> 12 original cells, 8 distinct cells remaining
#> Joins:
#> 3 5 7
#> 3 5 7 8 11
#> counts NRweights totalwts
#> Min. : 3.00 Min. :0.6840 Min. :23.15
#> 1st Qu.: 7.00 1st Qu.:0.8956 1st Qu.:30.31
#> Median : 11.00 Median :0.9793 Median :33.15
#> Mean : 22.88 Mean :1.1461 Mean :38.79
#> 3rd Qu.: 15.50 3rd Qu.:1.3142 3rd Qu.:44.48
#> Max. :112.00 Max. :2.0977 Max. :71.00
## one relatively sparse cell
sparseCells(nr2)
#> sparseCells(nr2)
#> Cells: 3
#> Indices:
#> sch.wide comp.imp stype
#> 3 "No" "Yes" "E"
#> Summary:
#> NRwt wt n
#> 3 2.1 71 10
## but nothing suitable to join it to
neighbours(3,nr2)
#> `[.nonresponse`(object, nbour.index)
#> Cells: 4 1 6 9 12
#> Indices:
#> sch.wide comp.imp stype
#> 4 "Yes" "Yes" "E"
#> 1 "No" "No" "E"
#> 6 "Yes" "No" "H"
#> 9 "No" "No" "M"
#> 12 "Yes" "Yes" "M"
#> Summary:
#> NRwt wt n
#> 4 0.920 31.1 112
#> 1 1.040 35.2 12
#> 6 0.835 28.2 4
#> 9 0.916 31.0 8
#> 12 1.290 43.6 14
## extract the weights
weights(nr2)
#> , , stype = E
#>
#> comp.imp
#> sch.wide No Yes
#> No 1.0389893 2.0976751
#> Yes 0.6839602 0.9195794
#>
#> , , stype = H
#>
#> comp.imp
#> sch.wide No Yes
#> No 2.0976751 2.097675
#> Yes 0.8346383 2.097675
#>
#> , , stype = M
#>
#> comp.imp
#> sch.wide No Yes
#> No 0.9158863 2.097675
#> Yes 1.3886018 1.289416
#>