R version 4.4.0 RC (2024-04-16 r86458 ucrt) -- "Puppy Cup" 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) > > # > # Verify that scale can be fixed at a value > # coefs will differ slightly due to different iteration paths > tol <- .001 > > # Intercept only models > fit1 <- survreg(Surv(time,status) ~ 1, lung) > fit2 <- survreg(Surv(time,status) ~ 1, lung, scale=fit1$scale) > all.equal(fit1$coef, fit2$coef, tolerance= tol) [1] TRUE > all.equal(fit1$loglik, fit2$loglik, tolerance= tol) [1] TRUE > > # The two robust variance matrices are not the same, since removing > # an obs has a different effect on the two models. This just > # checks for failure, not for correctness > fit3 <- survreg(Surv(time,status) ~ 1, lung, robust=TRUE) > fit4 <- survreg(Surv(time,status) ~ 1, lung, scale=fit1$scale, robust=TRUE) > > > # multiple covariates > fit1 <- survreg(Surv(time,status) ~ age + ph.karno, lung) > fit2 <- survreg(Surv(time,status) ~ age + ph.karno, lung, + scale=fit1$scale) > all.equal(fit1$coef, fit2$coef, tolerance=tol) [1] TRUE > all.equal(fit1$loglik[2], fit2$loglik[2], tolerance=tol) [1] TRUE > > fit3 <- survreg(Surv(time,status) ~ age + ph.karno, lung, robust=TRUE) > fit4 <- survreg(Surv(time,status) ~ age + ph.karno, lung, + scale=fit1$scale, robust=TRUE) > > # penalized models > fit1 <- survreg(Surv(time, status) ~ pspline(age), lung) > fit2 <- survreg(Surv(time, status) ~ pspline(age), lung, scale=fit1$scale) > all.equal(fit1$coef, fit2$coef, tolerance=tol) [1] TRUE > all.equal(fit1$loglik[2], fit2$loglik[2], tolerance=tol) [1] TRUE > > fit3 <- survreg(Surv(time,status) ~ pspline(age) + ph.karno, lung, robust=TRUE) > fit4 <- survreg(Surv(time,status) ~ pspline(age) + ph.karno, lung, + scale=fit1$scale, robust=TRUE) > > > > proc.time() user system elapsed 1.12 0.09 1.15