Skip to content

Commit 2e3b026

Browse files
Terry M Therneaucran-robot
authored andcommitted
version 3.6-4
1 parent 0ea2ab2 commit 2e3b026

File tree

114 files changed

+7480
-27194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+7480
-27194
lines changed

DESCRIPTION

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Title: Survival Analysis
22
Priority: recommended
33
Package: survival
4-
Version: 3.5-8
5-
Date: 2024-02-13
4+
Version: 3.6-4
5+
Date: 2024-04-22
66
Depends: R (>= 3.5.0)
77
Imports: graphics, Matrix, methods, splines, stats, utils
88
LazyData: Yes
@@ -22,12 +22,12 @@ Description: Contains the core survival analysis routines, including
2222
License: LGPL (>= 2)
2323
URL: https://github.com/therneau/survival
2424
NeedsCompilation: yes
25-
Packaged: 2024-02-13 23:24:58 UTC; therneau
25+
Packaged: 2024-04-22 14:02:15 UTC; therneau
2626
Author: Terry M Therneau [aut, cre],
2727
Thomas Lumley [ctb, trl] (original S->R port and R maintainer until
2828
2009),
2929
Atkinson Elizabeth [ctb],
3030
Crowson Cynthia [ctb]
3131
Maintainer: Terry M Therneau <therneau.terry@mayo.edu>
3232
Repository: CRAN
33-
Date/Publication: 2024-02-14 10:20:23 UTC
33+
Date/Publication: 2024-04-24 06:50:02 UTC

MD5

Lines changed: 94 additions & 100 deletions
Large diffs are not rendered by default.

