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

Adding conformal extensions to right-censored data #22

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
99eb0ca
Extensions to right-censored data
ariane-cwi Sep 21, 2023
b5a59ca
Name repository
ariane-cwi Sep 21, 2023
1a54547
Minor revisions
ariane-cwi Sep 21, 2023
f08789c
Update README.md
ariane-cwi Sep 21, 2023
8dee1eb
Update check.R
ariane-cwi Sep 21, 2023
51132f1
Merge branch 'master' of https://github.com/ariane-cwi/conformal
ariane-cwi Sep 21, 2023
c82f8c5
Test check
ariane-cwi Sep 21, 2023
52b84f4
Test check
ariane-cwi Sep 21, 2023
b21e20d
Export
ariane-cwi Sep 25, 2023
ee645a3
Namespace modification
ariane-cwi Sep 25, 2023
b699baa
Description modifications
ariane-cwi Sep 25, 2023
fba01a8
Namespace update
ariane-cwi Sep 25, 2023
31220cf
Update rmst.pred.R
ariane-cwi Sep 25, 2023
85fe8f4
Update rmst.pred.Rd
ariane-cwi Sep 25, 2023
f62e90e
Description updates
ariane-cwi Sep 25, 2023
e2ca674
rmst.pred update
ariane-cwi Sep 25, 2023
e03c9a0
rmst.pred updates
ariane-cwi Sep 25, 2023
c567c52
rmst.pred updates
ariane-cwi Sep 25, 2023
145cd25
Description updates
ariane-cwi Sep 25, 2023
7c8e403
Description updates
ariane-cwi Sep 25, 2023
439422f
Update loco.roo.R
ariane-cwi Sep 25, 2023
68f98b8
Update loco.roo.R
ariane-cwi Sep 25, 2023
d7b26a9
Dimension issue
ariane-cwi Sep 26, 2023
f241bf5
Dimension issues
ariane-cwi Sep 26, 2023
07e88de
Independent function wrss
ariane-cwi Sep 26, 2023
a20f168
wrss updates
ariane-cwi Sep 26, 2023
e0cfeb2
wrss updates
ariane-cwi Sep 26, 2023
b76bf34
wrss updates
ariane-cwi Sep 26, 2023
d244393
wrss error
ariane-cwi Sep 26, 2023
fceea8c
Update rmst.pred.R
ariane-cwi Sep 26, 2023
eedfcad
Illustrations
ariane-cwi Sep 27, 2023
626829a
Update fig.loco.surv.R
ariane-cwi Sep 27, 2023
247e1eb
Update fig.loco.surv.R
ariane-cwi Sep 27, 2023
2219209
Alpha check error
ariane-cwi Sep 28, 2023
7f2e864
Update plot.rmst.pred
ariane-cwi Sep 28, 2023
d74667c
Correction wrss
ariane-cwi Nov 8, 2023
68c2103
varsL and varsG
ariane-cwi Dec 13, 2023
a7ad4bb
Update plot.rmst.pred for vimpL
ariane-cwi Dec 13, 2023
ee4e11d
Update rmst.pred.R
ariane-cwi Dec 13, 2023
354747e
Update rmst.pred.R
ariane-cwi Dec 19, 2023
89b1f43
Update check.R
ariane-cwi Dec 20, 2023
61bfd6a
Update check.R
ariane-cwi Dec 20, 2023
5099094
Update check.R
ariane-cwi Dec 20, 2023
c719088
Update check.R
ariane-cwi Dec 20, 2023
3eedb4d
Factors authorized in x
ariane-cwi Jan 5, 2024
89c80bc
Update ipcw.R
ariane-cwi Jan 9, 2024
0425f10
Rejection rate
ariane-cwi Feb 12, 2024
df79528
Update fig.loco.surv.R
ariane-cwi Aug 20, 2024
5dd268f
Update rmst.pred.R
ariane-cwi Aug 20, 2024
d694302
Update roo.R
ariane-cwi Aug 21, 2024
ac93512
Update split.R
ariane-cwi Aug 21, 2024
53218da
Update ipcw.R
ariane-cwi Aug 23, 2024
0124d3d
Update ipcw.R
ariane-cwi Aug 23, 2024
a4c3fe9
Update ipcw.R
ariane-cwi Aug 23, 2024
51bde67
Update loco.R
ariane-cwi Sep 6, 2024
092ecc2
Update loco.R
ariane-cwi Sep 10, 2024
800bd54
Update ipcw.R
ariane-cwi Sep 24, 2024
1a55b09
Update calibration.pdf
ariane-cwi Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update ipcw.R
Error for division by zero (if the censoring survival function reaches 0 at the evaluated time)
ariane-cwi committed Aug 23, 2024
commit 53218da5783cd0d1bfedf5256b50d20bae3845ee
52 changes: 39 additions & 13 deletions conformalInference/R/ipcw.R
Original file line number Diff line number Diff line change
@@ -36,10 +36,19 @@ ipcw.km = function(t,d,x,tau){
fit = survfit(Surv(t, d) ~ 1, data=df)
censfct = stepfun(fit$time,c(1,fit$surv))
G.hat.tau = censfct(tau)
w = as.double(lapply(1:n, function(s)
(t[s] <= tau)*d[s]/ifelse(d[s],censfct(t[s]),1) +
(t[s] > tau)/G.hat.tau )
)
w = as.double(lapply(1:n, function(s) {
if (t[s] <= tau) {
if (d[s] && censfct[[s]](t[s]) == 0) {
stop("Error in weight calculation: Division by zero")
}
return((t[s] <= tau) * d[s] / ifelse(d[s],censfct[[s]](t[s]),1))
} else {
if (censfct[[s]](tau) == 0) {
stop("Error in weight calculation: Division by zero")
}
return((t[s] > tau) / censfct[[s]](tau))
}
}))
return(w)
}

