phreg: Fast Cox PH regression

Description Usage Arguments Author(s) Examples

View source: R/phreg.R

Description

Fast Cox PH regression

Usage

1

Arguments

formula

formula with 'Surv' outcome (see coxph)

data

data frame

...

Additional arguments to lower level funtions

Author(s)

Klaus K. Holst

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
simcox <- function(n=1000, seed=1, beta=c(1,1), entry=TRUE) {
  if (!is.null(seed))
    set.seed(seed)
  library(lava)
  m <- lvm()
  regression(m,T~X1+X2) <- beta
  distribution(m,~T+C) <- coxWeibull.lvm(scale=1/100)
  distribution(m,~entry) <- coxWeibull.lvm(scale=1/10)
  m <- eventTime(m,time~min(T,C=0),"status")
  d <- sim(m,n);
  if (!entry) d$entry <- 0
  else d <- subset(d, time>entry,select=-c(T,C))
  return(d)
}
## Not run: 
n <- 1e3;
d <- mets:::simCox(n); d$id <- seq(nrow(d)); d$group <- factor(rbinom(nrow(d),1,0.5))

(m1 <- phreg(Surv(entry,time,status)~X1+X2,data=d))
(m2 <- coxph(Surv(entry,time,status)~X1+X2+cluster(id),data=d))
(coef(m3 <-cox.aalen(Surv(entry,time,status)~prop(X1)+prop(X2),data=d)))


(m1b <- phreg(Surv(entry,time,status)~X1+X2+strata(group),data=d))
(m2b <- coxph(Surv(entry,time,status)~X1+X2+cluster(id)+strata(group),data=d))
(coef(m3b <-cox.aalen(Surv(entry,time,status)~-1+group+prop(X1)+prop(X2),data=d)))

m <- phreg(Surv(entry,time,status)~X1*X2+strata(group)+cluster(id),data=d)
m
plot(m,ylim=c(0,1))

## End(Not run)

Example output

Loading required package: timereg
Loading required package: survival
Loading required package: lava
mets version 1.2.8.1
Call:
phreg(formula = Surv(entry, time, status) ~ X1 + X2, data = d)

   n events
 766    345

 766 clusters
log-coeffients:
   Estimate     S.E.  dU^-1/2 P-value
X1 1.012792 0.065009 0.070213       0
X2 0.911190 0.066907 0.063496       0

exp(coeffients):
     Estimate Std.Err    2.5%   97.5% P-value
[X1]  2.75328 0.17899 2.40247 3.10409       0
[X2]  2.48728 0.16642 2.16111 2.81345       0

Call:
coxph(formula = Surv(entry, time, status) ~ X1 + X2, data = d, 
    cluster = id)

      coef exp(coef) se(coef) robust se     z      p
X1 1.01279   2.75328  0.07021   0.06501 15.58 <2e-16
X2 0.91119   2.48728  0.06350   0.06691 13.62 <2e-16

Likelihood ratio test=360.9  on 2 df, p=< 2.2e-16
n= 766, number of events= 345 
         Coef.     SE Robust SE D2log(L)^-1    z P-val lower2.5% upper97.5%
prop(X1) 1.010 0.0713    0.0650      0.0702 15.6     0     0.870       1.15
prop(X2) 0.911 0.0643    0.0669      0.0635 13.6     0     0.785       1.04
Call:
phreg(formula = Surv(entry, time, status) ~ X1 + X2 + strata(group), 
    data = d)

   n events
 766    345

 766 clusters
log-coeffients:
   Estimate     S.E.  dU^-1/2 P-value
X1 1.014093 0.065559 0.070452       0
X2 0.912926 0.065355 0.063851       0

exp(coeffients):
     Estimate Std.Err    2.5%   97.5% P-value
[X1]  2.75686 0.18074 2.40262 3.11110       0
[X2]  2.49160 0.16284 2.17244 2.81076       0

Call:
coxph(formula = Surv(entry, time, status) ~ X1 + X2 + strata(group), 
    data = d, cluster = id)

      coef exp(coef) se(coef) robust se     z      p
X1 1.01409   2.75686  0.07045   0.06556 15.47 <2e-16
X2 0.91293   2.49160  0.06385   0.06535 13.97 <2e-16

Likelihood ratio test=359.9  on 2 df, p=< 2.2e-16
n= 766, number of events= 345 
         Coef.     SE Robust SE D2log(L)^-1    z P-val lower2.5% upper97.5%
prop(X1) 1.010 0.0709    0.0656      0.0705 15.5     0     0.871       1.15
prop(X2) 0.913 0.0644    0.0654      0.0639 14.0     0     0.787       1.04
Call:
phreg(formula = Surv(entry, time, status) ~ X1 * X2 + strata(group) + 
    cluster(id), data = d)

   n events
 766    345

 766 clusters
log-coeffients:
       Estimate      S.E.   dU^-1/2 P-value
X1     1.018187  0.065551  0.070752  0.0000
X2     0.920881  0.068055  0.065246  0.0000
X1:X2 -0.042774  0.066416  0.069018  0.5196

exp(coeffients):
        Estimate  Std.Err     2.5%    97.5% P-value
[X1]    2.768171 0.181457 2.412522 3.123820  0.0000
[X2]    2.511502 0.170919 2.176506 2.846498  0.0000
[X1:X2] 0.958128 0.063635 0.833405 1.082850  0.5105

mets documentation built on May 2, 2019, 4:43 p.m.