HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Program Files/R/R-4.4.0/library/survival/tests/singtest.Rout.save
R Under development (unstable) (2018-04-09 r74565) -- "Unsuffered Consequences"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

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 simple test of an overdetermined system
> #  Should give a set of NA coefficients
> #
> test1 <- data.frame(time=  c(4, 3,1,1,2,2,3),
+ 		    status=c(1,NA,1,0,1,1,0),
+ 		    x=     c(0, 2,1,1,1,0,0))
> 
> temp <- rep(0:3, rep(7,4))
> 
> stest <- data.frame(start  = 10*temp,
+ 		    stop   = 10*temp + test1$time,
+ 		    status = rep(test1$status,4),
+ 		    x      = c(test1$x+ 1:7, rep(test1$x,3)),
+ 		    epoch  = rep(1:4, rep(7,4)))
> 
> # Will create a warning about a singular X matrix
> fit1 <- coxph(Surv(start, stop, status) ~ x * factor(epoch), stest)
> fit1$coef    # elements 2:4 should be NA
               x   factor(epoch)2   factor(epoch)3   factor(epoch)4 
       0.1041579               NA               NA               NA 
x:factor(epoch)2 x:factor(epoch)3 x:factor(epoch)4 
       1.5726996        1.5726996        1.5726996 
> all.equal(is.na(fit1$coef), c(F,T,T,T,F,F,F), check.attributes=FALSE)
[1] TRUE
> 
> proc.time()
   user  system elapsed 
  0.668   0.040   0.704