svyratio.Rd
Ratio estimation and estimates of totals based on ratios for complex
survey samples. Estimating domain (subpopulation) means can be done
more easily with svymean
.
# S3 method for survey.design2
svyratio(numerator=formula, denominator,
design,separate=FALSE, na.rm=FALSE,formula, covmat=FALSE,
deff=FALSE,influence=FALSE,...)
# S3 method for svyrep.design
svyratio(numerator=formula, denominator, design,
na.rm=FALSE,formula, covmat=FALSE,return.replicates=FALSE,deff=FALSE, ...)
# S3 method for twophase
svyratio(numerator=formula, denominator, design,
separate=FALSE, na.rm=FALSE,formula,...)
# S3 method for svyratio
predict(object, total, se=TRUE,...)
# S3 method for svyratio_separate
predict(object, total, se=TRUE,...)
# S3 method for svyratio
SE(object,...,drop=TRUE)
# S3 method for svyratio
coef(object,...,drop=TRUE)
# S3 method for svyratio
confint(object, parm, level = 0.95,df =Inf,...)
formula, expression, or data frame giving numerator variable(s)
formula, expression, or data frame giving denominator variable(s)
survey design object
result of svyratio
vector of population totals for the denominator variables in
object
, or list of vectors of
population stratum totals if separate=TRUE
Return standard errors?
Estimate ratio separately for strata
Remove missing values?
Compute the full variance-covariance matrix of the ratios
Compute design effects
Return replicate estimates of ratios
Return influence functions
Return a vector rather than a matrix
a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered.
the confidence level required.
degrees of freedom for t-distribution in confidence
interval, use degf(design)
for number of PSUs minus number of
strata
Other unused arguments for other methods
The separate ratio estimate of a total is the sum of ratio estimates
in each stratum. If the stratum totals supplied in the total
argument and the strata in the design object both have names these
names will be matched. If they do not have names it is important that
the sample totals are supplied in the correct order, the same order
as shown in the output of summary(design)
.
When design
is a two-phase design, stratification will be on
the second phase.
svyratio
returns an object of class svyratio
. The
predict
method returns a matrix of population totals and
optionally a matrix of standard errors.
Levy and Lemeshow. "Sampling of Populations" (3rd edition). Wiley
data(scd)
## survey design objects
scddes<-svydesign(data=scd, prob=~1, id=~ambulance, strata=~ESA,
nest=TRUE, fpc=rep(5,6))
scdnofpc<-svydesign(data=scd, prob=~1, id=~ambulance, strata=~ESA,
nest=TRUE)
# convert to BRR replicate weights
scd2brr <- as.svrepdesign(scdnofpc, type="BRR")
# use BRR replicate weights from Levy and Lemeshow
repweights<-2*cbind(c(1,0,1,0,1,0), c(1,0,0,1,0,1), c(0,1,1,0,0,1),
c(0,1,0,1,1,0))
scdrep<-svrepdesign(data=scd, type="BRR", repweights=repweights)
#> Warning: No sampling weights provided: equal probability assumed
# ratio estimates
svyratio(~alive, ~arrests, design=scddes)
#> Ratio estimator: svyratio.survey.design2(~alive, ~arrests, design = scddes)
#> Ratios=
#> arrests
#> alive 0.1535064
#> SEs=
#> arrests
#> alive 0.007596705
svyratio(~alive, ~arrests, design=scdnofpc)
#> Ratio estimator: svyratio.survey.design2(~alive, ~arrests, design = scdnofpc)
#> Ratios=
#> arrests
#> alive 0.1535064
#> SEs=
#> arrests
#> alive 0.009807304
svyratio(~alive, ~arrests, design=scd2brr)
#> Ratio estimator: svyratio.svyrep.design(~alive, ~arrests, design = scd2brr)
#> Ratios=
#> arrests
#> alive 0.1535064
#> SEs=
#> [,1]
#> [1,] 0.009418401
svyratio(~alive, ~arrests, design=scdrep)
#> Ratio estimator: svyratio.svyrep.design(~alive, ~arrests, design = scdrep)
#> Ratios=
#> arrests
#> alive 0.1535064
#> SEs=
#> [,1]
#> [1,] 0.009418401
data(api)
dstrat<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
## domain means are ratio estimates, but available directly
svyratio(~I(api.stu*(comp.imp=="Yes")), ~as.numeric(comp.imp=="Yes"), dstrat)
#> Ratio estimator: svyratio.survey.design2(~I(api.stu * (comp.imp == "Yes")), ~as.numeric(comp.imp ==
#> "Yes"), dstrat)
#> Ratios=
#> as.numeric(comp.imp == "Yes")
#> I(api.stu * (comp.imp == "Yes")) 439.9305
#> SEs=
#> as.numeric(comp.imp == "Yes")
#> I(api.stu * (comp.imp == "Yes")) 19.24367
svymean(~api.stu, subset(dstrat, comp.imp=="Yes"))
#> mean SE
#> api.stu 439.93 19.244
## separate and combined ratio estimates of total
(sep<-svyratio(~api.stu,~enroll, dstrat,separate=TRUE))
#> Stratified ratio estimate: svyratio.survey.design2(~api.stu, ~enroll, dstrat, separate = TRUE)
#> Ratio estimator: Stratum == 1L
#> Ratios=
#> enroll
#> api.stu 0.8518163
#> SEs=
#> enroll
#> api.stu 0.00703236
#> Ratio estimator: Stratum == 2L
#> Ratios=
#> enroll
#> api.stu 0.8105702
#> SEs=
#> enroll
#> api.stu 0.02047726
#> Ratio estimator: Stratum == 3L
#> Ratios=
#> enroll
#> api.stu 0.8356958
#> SEs=
#> enroll
#> api.stu 0.01818744
(com<-svyratio(~api.stu, ~enroll, dstrat))
#> Ratio estimator: svyratio.survey.design2(~api.stu, ~enroll, dstrat)
#> Ratios=
#> enroll
#> api.stu 0.8369569
#> SEs=
#> enroll
#> api.stu 0.007757103
stratum.totals<-list(E=1877350, H=1013824, M=920298)
predict(sep, total=stratum.totals)
#> $total
#> enroll
#> api.stu 3190022
#>
#> $se
#> enroll
#> api.stu 29756.44
#>
predict(com, total=sum(unlist(stratum.totals)))
#> $total
#> enroll
#> api.stu 3190038
#>
#> $se
#> enroll
#> api.stu 29565.98
#>
SE(com)
#> api.stu/enroll
#> 0.007757103
coef(com)
#> api.stu/enroll
#> 0.8369569
coef(com, drop=FALSE)
#> enroll
#> api.stu 0.8369569
confint(com)
#> 2.5 % 97.5 %
#> api.stu/enroll 0.8217532 0.8521605