52 lines
1.4 KiB
Plaintext
Raw Normal View History

2025-01-12 00:52:51 +08:00
R version 2.11.1 (2010-05-31)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
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)
Loading required package: splines
>
> #
> # 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
>