data(steno2)
data(st2alb)
L2 <- Lexis( entry = list(per = doBase,
age = doBase - doBth),
exit = list(per = doEnd),
exit.status = factor(deathCVD + !is.na(doDth),
labels=c("Mic","D(oth)","D(CVD)")),
id = id,
data = cal.yr(steno2) )
summary(L2)
#
# Cut at intermediate transitions
cut2 <- data.frame(lex.id = st2alb$id,
cut = cal.yr(st2alb$do),
new.state = st2alb$state)
L3 <- rcutLexis(L2, cut2)
summary(L3)
#
# no direct transitions Mic <-> Mac allowed, so put a cut in between:
dd <- subset(L3, (lex.Cst == "Mac" & lex.Xst =="Norm") |
(lex.Cst =="Norm" & lex.Xst == "Mac"))
# artificial visits to the middle state Mic:
cut3 <- data.frame( lex.id = dd$lex.id,
cut = dd$per + dd$lex.dur/2,
new.state = "Mic")
L4 <- rcutLexis(L3, cut3)
summary(L4)
#
# Show all transitions
boxes(L4, boxpos = list(x = c(15,15,15,85,85),
y = c(50,15,85,25,75)),
show.BE = TRUE, scale.R = 1000,
cex=0.8, pos.arr=0.7, font=1, font.arr=1)
Run the code above in your browser using DataLab