Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

splitLexisDT/splitMulti do not properly roll lex.Xst states #138

Closed
WetRobot opened this issue Oct 24, 2017 · 2 comments
Closed

splitLexisDT/splitMulti do not properly roll lex.Xst states #138

WetRobot opened this issue Oct 24, 2017 · 2 comments
Assignees

Comments

@WetRobot
Copy link
Collaborator

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.

@WetRobot WetRobot self-assigned this Oct 24, 2017
@WetRobot
Copy link
Collaborator Author

This has been resolved in aa2eaca and 172eff8.

@WetRobot
Copy link
Collaborator Author

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
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant