Running examples in ‘survey-Ex.R’ failed
The error most likely occurred in:

> ### Name: calibrate
> ### Title: Calibration (GREG) estimators
> ### Aliases: calibrate.survey.design2 calibrate.svyrep.design calibrate
> ###   calibrate.twophase grake
> ### Keywords: survey manip
> 
> ### ** Examples
> 
> data(api)
> dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
> 
> pop.totals<-c(`(Intercept)`=6194, stypeH=755, stypeM=1018)
> 
> ## For a single factor variable this is equivalent to
> ## postStratify
> 
> (dclus1g<-calibrate(dclus1, ~stype, pop.totals))
1 - level Cluster Sampling design
With (15) clusters.
calibrate(dclus1, ~stype, pop.totals)
> 
> svymean(~api00, dclus1g)
        mean     SE
api00 642.31 23.921
> svytotal(~enroll, dclus1g)
         total     SE
enroll 3680893 406293
> svytotal(~stype, dclus1g)
       total SE
stypeE  4421  0
stypeH   755  0
stypeM  1018  0
> 
> ## Make weights constant within school district
> (dclus1agg<-calibrate(dclus1, ~stype, pop.totals, aggregate=1))
1 - level Cluster Sampling design
With (15) clusters.
calibrate(dclus1, ~stype, pop.totals, aggregate = 1)
> svymean(~api00, dclus1agg)
        mean    SE
api00 640.31 25.71
> svytotal(~enroll, dclus1agg)
         total     SE
enroll 3313035 268167
> svytotal(~stype, dclus1agg)
       total SE
stypeE  4421  0
stypeH   755  0
stypeM  1018  0
> 
> 
> ## Now add sch.wide
> (dclus1g2 <- calibrate(dclus1, ~stype+sch.wide, c(pop.totals, sch.wideYes=5122)))
1 - level Cluster Sampling design
With (15) clusters.
calibrate(dclus1, ~stype + sch.wide, c(pop.totals, sch.wideYes = 5122))
> 
> svymean(~api00, dclus1g2)
      mean     SE
api00  641 23.829
> svytotal(~enroll, dclus1g2)
         total     SE
enroll 3654414 403074
> svytotal(~stype, dclus1g2)
       total SE
stypeE  4421  0
stypeH   755  0
stypeM  1018  0
> 
> ## Finally, calibrate on 1999 API and school type
> 
> (dclus1g3 <- calibrate(dclus1, ~stype+api99, c(pop.totals, api99=3914069)))
1 - level Cluster Sampling design
With (15) clusters.
calibrate(dclus1, ~stype + api99, c(pop.totals, api99 = 3914069))
> 
> svymean(~api00, dclus1g3)
        mean     SE
api00 665.31 3.4418
> svytotal(~enroll, dclus1g3)
         total     SE
enroll 3638487 385524
> svytotal(~stype, dclus1g3)
       total SE
stypeE  4421  0
stypeH   755  0
stypeM  1018  0
> 
> 
> ## Same syntax with replicate weights
> rclus1<-as.svrepdesign(dclus1)
> 
> (rclus1g3 <- calibrate(rclus1, ~stype+api99, c(pop.totals, api99=3914069)))
Call: calibrate(rclus1, ~stype + api99, c(pop.totals, api99 = 3914069))
Unstratified cluster jacknife (JK1) with 15 replicates.
> 
> svymean(~api00, rclus1g3)
        mean     SE
api00 665.31 3.9429
> svytotal(~enroll, rclus1g3)
         total     SE
enroll 3638487 478749
> svytotal(~stype, rclus1g3)
       total SE
stypeE  4421  0
stypeH   755  0
stypeM  1018  0
> 
> (rclus1agg3 <- calibrate(rclus1, ~stype+api99, c(pop.totals,api99=3914069), aggregate.index=~dnum))
Call: calibrate(rclus1, ~stype + api99, c(pop.totals, api99 = 3914069), 
    aggregate.index = ~dnum)
Unstratified cluster jacknife (JK1) with 15 replicates.
> 
> svymean(~api00, rclus1agg3)
        mean     SE
api00 666.83 6.5308
> svytotal(~enroll, rclus1agg3)
         total     SE
enroll 3238699 438251
> svytotal(~stype, rclus1agg3)
       total SE
stypeE  4421  0
stypeH   755  0
stypeM  1018  0
> 
> 
> ###
> ## Bounded weights
> range(weights(dclus1g3)/weights(dclus1))
[1] 0.4185925 1.8332949
> dclus1g3b <- calibrate(dclus1, ~stype+api99, c(pop.totals, api99=3914069),bounds=c(0.6,1.6))
> range(weights(dclus1g3b)/weights(dclus1))
[1] 0.6 1.6
> 
> svymean(~api00, dclus1g3b)
        mean     SE
api00 665.48 3.4184
> svytotal(~enroll, dclus1g3b)
         total     SE
enroll 3662213 378691
> svytotal(~stype, dclus1g3b)
       total SE
stypeE  4421  0
stypeH   755  0
stypeM  1018  0
> 
> ## trimming
> dclus1tr <- calibrate(dclus1, ~stype+api99, c(pop.totals, api99=3914069), 
+    bounds=c(0.5,2), trim=c(2/3,3/2))
37 weights were trimmed
> svymean(~api00+api99+enroll, dclus1tr)
         mean      SE
api00  662.73  3.4388
api99  628.63  0.0000
enroll 583.20 57.5477
> svytotal(~stype,dclus1tr)
         total SE
stypeE 4496.71  0
stypeH  684.89  0
stypeM 1012.40  0
> range(weights(dclus1tr)/weights(dclus1))
[1] 0.6666667 1.5000000
> 
> rclus1tr <- calibrate(rclus1, ~stype+api99, c(pop.totals, api99=3914069),
+    bounds=c(0.5,2), trim=c(2/3,3/2))
37 weights were trimmed
Warning in grake(mm, wwi, calfun, eta = rep(0, NCOL(mm)), bounds = bounds,  :
  Failed to converge: eps=0.0392952671757451 in 51 iterations
> svymean(~api00+api99+enroll, rclus1tr)
         mean      SE
api00  662.73  7.2853
api99  628.63  5.5528
enroll 583.20 63.0674
> svytotal(~stype,rclus1tr)
         total      SE
stypeE 4496.71 165.351
stypeH  684.89 168.518
stypeM 1012.40  56.543
> 
> ## Input in the same format as rake() for classical raking
> pop.table <- xtabs(~stype+sch.wide,apipop)
> pop.table2 <- xtabs(~stype+comp.imp,apipop)
> dclus1r<-rake(dclus1, list(~stype+sch.wide, ~stype+comp.imp),
+                list(pop.table, pop.table2))
Error in if (delta < epsilon) { : missing value where TRUE/FALSE needed
Calls: rake
Execution halted