Running ‘3stage2phase.R’ [3s/6s]
  Running ‘DBIcheck.R’ [3s/6s]
  Running ‘anova-svycoxph.R’ [3s/6s]
  Running ‘api.R’ [3s/6s]
  Running ‘badcal.R’ [2s/4s]
  Comparing ‘badcal.Rout’ to ‘badcal.Rout.save’ ... OK
  Running ‘bycovmat.R’ [2s/4s]
  Running ‘caleg.R’ [4s/7s]
  Running ‘check.R’ [2s/4s]
  Comparing ‘check.Rout’ to ‘check.Rout.save’ ... OK
  Running ‘contrast-replicates.R’ [2s/3s]
  Running ‘coxph-termtest.R’ [2s/4s]
  Running ‘deff.R’ [2s/4s]
  Comparing ‘deff.Rout’ to ‘deff.Rout.save’ ... OK
  Running ‘defftest.R’ [2s/4s]
  Running ‘domain.R’ [3s/5s]
  Running ‘fpc.R’ [2s/3s]
  Running ‘glm-scoping.R’ [2s/4s]
  Running ‘kalton.R’ [2s/3s]
  Comparing ‘kalton.Rout’ to ‘kalton.Rout.save’ ... OK
  Running ‘logranktest.R’ [2s/4s]
  Running ‘lonely.psu.R’ [3s/4s]
  Comparing ‘lonely.psu.Rout’ to ‘lonely.psu.Rout.save’ ... OK
  Running ‘mtcars-var.R’ [2s/3s]
  Running ‘multistage.R’ [2s/5s]
  Running ‘na_action.R’ [2s/3s]
  Running ‘newquantile.R’ [2s/3s]
  Running ‘nwts-cch.R’ [3s/4s]
  Running ‘nwts.R’ [3s/6s]
  Running ‘poisson.R’ [2s/4s]
  Running ‘pps.R’ [3s/5s]
  Running ‘quantile.R’ [3s/5s]
  Comparing ‘quantile.Rout’ to ‘quantile.Rout.save’ ... OK
  Running ‘quantiles-chile.R’ [2s/4s]
  Running ‘rakecheck.R’ [3s/5s]
  Comparing ‘rakecheck.Rout’ to ‘rakecheck.Rout.save’ ... OK
  Running ‘raowuboot.R’ [2s/4s]
  Comparing ‘raowuboot.Rout’ to ‘raowuboot.Rout.save’ ... OK
  Running ‘regTermTest-missing.R’ [2s/5s]
  Running ‘regpredict.R’ [2s/4s]
  Comparing ‘regpredict.Rout’ to ‘regpredict.Rout.save’ ... OK
  Running ‘rss_scores.R’ [2s/4s]
  Running ‘scoping.R’ [2s/3s]
  Running ‘survcurve.R’ [6s/9s]
  Comparing ‘survcurve.Rout’ to ‘survcurve.Rout.save’ ... OK
  Running ‘svyby-strings.R’ [2s/4s]
  Running ‘svyby_bug.R’ [2s/4s]
  Running ‘svyby_se.R’ [2s/3s]
  Running ‘svycontrast.R’ [2s/3s]
  Running ‘svyivreg-var.R’ [2s/3s]
  Running ‘svyivreg.R’ [2s/4s]
  Running ‘svyolr-rake-subset.R’ [2s/4s]
  Running ‘svyolr.R’ [2s/3s]
  Running ‘toy_example_for_postStratify.R’ [2s/3s]
  Running ‘twophase.R’ [2s/3s]
