R Under development (unstable) (2024-12-13 r87441 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. > 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$coefficients, fit2$coefficients) [1] TRUE > all.equal(fit1$loglik, fit2$loglik) [1] TRUE > all.equal(fit1$var, fit2$var) [1] TRUE > all.equal(fit1$residuals, fit2$residuals) [1] TRUE > > > proc.time() user system elapsed 0.84 0.07 0.92