R/aeqSurv.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Create time values such that tiny differences are treated as a tie
33
# The decision and tolerance are the same as all.equal
44
#
5+
# see methods document: tied times
56
aeqSurv <- function(x, tolerance = sqrt(.Machine$double.eps)) {
67
if (!missing(tolerance)) {
78
if (!is.numeric(tolerance) || length(tolerance)!=1 ||

R/brier.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ brier <- function(fit, times, newdata, ties=TRUE, detail =FALSE, timefix=TRUE,
2626
casewt <- as.numeric(casewt) # transform integer to numeric
2727
}
2828

29-
id <- model.extract(mf, "(id)")
29+
id <- model.extract(mf, "id")
3030
if (ny==3 && (is.null(id))) stop("id is required for start-stop data")
3131
if (!is.null(id)) {
3232
if (is.null(attr(Y, 'states'))) {

R/concordance.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ concordance.formula <- function(object, data,
3434
if (is.factor(Y) && (is.ordered(Y) || length(levels(Y))==2))
3535
Y <- Surv(as.numeric(Y))
3636
else if (is.numeric(Y) && is.vector(Y)) Y <- Surv(Y)
37-
else if (is.logical(Y)) Y <- as.numeric(Y)
37+
else if (is.logical(Y)) Y <- Surv(as.numeric(Y))
3838
else stop("left hand side of the formula must be a numeric vector,
3939
survival object, or an orderable factor")
4040
timewt <- "n"

R/parsecovar.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ parsecovar2 <- function(covar1, statedata, dformula, Terms, transitions,states)
212212
}
213213
else {
214214
k <- match(x$right, statedata$state)
215-
if (any(is.na(k))) stop(x$right[k], ": state not found")
215+
if (any(is.na(k))) stop(x$right, ": state not found")
216216
temp2 <- which(statedata$state %in% x$right)
217217
}
218218

R/print.survfit.R

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,22 @@ print.survfit <- function(x, scale=1,
5454
mtemp <- if (is.matrix(temp$matrix)) temp$matrix
5555
else matrix(temp$matrix, nrow=1,
5656
dimnames=list(NULL, names(temp$matrix)))
57-
if (all(mtemp[,2] == mtemp[,3])){
58-
cname <- dimnames(mtemp)[[2]]
59-
mtemp <- mtemp[,-2, drop=FALSE]
60-
cname <-cname[-2]
61-
cname[2] <- "n"
62-
dimnames(mtemp)[[2]] <- cname
57+
if (dimnames(mtemp)[[2]][2] == "n.id") {
58+
mtemp <- mtemp[,-3, drop=FALSE] # no need for n.start
59+
dimnames(mtemp)[[2]][2] <- "n"
6360
}
61+
else { # older path
62+
if (all(mtemp[,2] == mtemp[,3])){
63+
cname <- dimnames(mtemp)[[2]]
64+
mtemp <- mtemp[,-3, drop=FALSE]
65+
cname <-cname[-3]
66+
cname[2] <- "n"
67+
dimnames(mtemp)[[2]] <- cname
68+
}
6469

65-
if (all(mtemp[,1] == mtemp[,2]))
66-
mtemp <- mtemp[,-1, drop=FALSE]
67-
70+
if (all(mtemp[,1] == mtemp[,2]))
71+
mtemp <- mtemp[,-1, drop=FALSE]
72+
}
6873
# for printing, put a footnote on the rmean label
6974
if (rmean != 'none') {
7075
dd <- dimnames(mtemp)
@@ -99,7 +104,7 @@ survmean <- function(x, scale=1, rmean) {
99104
# i.e., once per curve. It creates the line of output
100105
#
101106
pfun <- function(nused, time, surv, n.risk, n.event, lower, upper,
102-
start.time, end.time) {
107+
start.time, end.time, nid) {
103108
#
104109
# Start by defining a small utility function
105110
# Multiple times, we need to find the x corresponding to the first
@@ -161,16 +166,17 @@ survmean <- function(x, scale=1, rmean) {
161166
varmean <- 0 #placeholders
162167
}
163168

169+
if (is.null(nid)) maxn= max(n.risk) else maxn = nid
164170
#compute the median and ci(median)
165171
med <- minmin(surv, time)
166172
if (!is.null(upper)) {
167173
upper <- minmin(upper, time)
168174
lower <- minmin(lower, time)
169-
c(nused, max(n.risk), n.risk[1],
175+
c(nused, maxn, n.risk[1],
170176
sum(n.event), sum(mean), sqrt(varmean), med, lower, upper)
171177
}
172178
else
173-
c(nused, max(n.risk), n.risk[1], sum(n.event),
179+
c(nused, maxn, n.risk[1], sum(n.event),
174180
sum(mean), sqrt(varmean), med, 0, 0)
175181
}
176182

@@ -188,7 +194,7 @@ survmean <- function(x, scale=1, rmean) {
188194
"rmean", "se(rmean)", "median",
189195
paste(x$conf.int, c("LCL", "UCL"), sep='')) #col labels
190196
ncols <- 9 #number of columns in the output
191-
197+
if (!is.null(x$n.id)) plab[2] <- "n.id"
192198

193199
#Four cases: strata Y/N by ncol(surv)>1 Y/N
194200
# Repeat the code, with minor variations, for each one
@@ -206,17 +212,17 @@ survmean <- function(x, scale=1, rmean) {
206212
if (is.null(x$conf.int))
207213
out[i,] <- pfun(x$n, stime, surv[,i], x$n.risk,
208214
x$n.event[,i],
209-
NULL, NULL, start.time, end.time)
215+
NULL, NULL, start.time, end.time, x$n.id)
210216
else out[i,] <- pfun(x$n, stime, surv[,i], x$n.risk,
211217
x$n.event[,i],
212218
x$lower[,i], x$upper[,i], start.time,
213-
end.time)
219+
end.time, x$n.id)
214220
}
215221
dimnames(out) <- list(dimnames(surv)[[2]], plab)
216222
}
217223
else {
218224
out <- matrix(pfun(x$n, stime, surv, x$n.risk, x$n.event, x$lower,
219-
x$upper, start.time, end.time), nrow=1)
225+
x$upper, start.time, end.time, x$n.id), nrow=1)
220226
dimnames(out) <- list(NULL, plab)
221227
}
222228
}
@@ -248,11 +254,12 @@ survmean <- function(x, scale=1, rmean) {
248254
if (is.null(x$lower))
249255
out[k,] <- pfun(x$n[i], stime[who], surv[who,j],
250256
x$n.risk[who], x$n.event[who,j],
251-
NULL, NULL, start.time, end.time[i])
257+
NULL, NULL, start.time, end.time[i],
258+
x$n.id[j])
252259
else out[k,] <- pfun(x$n[i], stime[who], surv[who,j],
253260
x$n.risk[who], x$n.event[who,j],
254261
x$lower[who,j], x$upper[who,j],
255-
start.time, end.time[i])
262+
start.time, end.time[i], x$n.id[j])
256263
}
257264
}
258265
}
@@ -264,11 +271,12 @@ survmean <- function(x, scale=1, rmean) {
264271
if (is.null(x$lower))
265272
out[i,] <- pfun(x$n[i], stime[who], surv[who],
266273
x$n.risk[who], x$n.event[who],
267-
NULL, NULL, start.time, end.time[i])
274+
NULL, NULL, start.time, end.time[i],
275+
x$n.id[i])
268276
else out[i,] <- pfun(x$n[i], stime[who], surv[who],
269277
x$n.risk[who], x$n.event[who],
270278
x$lower[who], x$upper[who], start.time,
271-
end.time[i])
279+
end.time[i], x$n.id[i])
272280
}
273281
}
274282
}

0 commit comments

Comments
 (0)