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/clogit.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.

> library(survival)
> #
> # Test of the clogit function, and indirectly of the exact option
> #
> # Data set logan has the occupation of fathers, we create a 
> #  multinomial response
> #
> nresp <- length(levels(logan$occupation))
> n <- nrow(logan)
> indx <- rep(1:n, nresp)
> logan2 <- data.frame(logan[indx,],
+                      id = indx,
+                      occ2 = factor(rep(levels(logan$occupation), each=n)))
> logan2$y <- (logan2$occupation == logan2$occ2)
> 
> #We expect two NA coefficients, so ignore the warning
> fit1 <- clogit(y ~ occ2 + occ2:education + occ2:race + strata(id), logan2)
> 
> #since there is only one death per group, all methods are equal
> dummy <- rep(1, nrow(logan2))
> fit2 <- coxph(Surv(dummy, y) ~ occ2 + occ2:education + occ2:race + strata(id),
+                    logan2, method='breslow')
> 
> all.equal(fit1$coef, fit2$coef)
[1] TRUE
> all.equal(fit1$loglik, fit2$loglik)
[1] TRUE
> all.equal(fit1$var, fit2$var)
[1] TRUE
> all.equal(fit1$resid, fit2$resid)
[1] TRUE
> 
> 
> proc.time()
   user  system elapsed 
  0.868   0.024   0.890