R Under development (unstable) (2024-03-07 r86063 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > ## 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)) Call: svyglm(formula = rel ~ factor(stage) * factor(histol), design = dccs2, family = quasibinomial) Survey design: twophase2(id = id, strata = strata, probs = probs, fpc = fpc, subset = subset, data = data, pps = pps) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.5701 0.1288 -19.955 < 2e-16 *** factor(stage)2 0.5482 0.1979 2.769 0.005708 ** factor(stage)3 0.4791 0.2032 2.359 0.018515 * factor(stage)4 1.0037 0.2592 3.872 0.000114 *** factor(histol)2 1.3505 0.3107 4.346 1.51e-05 *** factor(stage)2:factor(histol)2 0.1152 0.4410 0.261 0.793876 factor(stage)3:factor(histol)2 0.5066 0.4241 1.194 0.232548 factor(stage)4:factor(histol)2 0.9785 0.6214 1.575 0.115615 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for quasibinomial family taken to be 1.000876) Number of Fisher Scoring iterations: 4 > summary(svyglm(rel~factor(stage)*factor(histol),family=quasibinomial,design=dccs8)) Call: svyglm(formula = rel ~ factor(stage) * factor(histol), design = dccs8, family = quasibinomial) Survey design: twophase2(id = id, strata = strata, probs = probs, fpc = fpc, subset = subset, data = data, pps = pps) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.71604 0.10827 -25.085 < 2e-16 *** factor(stage)2 0.78141 0.14726 5.306 1.35e-07 *** factor(stage)3 0.80093 0.15250 5.252 1.80e-07 *** factor(stage)4 1.07293 0.17817 6.022 2.33e-09 *** factor(histol)2 1.45836 0.31780 4.589 4.96e-06 *** factor(stage)2:factor(histol)2 -0.04743 0.43495 -0.109 0.913 factor(stage)3:factor(histol)2 0.28064 0.41298 0.680 0.497 factor(stage)4:factor(histol)2 0.90983 0.63774 1.427 0.154 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for quasibinomial family taken to be 1.000876) Number of Fisher Scoring iterations: 4 > summary(svyglm(rel~factor(stage)*factor(histol),family=quasibinomial,design=gccs8)) Call: svyglm(formula = rel ~ factor(stage) * factor(histol), design = gccs8, family = quasibinomial) Survey design: calibrate(dccs2, phase = 2, formula = ~interaction(instit, stage, rel)) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.71604 0.10878 -24.968 < 2e-16 *** factor(stage)2 0.78141 0.14729 5.305 1.35e-07 *** factor(stage)3 0.80093 0.15212 5.265 1.68e-07 *** factor(stage)4 1.07293 0.17905 5.993 2.77e-09 *** factor(histol)2 1.45836 0.31757 4.592 4.88e-06 *** factor(stage)2:factor(histol)2 -0.04743 0.43432 -0.109 0.913 factor(stage)3:factor(histol)2 0.28064 0.41231 0.681 0.496 factor(stage)4:factor(histol)2 0.90983 0.63187 1.440 0.150 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for quasibinomial family taken to be 1.000876) Number of Fisher Scoring iterations: 4 > > ## check subsets of calibrated designs. > summary(svyglm(rel~factor(stage), + family=quasibinomial,design=subset(dccs8,histol==1))) Call: svyglm(formula = rel ~ factor(stage), design = subset(dccs8, histol == 1), family = quasibinomial) Survey design: subset(dccs8, histol == 1) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.7160 0.1083 -25.085 < 2e-16 *** factor(stage)2 0.7814 0.1473 5.306 1.48e-07 *** factor(stage)3 0.8009 0.1525 5.252 1.97e-07 *** factor(stage)4 1.0729 0.1782 6.022 2.73e-09 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for quasibinomial family taken to be 1.001333) Number of Fisher Scoring iterations: 4 Warning messages: 1: In `[.twophase2`(x, r, ) : 1 strata have only one PSU in this subset. 2: In summary.glm(g) : observations with zero weight not used for calculating dispersion 3: In summary.glm(glm.object) : observations with zero weight not used for calculating dispersion 4: In `[.twophase2`(design, nas == 0, ) : 1 strata have only one PSU in this subset. 5: In `[.twophase2`(design, nas == 0, ) : 1 strata have only one PSU in this subset. > summary(svyglm(rel~factor(stage), + family=quasibinomial,design=subset(gccs8,histol==1))) Call: svyglm(formula = rel ~ factor(stage), design = subset(gccs8, histol == 1), family = quasibinomial) Survey design: subset(gccs8, histol == 1) Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -2.7160 0.1082 -25.105 < 2e-16 *** factor(stage)2 0.7814 0.1457 5.363 1.10e-07 *** factor(stage)3 0.8009 0.1504 5.324 1.34e-07 *** factor(stage)4 1.0729 0.1759 6.101 1.70e-09 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for quasibinomial family taken to be 1.001333) Number of Fisher Scoring iterations: 4 Warning messages: 1: In summary.glm(g) : observations with zero weight not used for calculating dispersion 2: In summary.glm(glm.object) : observations with zero weight not used for calculating dispersion > > > proc.time() user system elapsed 2.75 0.31 3.04