svyquantile

0th

Percentile

Quantiles for sample surveys

Compute quantiles for data from complex surveys.

Keywords
univar, survey
Usage
## S3 method for class 'survey.design':
svyquantile(x, design, quantiles, alpha=0.05,
 ci=FALSE, method = "linear", f = 1, interval.type=c("Wald","score"),
 na.rm=FALSE,...)
## S3 method for class 'svyrep.design':
svyquantile(x, design, quantiles,
 method ="linear", interval.type=c("probability","quantile"), f = 1,
 return.replicates=FALSE,...)
## S3 method for class 'svyquantile':
SE(object,...)
Arguments
x
A formula, vector or matrix
design
survey.design or svyrep.design object
quantiles
Quantiles to estimate
method
see approxfun
f
see approxfun
ci
Compute a confidence interval (relatively slow)?
alpha
Level for confidence interval
interval.type
See Details below
return.replicates
Return the replicate means?
na.rm
Remove NAs?
...
arguments for future expansion
object
Object returned by svyquantile.survey.design
Details

Interval estimation for quantiles is complicated, because the influence function is not continuous. Linearisation cannot be used, and only some replication weight designs give valid results. For survey.design objects the computation is controlled by interval.type. If "Wald", a 95% Wald confidence interval is constructed for the proportion below the estimated quantile. The inverse of the estimated CDF is used to map this to a confidence interval for the quantile. This is the method of Woodruff (1952). If interval.type="score" we use a method described by Binder (1991) and due originally to Francisco and Fuller (1986), which corresponds to inverting a robust score test. At the upper and lower limits of the confidence interval, a test of the null hypothesis that the cumulative distribution function is equal to the target quantile just rejects. This was the default before version 2.9. It is much slower, and Dorfman & Valliant (1993) suggest it is not any more accurate. Standard errors are computed from these confidence intervals by dividing the confidence interval length by 2*qnorm(alpha/2). For replicate-weight designs, ordinary replication-based standard errors are valid for BRR and Fay's method, and for some bootstrap-based designs, but not for jackknife-based designs. interval.type="quantile" gives these replication-based standard errors. The default, interval.type="probability" computes confidence on the probability scale and then transforms back to quantiles, the equivalent of interval.type="Wald" for survey.design objects (with alpha=0.05).

Value

  • returns a list whose first component is the quantiles and second component is the confidence intervals. For replicate weight designs, returns an object of class svyrepstat.

Note

By default, svyquantile interpolates between the two nearest observed values to obtain a quantile. This is the almost universal practice outside survey statistics, but software for survey analysis often does not interpolate. Interpolation is discussed in the help for quantile; svyquantile uses type 4 of the 9 methods described there. For type 1 quantiles, the inverse of the weighted right-continuous empirical cdf, specify method="constant" and f=0.

References

Binder DA (1991) Use of estimating functions for interval estimation from complex surveys. Proceedings of the ASA Survey Research Methods Section 1991: 34-42

Dorfman A, Valliant R (1993) Quantile variance estimators in complex surveys. Proceedings of the ASA Survey Research Methods Section. 1993: 866-871 Francisco CA, Fuller WA (1986) Estimation of the distribution function with a complex survey. Technical Report, Iowa State University. Shao J, Tu D (1995) The Jackknife and Bootstrap. Springer. Woodruff RS (1952) Confidence intervals for medians and other position measures. JASA 57, 622-627.

See Also

svydesign, svymean, as.svrepdesign, svrepdesign

Aliases
  • svyquantile
  • print.svyquantile
  • SE.svyquantile
  • svyquantile.survey.design
  • svyquantile.svyrep.design
Examples
data(api)
  ## population
  quantile(apipop$api00,c(.25,.5,.75))

  ## one-stage cluster sample
  dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
  svyquantile(~api00, dclus1, c(.25,.5,.75),ci=TRUE)

  dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
  (qapi<-svyquantile(~api00, dclus1, c(.25,.5,.75),ci=TRUE, interval.type="score"))
  SE(qapi)

  #stratified sample
  dstrat<-svydesign(id=~1, strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
  svyquantile(~api00, dstrat, c(.25,.5,.75),ci=TRUE)

  #stratified sample, replicate weights
  # interval="probability" is necessary for jackknife weights
  rstrat<-as.svrepdesign(dstrat)
  svyquantile(~api00, rstrat, c(.25,.5,.75), interval="probability")


  # BRR method
  data(scd)
  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)
  svyquantile(~arrests+alive, design=scdrep, quantile=0.5, interval="quantile")
Documentation reproduced from package survey, version 3.9-1, License: GPL-2 | GPL-3

Community examples

Looks like there are no examples yet.