# A small bogus cohort
xcoh <- data.frame( id = c("A", "B", "C"),
birth = c("1952-07-14", "1954-04-01", "1987-06-10"),
entry = c("1965-08-04", "1972-09-08", "1991-12-23"),
exit = c("1997-06-27", "1995-05-23", "1998-07-24"),
fail = c(1, 0, 1),
sex = c("M","F","M") )
# Convert to calendar years
for( i in 2:4 ) xcoh[,i] <- cal.yr(xcoh[,i])
xcoh <- xcoh[sample(1:3, 10, replace = TRUE),]
xcoh$entry <- xcoh$entry + runif(10, 0, 10)
xcoh$exit <- xcoh$entry + runif(10, 0, 10)
Lcoh <- Lexis(entry = list(per = entry),
exit = list(per = exit,
age = exit - birth),
exit.status = fail,
data = xcoh)
Lcoh
Lx <- splitLexis(Lcoh, breaks = 0:10 * 10, "age")
Lx
nid(Lx)
nid(Lx, by="sex")
Lb <- bootLexis(Lx)
head(Lb)
nid(bootLexis(Lx, size = 7))
Li <- bootLexis(Lx, by = "id") # superfluous
summary(Lx)
summary(Li)
L2 <- bootLexis(Lx, by = "sex", size = c(2, 5))
nid(L2, by = "sex")
summary(L2, by = "sex")
Run the code above in your browser using DataLab