# Follow-up of 2 persons
clear()
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))
# drug purchases, one data frame for each drug
ra <- data.frame(per = c(2007 + runif(12,0,10)),
amt = sample(2:4, 12, r = TRUE),
lex.id = sample(1:2, 12, r = TRUE))
ra <- ra[order(ra$lex.id, ra$per),]
rb <- 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))
rb <- rb[order(rb$lex.id, rb$per),]
# put in a named list
pdat <- list(A = ra, B = rb)
pdat
ex1 <- addDrug.Lexis(Sx, pdat, method = "ext") # default
summary(ex1)
# collapsing some of the smaller intervals with the next
summary(coarse.Lexis(ex1, c(0.2,0.5)))
ex2 <- addDrug.Lexis(Sx, pdat, method = "ext", grace = 0.2)
dos <- addDrug.Lexis(Sx, pdat, method = "dos", dpt = 6)
fix <- addDrug.Lexis(Sx, pdat, method = "fix", maxt = 1)
Run the code above in your browser using DataLab