R Under development (unstable) (2024-12-12 r87438 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > options(na.action=na.exclude) # preserve missings > options(contrasts=c('contr.treatment', 'contr.poly')) #ensure constrast type > library(survival) > > # > # A test with the lung data > # This caused problems in one release > > # > # First, get rid of some missings > # > lung2 <- na.omit(lung[c('time', 'status', 'wt.loss')]) > > # > # Test the logliklihoods > # > fit <- coxph(Surv(time, status) ~ pspline(wt.loss,3), lung2, x=T) > fit0<- coxph(Surv(time, status) ~ 1, lung2) > fit1<- coxph(Surv(time, status) ~ fit$x, lung2, iter=0, init=fit$coef) > > all.equal(fit$loglik[1], fit0$loglik) [1] TRUE > all.equal(fit$loglik[2], fit1$loglik[2]) [1] TRUE > > # > # Check variances > # > imat <- solve(fit1$var) > var2 <- fit$var %*% imat %*% fit$var > all.equal(fit$var2, var2) [1] TRUE > > proc.time() user system elapsed 0.73 0.15 0.87