Running the tests in ‘tests/3stage2phase.R’ failed.
Complete output:
  > ## simulated data with three-stage sample at phase 1, SRS at phase 2
  > ## motivated by dietary biomarker substudy in HCHS
  > 
  > library(survey)
  Loading required package: grid
  Loading required package: Matrix
  Loading required package: survival
  
  Attaching package: 'survey'
  
  The following object is masked from 'package:graphics':
  
      dotchart
  
  > 
  > load("simdata1.RData")
  > 
  > twophase.full = twophase(id=list(~block+house+ind,~1),
  +                          strata=list(~strat,NULL),
  +                          probs=list(~P.block+P.house+P.ind,NULL),
  +                          subset=~phase2,
  +                          data=simdata1,method='full')
  > 
  > twophase.approx = twophase(id=list(~block+house+ind,~1),
  +                          strata=list(~strat,NULL),
  +                          probs=list(~P.block+P.house+P.ind,NULL),
  +                          subset=~phase2,
  +                          data=simdata1,method='approx')
  > 
  > twophase.rep = twophase(id=list(~block,~1),
  +                          strata=list(~strat,NULL),
  +                          probs=list(~I(P.block*P.house*P.ind),NULL),
  +                          subset=~phase2,
  +                          data=simdata1,method='full')
  > 
  > 
  > twophase.repapprox = twophase(id=list(~block,~1),
  +                          strata=list(~strat,NULL),
  +                          probs=list(~I(P.block*P.house*P.ind),NULL),
  +                          subset=~phase2,
  +                          data=simdata1,method='approx')
  > 
  > 
  > svymean(~age, twophase.full)
  Error in h(simpleError(msg, call)) : 
    error in evaluating the argument 'x' in selecting a method for function 'as.matrix': 'crossprod' is not an exported object from 'namespace:Matrix'
  Calls: svymean ... apply -> FUN -> as.matrix -> .handleSimpleError -> h
  Execution halted
