We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Time-transformations with the tt-special in coxph crash anova.coxph when the transformation function calls survival::nsk.
tt
coxph
anova.coxph
survival::nsk
## Example from vignette("timedep", package = "survival"), Section 4.2 library(survival) fit1 <- coxph(Surv(time, status) ~ trt + prior + karno + tt(karno), data=veteran, tt = function(x, t, ...) x* nsk(t, knots=c(5, 100, 200, 400), Boundary.knots = FALSE)) anova(fit1) ## Error: variable 'tt(karno)' was fitted with type "numeric" but type "nmatrix.3" was supplied
For a time-varying factor variable, the error message differs:
veteran2 <- transform(veteran, trt = factor(trt)) fit2 <- coxph(Surv(time, status) ~ trt + tt(trt) + prior + karno , data=veteran2, tt = function(x, t, ...) as.numeric(x == "2")* nsk(t, knots=c(5, 100, 200, 400), Boundary.knots = FALSE)) anova(fit2) ## Error in x[ol] - k.pivot : non-numeric argument to binary operator
In both cases, traceback() indicates that the error is generated in ns() called by nsk().
traceback()
ns()
nsk()
Both models work if the time transformation is something simple:
fit3 <- coxph(Surv(time, status) ~ trt + prior + karno + tt(karno), data=veteran, tt = function(x, t, ...) x*log(t + 20)) anova(fit3) fit4 <- coxph(Surv(time, status) ~ trt + tt(trt) + prior + karno , data=veteran2, tt = function(x, t, ...) as.numeric(x == "2")* log(t + 20)) anova(fit4)
Session:
sessionInfo() R version 4.4.0 (2024-04-24 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 10 x64 (build 19045) Matrix products: default locale: [1] LC_COLLATE=Swedish_Sweden.utf8 LC_CTYPE=Swedish_Sweden.utf8 LC_MONETARY=Swedish_Sweden.utf8 [4] LC_NUMERIC=C LC_TIME=Swedish_Sweden.utf8 time zone: Europe/Stockholm tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] survival_3.7-0 loaded via a namespace (and not attached): [1] compiler_4.4.0 Matrix_1.7-0 tools_4.4.0 splines_4.4.0 grid_4.4.0 lattice_0.22-6
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Time-transformations with the
tt
-special incoxph
crashanova.coxph
when the transformation function callssurvival::nsk
.For a time-varying factor variable, the error message differs:
In both cases,
traceback()
indicates that the error is generated inns()
called bynsk()
.Both models work if the time transformation is something simple:
Session:
The text was updated successfully, but these errors were encountered: