### R code from vignette source 'attr-risk-sol.rnw'

###################################################
### code chunk number 1: attr-risk-sol.rnw:35-46
###################################################
th <- matrix( c(
 0,   5,  572.1,  11, 1536.1,
20,  17, 1974.2,  16, 2449.1,
30,  58, 3489.0,  35, 4228.8,
40, 100, 4502.2,  67, 5822.3,
50, 184, 4433.5, 137, 6647.0,
60, 205, 2998.1, 211, 5780.3,
70, 137, 1134.4, 206, 3113.6,
80,  45,  261.5, 114,  939.8), ncol=5, byrow=TRUE )
colnames(th) <- c("age","D.th","Y.th","D.ct","Y.ct")
th


###################################################
### code chunk number 2: attr-risk-sol.rnw:50-51
###################################################
RR <- (th[,"D.th"]/th[,"Y.th"]) / (th[,"D.ct"]/th[,"Y.ct"])


###################################################
### code chunk number 3: attr-risk-sol.rnw:54-55
###################################################
AR <- (RR-1)/RR


###################################################
### code chunk number 4: attr-risk-sol.rnw:59-63
###################################################
D.tot <- th[,"D.th"] + th[,"D.ct"]
AC <- AR * D.tot
round( cbind( RR, AR, AC ), 3 )
round( sum(AC), 1 )