@@ -48,11 +57,19 @@ ipcw.cox = function(t,d,x,tau){
df = data.frame(t=t,d=1-d,x)
fit = survfit(coxph(Surv(t, d) ~ ., data=df), newdata=data.frame(x))
censfct = sapply(1:n,function(j) stepfun(fit$time,c(1,fit$surv[,j])))
w = as.double(lapply(1:n, function(s)
(t[s] <= tau)*d[s]/ifelse(d[s],censfct[[s]](t[s]),1) +
(t[s] > tau)/censfct[[s]](tau) )
)

w = as.double(lapply(1:n, function(s) {
if (t[s] <= tau) {
if (d[s] && censfct[[s]](t[s]) == 0) {
stop("Error in weight calculation: Division by zero")
}
return((t[s] <= tau) * d[s] / ifelse(d[s],censfct[[s]](t[s]),1))
} else {
if (censfct[[s]](tau) == 0) {
stop("Error in weight calculation: Division by zero")
}
return((t[s] > tau) / censfct[[s]](tau))
}
}))
return(w)
}

@@ -61,9 +78,18 @@ ipcw.rfsrc = function(t,d,x,tau){
df = data.frame(t=t,d=1-d,x)
fit = rfsrc(Surv(t, d) ~ ., data=df)
censfct = sapply(1:n,function(j) stepfun(fit$time.interest,c(1,fit$survival[j,])))
w = as.double(lapply(1:n, function(s)
(t[s] <= tau)*d[s]/ifelse(d[s],censfct[[s]](t[s]),1) +
(t[s] > tau)/censfct[[s]](tau) )
)
w = as.double(lapply(1:n, function(s) {
if (t[s] <= tau) {
if (d[s] && censfct[[s]](t[s]) == 0) {
stop("Error in weight calculation: Division by zero")
}
return((t[s] <= tau) * d[s] / ifelse(d[s],censfct[[s]](t[s]),1))
} else {
if (censfct[[s]](tau) == 0) {
stop("Error in weight calculation: Division by zero")
}
return((t[s] > tau) / censfct[[s]](tau))
}
}))
return(w)
}