Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upsplitLexisDT/splitMulti do not properly roll lex.Xst states #138
Comments
|
An example based on test in 0.4.3.5: library("Epi")
library("popEpi")
library("data.table")
data(nickel, package = "Epi")
lex <- Lexis( entry = list(age=agein,
per=agein+dob),
exit = list(age=ageout),
exit.status = factor(icd>0, labels=c("Alive","Dead")),
entry.status = factor(0, 0:1, labels = c("Alive", "Dead")),
data = nickel )
set.seed(1337)
lex$lex.id <- sample(paste0("abcd_", 1:nrow(lex)), size = nrow(lex))
BL <- list(
per = 1920:1990,
age = 0:100
)
epi_s1 <- splitLexis(lex, breaks = BL$per, time.scale = "per")
epi_s2 <- splitLexis(epi_s1, breaks = BL$age, time.scale = "age")
pop_s1 <- splitLexisDT(lex, breaks=BL$per, timeScale="per", drop = FALSE)
pop_s2 <- splitLexisDT(pop_s1, breaks=BL$age, timeScale="age" , drop = FALSE)
pop_s1_a <- splitLexisDT(lex, breaks=BL$age, timeScale="age", drop = FALSE)
pop_s2_a <- splitLexisDT(pop_s1_a, breaks=BL$per, timeScale="per" , drop = FALSE)
pop_sm_a <- splitMulti(lex, breaks = BL, drop = FALSE)
pop_sm_b <- splitMulti(lex, breaks = rev(BL), drop = FALSE)
all.equal(
setDT(epi_s1), setDT(pop_s1), check.attributes = FALSE
)
all.equal(
setDT(epi_s1), setDT(pop_s1_a), check.attributes = FALSE
)
all.equal(
setDT(epi_s2), setDT(pop_s2_a), check.attributes = FALSE
)
all.equal(
setDT(epi_s2), setDT(pop_s2), check.attributes = FALSE
)
all.equal(
setDT(epi_s2), setDT(pop_sm_a), check.attributes = FALSE
)
all.equal(
setDT(epi_s2), setDT(pop_sm_b), check.attributes = FALSE
)
|
It appears that in 0.4.3, lex.Xst resulting in splitting with splitLexisDT and hence splitMulti was sometimes duplicated --- that last two rows for a person had both e.g. alive -> dead. This has never happened in the test datas used before so it is somewhat strange. This has been resolved in aa2eaca and 172eff8.