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

Update ggcoxdiagnostics.R, fix for ox.scale = "time" and non unique eventtimes #468

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions R/ggcoxdiagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ ggcoxdiagnostics <- function (fit,
stop("Can't handle an object of class ", class(fit))
type <- match.arg(type)

res <- as.data.frame(resid(fit, type = type))
# raw_res needed for eventimes, when ox.scale = time and there are non-unique eventtimes
raw_res <- resid(fit, type = type)
res <- as.data.frame(raw_res)
.facet <- FALSE

xlabel <- "The index number of observations"
Expand All @@ -89,7 +91,8 @@ ggcoxdiagnostics <- function (fit,
time = {
if (!(type %in% c("schoenfeld", "scaledsch")))
warning("ox.scale='time' works only with type=schoenfeld/scaledsch")
xval <- as.numeric(rownames(res))
xval <- as.numeric(rownames(raw_res)) # see comment raw_res
raw_res <- NULL # no longer needed and potentially large
xlabel <- "Time"
},
{warning("ox.scale should be one of linear.predictions/observation.id/time")})
Expand Down