# NOT RUN {
# Follow-up of 2 persons
fu <- data.frame(doe = c(2006, 2008),
dox = c(2015, 2018),
dob = c(1950, 1951),
xst = factor(c("A","D")))
Lx <- Lexis(entry = list(per = doe,
age = doe- dob),
exit = list(per = dox),
exit.status = xst,
data = fu)
Lx <- subset(Lx, select = -c(doe, dob, dox, xst))
# split FU in 1 year intervals
Sx <- splitLexis(Lx, "per", breaks = seq(1990, 2020, 1.0))
rc <- data.frame(per = c(2007 + runif(12,0,10)),
amt = sample(2:4, 12, r = TRUE),
lex.id = sample(1:2, 12, r = TRUE))
rc <- rc[order(rc$lex.id, rc$per),]
rd <- data.frame(per = c(2009 + runif(10, 0, 10)),
amt = sample(round(2:4/3,1), 10, r = TRUE),
lex.id = sample(1:2, 10, r = TRUE))
rd <- rd[order(rd$lex.id, rd$per),]
pdat <- list(Joe = rc, Pat = rd)
pdat
addDrug.Lexis(Sx, pdat, method = "ext") # default
addDrug.Lexis(Sx, pdat, method = "ext", grace = 0.2)
addDrug.Lexis(Sx, pdat, method = "dos", apt = 6)
addDrug.Lexis(Sx, pdat, method = "fix", maxt = 1)
# }
Run the code above in your browser using DataLab