Running the tests in ‘tests/domain.R’ failed.
Complete output:
  > ##
  > ## Domain means can be written as ratio estimators or as regression coefficients
  > ##
  > ## This code checks that subsetting the design object gives the same results as
  > ## these approaches.
  > ##
  > 
  > 
  > library(survey)
  Loading required package: grid
  Loading required package: Matrix
  Loading required package: survival
  
  Attaching package: 'survey'
  
  The following object is masked from 'package:graphics':
  
      dotchart
  
  > data(fpc)
  > dfpc<-svydesign(id=~psuid,strat=~stratid,weight=~weight,data=fpc,nest=TRUE)
  > dsub<-subset(dfpc,x>4)
  > (m1<-svymean(~x,design=dsub))
     mean     SE
  x 6.195 0.7555
  > 
  > ## These should give the same domain estimates and standard errors
  > (m2<-svyby(~x,~I(x>4),design=dfpc, svymean,keep.var=TRUE))
        I(x > 4)        x        se
  FALSE    FALSE 3.314286 0.3117042
  TRUE      TRUE 6.195000 0.7555129
  > m3<-svyglm(x~I(x>4)+0,design=dfpc)
  > summary(m3)
  
  Call:
  svyglm(formula = x ~ I(x > 4) + 0, design = dfpc)
  
  Survey design:
  svydesign(id = ~psuid, strat = ~stratid, weight = ~weight, data = fpc, 
      nest = TRUE)
  
  Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
  I(x > 4)FALSE   3.3143     0.3117   10.63 0.000127 ***
  I(x > 4)TRUE    6.1950     0.7555    8.20 0.000439 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
  (Dispersion parameter for gaussian family taken to be 2.557379)
  
  Number of Fisher Scoring iterations: 2
  
  > (m4<-svyratio(~I(x*(x>4)),~as.numeric(x>4), dfpc))
  Ratio estimator: svyratio.survey.design2(~I(x * (x > 4)), ~as.numeric(x > 4), 
      dfpc)
  Ratios=
                 as.numeric(x > 4)
  I(x * (x > 4))             6.195
  SEs=
                 as.numeric(x > 4)
  I(x * (x > 4))         0.7555129
  > stopifnot(isTRUE(all.equal(SE(m2), as.vector(SE(m3)))))
  > stopifnot(isTRUE(all.equal(SE(m2)[2], as.vector(SE(m4)))))
  > 
  > ## with strata
  > data(api)
  > dstrat<-svydesign(id=~1, strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
  > m1<-svymean(~enroll, subset(dstrat, comp.imp=="Yes"))
  > m2<-svyglm(enroll~comp.imp-1, dstrat)
  > m3<- svyratio(~I(enroll*(comp.imp=="Yes")), ~as.numeric(comp.imp=="Yes"), dstrat)
  > stopifnot(isTRUE(all.equal(as.vector(SE(m2)["comp.impYes"]), as.vector(SE(m1)))))
  > stopifnot(isTRUE( all.equal(as.vector(SE(m1)), as.vector(drop(SE(m3))))))
  > 
  > ## with calibration
  > dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
  > pop.totals<-c(`(Intercept)`=6194, stypeH=755, stypeM=1018)
  > (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))
  > 
  > m1<-svymean(~api00, subset(dclus1g3, comp.imp=="Yes"))
  > m3<-svyratio(~I(api00*(comp.imp=="Yes")), ~as.numeric(comp.imp=="Yes"), dclus1g3)
  > m2<-svyglm(api00~comp.imp-1, dclus1g3)
  > stopifnot(isTRUE( all.equal(as.vector(SE(m2)["comp.impYes"]), as.vector(SE(m1)))))
  > stopifnot(isTRUE( all.equal(as.vector(SE(m1)), as.vector(drop(SE(m3))))))
  > 
  > ## with raking
  > pop.types <- data.frame(stype=c("E","H","M"), Freq=c(4421,755,1018))
  > pop.schwide <- data.frame(sch.wide=c("No","Yes"), Freq=c(1072,5122))
  > dclus1r<-rake(dclus1, list(~stype,~sch.wide), list(pop.types, pop.schwide))
  > m1<-svymean(~api00, subset(dclus1r, comp.imp=="Yes"))
  > m2<-svyglm(api00~comp.imp-1, dclus1r)
  > m3<-svyratio(~I(api00*(comp.imp=="Yes")), ~as.numeric(comp.imp=="Yes"), dclus1r)
  > stopifnot(isTRUE( all.equal(as.vector(SE(m2)["comp.impYes"]), as.vector(SE(m1)))))
  > stopifnot(isTRUE( all.equal(as.vector(SE(m1)), as.vector(drop(SE(m3))))))
  > 
  > 
  > 
  > ##
  > ## based on bug report from Takahiro Tsuchiya for version 3.4
  > ## 
  > rei<-read.table(tmp<-textConnection(
  + "  id   N n.a h n.ah n.h   sub  y
  + 1   1 300  20 1   12   5  TRUE  1
  + 2   2 300  20 1   12   5  TRUE  2
  + 3   3 300  20 1   12   5  TRUE  3
  + 4   4 300  20 1   12   5  TRUE  4
  + 5   5 300  20 1   12   5  TRUE  5
  + 6   6 300  20 1   12   5 FALSE NA
  + 7   7 300  20 1   12   5 FALSE NA
  + 8   8 300  20 1   12   5 FALSE NA
  + 9   9 300  20 1   12   5 FALSE NA
  + 10 10 300  20 1   12   5 FALSE NA
  + 11 11 300  20 1   12   5 FALSE NA
  + 12 12 300  20 1   12   5 FALSE NA
  + 13 13 300  20 2    8   3  TRUE  6
  + 14 14 300  20 2    8   3  TRUE  7
  + 15 15 300  20 2    8   3  TRUE  8
  + 16 16 300  20 2    8   3 FALSE NA
  + 17 17 300  20 2    8   3 FALSE NA
  + 18 18 300  20 2    8   3 FALSE NA
  + 19 19 300  20 2    8   3 FALSE NA
  + 20 20 300  20 2    8   3 FALSE NA
  + "), header=TRUE)
  > close(tmp)
  > 
  > 
  > des.rei2 <- twophase(id=list(~id,~id), strata=list(NULL,~h),
  +                     fpc=list(~N,NULL), subset=~sub, data=rei, method="full")
  > tot2<- svytotal(~y, subset(des.rei2, y>3))
  Error in h(simpleError(msg, call)) : 
    error in evaluating the argument 'x' in selecting a method for function 'as.matrix': 'crossprod' is not an exported object from 'namespace:Matrix'
  Calls: svytotal ... apply -> FUN -> as.matrix -> .handleSimpleError -> h
  Execution halted
Running the tests in ‘tests/nwts-cch.R’ failed.
Complete output:
  > library(survey)
  Loading required package: grid
  Loading required package: Matrix
  Loading required package: survival
  
  Attaching package: 'survey'
  
  The following object is masked from 'package:graphics':
  
      dotchart
  
  > library(survival)
  > data(nwtco)
  > 
  > ntwco<-subset(nwtco, !is.na(edrel))
  > 
  > load("nwtco-subcohort.rda")
  > nwtco$subcohort<-subcohort
  > 
  > d_BorganII <- twophase(id=list(~seqno,~seqno),
  +                        strata=list(NULL,~interaction(instit,rel)),
  +                        data=nwtco, subset=~I(rel |subcohort))
  > 
  > ##Coefficient results same as Splus with code from
  > ## http://faculty.washington.edu/norm/software.html
  > ## SE slightly larger due to using sandwich variance.
  > 
  > svycoxph(Surv(edrel, rel)~factor(stage)+factor(histol)+I(age/12), design=d_BorganII)
  Error in h(simpleError(msg, call)) : 
    error in evaluating the argument 'x' in selecting a method for function 'as.matrix': 'crossprod' is not an exported object from 'namespace:Matrix'
  Calls: svycoxph ... apply -> FUN -> as.matrix -> .handleSimpleError -> h
  Execution halted
Running the tests in ‘tests/nwts.R’ failed.
Complete output:
  > 
  > ## examples from Breslow & Chatterjee: Applied Statistics 1999 No. 4, p458
  > ## data from Norman Breslow's web page.
  > library(survey)
  Loading required package: grid
  Loading required package: Matrix
  Loading required package: survival
  
  Attaching package: 'survey'
  
  The following object is masked from 'package:graphics':
  
      dotchart
  
  > load("nwts.rda")
  > nwtsnb<-nwts
  > nwtsnb$case<-nwts$case-nwtsb$case
  > nwtsnb$control<-nwts$control-nwtsb$control
  > 
  > a<-rbind(nwtsb,nwtsnb)
  > a$in.ccs<-rep(c(TRUE,FALSE),each=16)
  > 
  > b<-rbind(a,a)
  > b$rel<-rep(c(1,0),each=32)
  > b$n<-ifelse(b$rel,b$case,b$control)
  > 
  > index<-rep(1:64,b$n)
  > 
  > nwt.exp<-b[index,c(1:3,6,7)]
  > nwt.exp$id<-1:4088
  > 
  > dccs2<-twophase(id=list(~id,~id),subset=~in.ccs,
  +                 strata=list(NULL,~interaction(instit,rel)),data=nwt.exp)
  > 
  > dccs8<-twophase(id=list(~id,~id),subset=~in.ccs,
  +                 strata=list(NULL,~interaction(instit,stage,rel)),data=nwt.exp)
  > 
  > gccs8<-calibrate(dccs2,phase=2,formula=~interaction(instit,stage,rel))
  > 
  > summary(svyglm(rel~factor(stage)*factor(histol),family=quasibinomial,design=dccs2))
  Error in h(simpleError(msg, call)) : 
    error in evaluating the argument 'object' in selecting a method for function 'summary': error in evaluating the argument 'x' in selecting a method for function 'as.matrix': 'crossprod' is not an exported object from 'namespace:Matrix'
  Calls: summary ... as.matrix -> .handleSimpleError -> h -> .handleSimpleError -> h
  Execution halted
Running the tests in ‘tests/poisson.R’ failed.
Complete output:
  > ## check poisson sampling
  > library(survey)
  Loading required package: grid
  Loading required package: Matrix
  Loading required package: survival
  
  Attaching package: 'survey'
  
  The following object is masked from 'package:graphics':
  
      dotchart
  
  > data(api)
  > set.seed(2021-7-15)
  > apipop$prob<-apipop$api00/1000
  > insample<-rbinom(nrow(apipop),1,apipop$prob)
  > apipois<-apipop[insample,]
  > des<-svydesign(id=~1, prob=~prob, pps=poisson_sampling(apipois$prob), data=apipois)
  > 
  > stopifnot(isTRUE(all.equal(
  +  as.vector(SE(svytotal(~api00,design=des))),
  +  as.vector(sqrt(sum( (apipois$api00*weights(des))^2*(1-apipois$prob))))
  +  )))
  Error in h(simpleError(msg, call)) : 
    error in evaluating the argument 'target' in selecting a method for function 'all.equal': error in evaluating the argument 'x' in selecting a method for function 'as.matrix': 'crossprod' is not an exported object from 'namespace:Matrix'
  Calls: stopifnot ... as.matrix -> .handleSimpleError -> h -> .handleSimpleError -> h
  Execution halted
Running the tests in ‘tests/pps.R’ failed.
Complete output:
  > library(survey)
  Loading required package: grid
  Loading required package: Matrix
  Loading required package: survival
  
  Attaching package: 'survey'
  
  The following object is masked from 'package:graphics':
  
      dotchart
  
  > data(election)
  > 
  > dpps<- svydesign(id=~1, weights=~wt, fpc=~p, data=election_pps, pps="brewer")
  > dppswr <-svydesign(id=~1, weights=~wt, data=election_pps)
  > svytotal(~Bush+Kerry+Nader, dpps)
           total      SE
  Bush  64518472 2447629
  Kerry 51202102 2450787
  Nader   478530  102420
  > svytotal(~Bush+Kerry+Nader, dppswr)
           total      SE
  Bush  64518472 2671455
  Kerry 51202102 2679433
  Nader   478530  105303
  > 
  > ##subsets
  > svytotal(~Bush+Kerry+Nader, subset(dpps, Nader>0))
           total      SE
  Bush  34944285 5399833
  Kerry 25581714 4028434
  Nader   478530  102420
  > 
  > ##multistage: should agree with STRS analysis
  > data(api)
  > dclus2<-svydesign(id = ~dnum + snum, fpc = ~fpc1 + fpc2, data = apiclus2)
  > dclus2pps<-svydesign(id = ~dnum + snum, fpc = ~I(40/fpc1) + I(pmin(1,5/fpc2)), data = apiclus2)
  > 
  > all.equal(svytotal(~sch.wide,dclus2), svytotal(~sch.wide,dclus2pps))
  [1] TRUE
  > all.equal(svymean(~sch.wide,dclus2), svymean(~sch.wide,dclus2pps))
  [1] TRUE
  > all.equal(svytotal(~enroll,dclus2), svytotal(~enroll,dclus2pps))
  [1] TRUE
  > 
  > ## the new without-replacement methods
  > data(election)
  > dpps_br<- svydesign(id=~1,  fpc=~p, data=election_pps, pps="brewer")
  > dpps_ov<- svydesign(id=~1,  fpc=~p, data=election_pps, pps="overton")
  > dpps_hr<- svydesign(id=~1,  fpc=~p, data=election_pps, pps=HR(sum(election$p^2)/40))
  > dpps_hr1<- svydesign(id=~1, fpc=~p, data=election_pps, pps=HR())
  > dpps_ht<- svydesign(id=~1,  fpc=~p, data=election_pps, pps=ppsmat(election_jointprob))
  > ## Yates-Grundy type
  > dpps_yg<- svydesign(id=~1,  fpc=~p, data=election_pps, pps=ppsmat(election_jointprob),variance="YG")
  > dpps_hryg<- svydesign(id=~1,  fpc=~p, data=election_pps, pps=HR(sum(election$p^2)/40),variance="YG")
  > 
  > ## The with-replacement approximation
  > svytotal(~Bush+Kerry+Nader, dpps_ht)
  Error in h(simpleError(msg, call)) : 
    error in evaluating the argument 'x' in selecting a method for function 'as.matrix': 'crossprod' is not an exported object from 'namespace:Matrix'
  Calls: svytotal ... apply -> FUN -> as.matrix -> .handleSimpleError -> h
  Execution halted
Running the tests in ‘tests/twophase.R’ failed.
Complete output:
  > library(survey)
  Loading required package: grid
  Loading required package: Matrix
  Loading required package: survival
  
  Attaching package: 'survey'
  
  The following object is masked from 'package:graphics':
  
      dotchart
  
  > 
  > ## two-phase simple random sampling.
  > data(pbc, package="survival")
  > pbc$id<-1:nrow(pbc)
  > pbc$randomized<-with(pbc, !is.na(trt) & trt>-9)
  > (d2pbc<-twophase(id=list(~id,~id), data=pbc, subset=~I(!randomized)))
  Two-phase sparse-matrix design:
   twophase2(id = id, strata = strata, probs = probs, fpc = fpc, 
      subset = subset, data = data)
  Phase 1:
  Independent Sampling design (with replacement)
  svydesign(ids = ~id)
  Phase 2:
  Independent Sampling design
  svydesign(ids = ~id, fpc = `*phase1*`)
  > m<-svymean(~bili, d2pbc)
  Error in h(simpleError(msg, call)) : 
    error in evaluating the argument 'x' in selecting a method for function 'as.matrix': 'crossprod' is not an exported object from 'namespace:Matrix'
  Calls: svymean ... apply -> FUN -> as.matrix -> .handleSimpleError -> h
  Execution halted