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

Interval boundaries are not exactly equal #247

Open
Niklas191 opened this issue Dec 12, 2024 · 0 comments
Open

Interval boundaries are not exactly equal #247

Niklas191 opened this issue Dec 12, 2024 · 0 comments

Comments

@Niklas191
Copy link

Niklas191 commented Dec 12, 2024

Fore some reason it occasionally occurs that the the tstart value of an interval is not exactly equal to the tend value of the previous interval but differs slightly (in the range <1e-18), see example below. Interestingly, this only happens for one interval in the whole dataset.

Unfortunately, this leads to an error when using get_intervals() and, consequentially, prevents pec::pec() from working.

Example (example dataset is attached):
df.csv

> df <- read.csv("df.csv", header = TRUE)
> head(df)
      time event        x1        x2
1 0.143619     1 0.6961045 0.8430649
2 0.124192     1 0.2825347 0.5019340
3 0.038448     1 0.6041976 0.6403361
4 0.536073     1 0.5275156 0.2009848
5 0.345269     1 0.0115978 0.4454234
6 0.194007     1 0.8846513 0.0103127
> unique(sapply(df$time, nchar) - 2) # all values of time have at most 6 digits (-2 for for "." and leading 0)
[1] 6 5 4
> ped_df <- as_ped(df, Surv(time = time, event = event)~., cut = unique(df$time), id = "id")
> table(sort(unique(ped_df$tstart)) == lag(sort(unique(ped_df$tend))))

FALSE  TRUE 
    1   398 
> which(sort(unique(ped_df$tstart)) != lag(sort(unique(ped_df$tend))))
[1] 6
> head(ped_df)
  id   tstart     tend            interval    offset ped_status        x1        x2
1  1 0.000000 0.000849        (0,0.000849] -7.071451          0 0.6961045 0.8430649
2  1 0.000849 0.001239 (0.000849,0.001239] -7.849364          0 0.6961045 0.8430649
3  1 0.001239 0.001301 (0.001239,0.001301] -9.688376          0 0.6961045 0.8430649
4  1 0.001301 0.001592 (0.001301,0.001592] -8.142187          0 0.6961045 0.8430649
5  1 0.001592 0.005539 (0.001592,0.005539] -5.534799          0 0.6961045 0.8430649
6  1 0.005539 0.007474 (0.005539,0.007474] -6.247648          0 0.6961045 0.8430649
> ped_df$tend[5] == ped_df$tstart[6]
[1] FALSE
> ped_df$tend[5] - ped_df$tstart[6]
[1] -8.673617e-19
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