# NOT RUN {
library(robcbi)
# First example
data(Finney)
Vol <- Finney$Vol; Rate <- Finney$Rate; Resp <- Finney$Resp
# }
# NOT RUN {
plot(Vol,Rate,type="n")
points(Vol[Resp==0],Rate[Resp==0],pch=5, cex=1.2)
points(Vol[Resp==1],Rate[Resp==1],pch=16,cex=1.2)
# }
# NOT RUN {
lVol <-log(Vol); lRate <- log(Rate)
z.glm <- glm(Resp~lVol+lRate,family=binomial)
summary(z.glm)
z.cub <- glm(Resp~lVol+lRate,family=binomial,method="cubinf", ufact=3.2)
summary(z.cub)
weights(z.cub)
# }
# NOT RUN {
plot(z.cub, smooth=TRUE, ask=TRUE)
# }
# NOT RUN {
comp <- fits.compare(z.glm,z.cub)
comp
# }
# NOT RUN {
plot(comp)
# }
# NOT RUN {
# Second example
data(Breslow)
# }
# NOT RUN {
help(Breslow)
# }
# NOT RUN {
y = Breslow$sumY
x1 = Breslow$Age10
x2 = Breslow$Base4
x3 = rep(0,length(y))
x3[Breslow$Trt=="progabide"] = 1
x4 = x2*x3
CBA = glm(y~x1+x2+x3+x4,family=poisson,method=cubinf,ufact=3.2)
# }
# NOT RUN {
plot(CBA,num=5)
# }
# NOT RUN {
weights(CBA)
#
# compute the $R_n^2$ statistic (Section 2.5) to compare CBA
# with a reduced model with three variables:
#
CBA.red = update(CBA, .~.-x3-x4)
np = 5 # number of parameters of the full model
nq = 3 # number of parameters of the reduced model
CVR = covar(CBA)
CFF = coef(CBA)
K22 = CVR[(nq+1):np,(nq+1):np]
cff = as.matrix(CFF[(nq+1):np])
Rn2 = t(cff)%*%solve(K22)%*%cff
Rn2
# }
Run the code above in your browser using DataLab