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

reshaping of the data in bicomprisk #5

Open
jaromilfrossard opened this issue Feb 22, 2023 · 0 comments
Open

reshaping of the data in bicomprisk #5

jaromilfrossard opened this issue Feb 22, 2023 · 0 comments

Comments

@jaromilfrossard
Copy link

Thanks you for creating the mets package.

I stumble upon a strange behavior when using the bicomprisk() function. I still do not fully understand the theoretical background behind this function, but it seems not a desired behavior.

Here is the problem I saw:
For pairs, with both censored time, the time used in the function is the first one to appear in the data frame.

Sincerely,

Jaromil

Here is the code which replicates this behavior

library(mets)
library(dplyr)
library(tidyr)

## RUN the model
out <- bicomprisk(Event(time,status)~strata(zyg)+id(id),data=prt,cause=c(2,2),
                    return.data = T)

## Data in Wide format/ with max and min time
mydz =prt%>%as_tibble()%>%
  filter(zyg=="DZ")%>%
  group_by(id)%>%
  filter(n()==2)%>%
  summarise(
    mintime = min(time),
    maxtime = max(time),
    status_sum = sum(status),
    wmin =which.min(time),
    minstatus = status[which.min(time)],
    maxstatus = status[which.max(time)]
  )

## Analyse which time is kept when both subject of the pair is censored
## when wmin=1, then the first subject of the pairs has the minimum time.
## it always corresponds to cases when the time used is the minimum. 
mydz%>%
  mutate(model_time = dz$time)%>%
  filter(minstatus==0)%>%
  filter(maxstatus==0)%>%
  count(wmin,model_time==mintime)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant