Examples for 'survey::oldsvyquantile'


Deprecated implementation of quantiles

Aliases: oldsvyquantile oldsvyquantile.survey.design oldsvyquantile.svyrep.design print.svyquantile

Keywords: univar survey

### ** Examples


  data(api)
  ## population
  quantile(apipop$api00,c(.25,.5,.75))
25% 50% 75% 
565 667 761 
  ## one-stage cluster sample
  dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
  oldsvyquantile(~api00, dclus1, c(.25,.5,.75),ci=TRUE)
$quantiles
        0.25 0.5  0.75
api00 551.75 652 717.5

$CIs
, , api00

           0.25      0.5     0.75
(lower 490.5049 557.1892 691.0000
upper) 626.9903 714.0000 772.7397
  oldsvyquantile(~api00, dclus1, c(.25,.5,.75),ci=TRUE,interval.type="betaWald")
$quantiles
        0.25 0.5  0.75
api00 551.75 652 717.5

$CIs
, , api00

           0.25      0.5     0.75
(lower 495.3133 554.2038 684.0202
upper) 636.7716 714.7962 761.0759
  oldsvyquantile(~api00, dclus1, c(.25,.5,.75),ci=TRUE,df=NULL)
$quantiles
        0.25 0.5  0.75
api00 551.75 652 717.5

$CIs
, , api00

           0.25      0.5     0.75
(lower 490.5049 557.1892 691.0000
upper) 626.9903 714.0000 772.7397
  dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
  (qapi<-oldsvyquantile(~api00, dclus1, c(.25,.5,.75),ci=TRUE, interval.type="score"))
$quantiles
        0.25 0.5  0.75
api00 551.75 652 717.5

$CIs
, , api00

           0.25      0.5     0.75
(lower 512.0003 565.9999 662.0000
upper) 638.9998 702.9995 753.9996
  SE(qapi)
    0.25      0.5     0.75 
29.60654 31.93782 21.44726 
  #stratified sample
  dstrat<-svydesign(id=~1, strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
  oldsvyquantile(~api00, dstrat, c(.25,.5,.75),ci=TRUE)
$quantiles
          0.25      0.5     0.75
api00 562.2056 667.2358 755.1226

$CIs
, , api00

           0.25      0.5     0.75
(lower 534.0000 636.2683 724.9898
upper) 594.4526 681.0000 777.0392
  #stratified sample, replicate weights
  # interval="probability" is necessary for jackknife weights
  rstrat<-as.svrepdesign(dstrat)
  oldsvyquantile(~api00, rstrat, c(.25,.5,.75), interval.type="probability")
Statistic:
         api00
q0.25 562.2056
q0.5  667.2358
q0.75 755.1226
SE:
         api00
q0.25 15.26348
q0.5  11.42383
q0.75 13.26813
  # 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)
Warning in svrepdesign.default(data = scd, type = "BRR", repweights =
repweights): No sampling weights provided: equal probability assumed
  oldsvyquantile(~arrests+alive, design=scdrep, quantile=0.5, interval.type="quantile")
Statistic:
     arrests alive
q0.5     185    30
SE:
      arrests    alive
q0.5 15.02706 4.756574
  oldsvyquantile(~arrests+alive, design=scdrep, quantile=0.5, interval.type="quantile",df=NULL)
Statistic:
     arrests alive
q0.5     185    30
SE:
      arrests    alive
q0.5 15.02706 4.756574

[Package survey version 4.1-1 Index]