Академический Документы
Профессиональный Документы
Культура Документы
1 15
39
76
Considere slo un ensayo en el modelo, por ejemplo, las covariables T1, el tiempo de la
escisin. Los pacientes que recibieron la escisin se tratan como dos de los casos, antes y
despus de la escisin. Despus de reformular este dato en particular se tiene:
id
15
148
15
76
148
Modelo con
tratamiento y ambas
variables dependiente
del tiempo
fijas
TR
se (
)
exp
( )
se
( )
exp
( )
se (
)
exp
( )
se (
)
exp
( )
-.625
.294
.535
-.494
.300
.610
-.486
0.298
0.615
-.565
0.296
0.568
0.365
1.031
(0.034)
Gnero
Modelo con
tratamiento y TDC T1
-.640
(0.10)
.390
.527
1.010
8.613
(0.10)
(0.057)
(0.100)
raza
2.153
(0.033)
T1
-.591
.449
.554
(0.19)
T2
0.080
(0.83)
-.582
0.448
0.559
(0.19)
.367
1.084
0.0309
(0.930)
Para ilustrar cmo el factor de riesgo, exp (Xb + Z (t)), cambios sobre el tiempo,
asumimos que el tiempo de la escisin (T1) y tiempo de tratamiento con anticuerpos (T2)
son las variables importantes y se incluyen en el modelo con todas las otras covariables
fijas. Echemos un vistazo a los individuos con el tratamiento (id = 3, 4, 10, 22) y aquellos
sin tratamiento (id = 62, 66, 65, 67).
tdc.fit4=coxph(Surv(start, stop, event) ~ z1 + z2 + z3 + it1 + it2, data
= burn2)
coef=as.vector(tdc.fit4$coeff)
coef=coef[c(4:5, 1:3)]
X=burn2[,4:8]
datay=exp(as.matrix(X)%*%coef)
dataxy=cbind(burn2$stop, datay, burn2$id)
id=matrix(c(3, 4, 10, 22, 62, 66, 65, 67), byrow=T, nrow=2)
par(mfrow=c(2,2))
for (i in 1:4)
{
plot(seq(0, 65, length=10), seq(0, 10, length=10), type="n")
ii=0
for (j in id[, i])
{
ii=ii+1
x=(dataxy[,1])[dataxy[,3]==j]
y=(dataxy[,2])[dataxy[,3]==j]
lines(stepfun(c(0,x), y), lty=ii)
}
10
8
6
4
0
se q ( 0 , 1 0 , le n g th = 1 0 )
8
6
4
2
0
se q ( 0 , 1 0 , le n g th = 1 0 )
10
10
20
30
40
50
60
10
30
40
50
60
10
8
6
4
0
se q ( 0 , 1 0 , le n g th = 1 0 )
8
6
4
2
0
se q ( 0 , 1 0 , le n g th = 1 0 )
20
s e q ( 0 , 6 5 , le n g th = 1 0 )
10
s e q ( 0 , 6 5 , le n g th = 1 0 )
10
20
30
40
50
60
s e q ( 0 , 6 5 , le n g th = 1 0 )
10
20
30
40
50
60
s e q ( 0 , 6 5 , le n g th = 1 0 )
Tambin podemos considerar el modelo con las interacciones entre las covariables fijas y
TDC. El procedimiento de seleccin paso a paso del modelo resulta en el modelo final con
todas las covariables fijas y dos trminos de interaccin, entre el gnero y el tiempo de la
escisin y entre la raza y el tiempo de la escisin.
> tdc.fit<-coxph(Surv(start, stop, event) ~ (z1 + z2 + z3 ) * it1, data =
burn3)
> tdc.fit
Call:
coxph(formula = Surv(start, stop, event) ~ (z1 + z2 + z3) * it1, data =
burn3)
- z1:it1
Df
AIC
1 425.0524
<none> NA 427.0211
- z3:it1 1 427.4337
- z2:it1 1 429.8527
Step: AIC= 425.05
Surv(start, stop, event) ~ z1 + z2 + z3 + it1 + z2:it1 + z3:it1
Df
AIC
<none> NA 425.0524
- z3:it1 1 425.4590
- z1 1 426.0701
- z2:it1 1 427.8591
Call:
coxph(formula = Surv(start, stop, event) ~ z1 + z2 + z3 + it1 + z2:it1 +
z3:it1, data =
burn3)
on 6 df, p=0.000273
n= 236
z1 -0.4395
z2 -0.6468
z3 2.1459
stop:z1 -0.0161
z1
z2
z3
stop:z1
0.644
0.524
8.550
0.984
Rsquare= 0.005
(max possible=
Likelihood ratio test= 17.1 on
Wald test
= 11.5 on
Score (logrank) test = 13.9 on
0.132 )
4 df,
p=0.00182
4 df,
p=0.0212
4 df,
p=0.00762
z1
z2
z3
stop:z2
Rsquare= 0.006
(max possible=
Likelihood ratio test= 17.3 on
Wald test
= 11.6 on
Score (logrank) test = 13.9 on
0.132 )
4 df,
p=0.00166
4 df,
p=0.0203
4 df,
p=0.00764
z1
z2
z3
stop:z3
Rsquare= 0.007
(max possible=
Likelihood ratio test= 20.8 on
Wald test
= 9.18 on
Score (logrank) test = 14.5 on
upper .95
9.32e-001
1.13e+000
8.22e+005
1.04e+000
0.132 )
4 df,
p=0.000355
4 df,
p=0.0568
4 df,
p=0.00592
z1
z2
z3
I(z4 * z1)
Rsquare= 0.005
(max possible=
Likelihood ratio test= 17.1 on
Wald test
= 11.6 on
Score (logrank) test = 13.9 on
0.132 )
4 df,
p=0.00187
4 df,
p=0.021
4 df,
p=0.00776
se puede hacer por la funcin changePt (data, indic) (changePt.ssc), donde el argumento
data toma los datos reformulado por la funcin splitSurv y indic muestra la covariable
fijada de inters.
> changePt(reburn, 4)
event.time
logliks
[1,]
1 -217.2525
[2,]
2 -216.7316
[3,]
3 -217.6008
[4,]
4 -217.7581
[5,]
5 -216.9209
[6,]
6 -217.4549
[7,]
7 -217.7749
[8,]
8 -217.7686
[9,]
9 -217.6935
[10,]
10 -217.7094
[11,]
11 -217.5719
[12,]
13 -217.3211
[13,]
14 -217.5854
[14,]
16 -217.7456
[15,]
17 -217.6147
[16,]
18 -216.3561
[17,]
19 -216.7689
[18,]
21 -217.1448
[19,]
23 -217.4374
[20,]
32 -217.6488
[21,]
42 -216.3298
[22,]
44 -216.7694
[23,]
47 -217.2353
[24,]
51 -217.7764
[1] "best="
[1] 21
Call:
coxph(formula = Surv(data$start, data$stop, data$event) ~ x1 + x2,
method = "breslow")
n= 3109
coef exp(coef) se(coef)
z
p
x1 -0.459
0.63210
0.3 -1.53 0.13
x2 -5.785
0.00307
12.9 -0.45 0.65
x1
x2
Rsquare= 0.002
(max possible= 0.132 )
Likelihood ratio test= 6.6 on 2 df,
p=0.0368
Wald test
= 2.57
Score (logrank) test = 5.48
on 2 df,
on 2 df,
p=0.277
p=0.0646
> changePt(reburn, 5)
event.time
logliks
[1,]
1 -218.2118
[2,]
2 -218.1533
[3,]
3 -218.3450
[4,]
4 -218.0548
[5,]
5 -217.2861
[6,]
6 -216.9251
[7,]
7 -217.6808
[8,]
8 -217.3681
[9,]
9 -216.9712
[10,]
10 -216.4737
[11,]
11 -215.5089
[12,]
13 -215.0880
[13,]
14 -214.6195
[14,]
16 -214.0815
[15,]
17 -215.1789
[16,]
18 -216.0502
[17,]
19 -217.2415
[18,]
21 -218.0480
[19,]
23 -218.3470
[20,]
32 -217.2850
[21,]
42 -217.4875
[22,]
44 -217.7596
[23,]
47 -218.1056
[24,]
51 -218.3503
[1] "best="
[1] 14
Call:
coxph(formula = Surv(data$start, data$stop, data$event) ~ x1 + x2,
method = "breslow")
n= 3109
coef exp(coef) se(coef)
z
p
x1 -1.71
0.18
0.728 -2.35 0.0190
x2 2.49
12.05
0.930 2.68 0.0075
x1
x2
Rsquare= 0.004
(max possible=
Likelihood ratio test= 11.1 on
Wald test
= 7.34 on
Score (logrank) test = 8.92 on
0.132 )
2 df,
p=0.00389
2 df,
p=0.0255
2 df,
p=0.0116
> changePt(reburn, 6)
event.time
logliks
[1,]
1 -214.8830
[2,]
2 -214.8368
[3,]
3 -214.7584
[4,]
4 -214.6545
[5,]
5 -214.4963
[6,]
6 -214.4364
[7,]
7 -214.3373
[8,]
8 -214.2610
[9,]
9 -214.1741
[10,]
10 -214.0746
[11,]
11 -213.9058
[12,]
13 -213.8442
[13,]
14 -213.7787
[14,]
16 -213.7009
[15,]
17 -213.5070
[16,]
18 -213.2553
[17,]
19 -213.0905
[18,]
21 -212.9121
[19,]
23 -212.6449
[20,]
32 -212.3236
[21,]
42 -214.8464
[22,]
44 -214.8632
[23,]
47 -214.8847
[24,]
51 -214.8977
[1] "best="
[1] 20
Call:
coxph(formula = Surv(data$start, data$stop, data$event) ~ x1 + x2,
method = "breslow")
n= 3109
coef exp(coef) se(coef)
z
p
x1 7.27 1.44e+003
13.5 0.537 0.59
x2 -7.87 3.82e-004
13.6 -0.579 0.56
exp(coef) exp(-coef) lower .95 upper .95
x1 1.44e+003 6.97e-004 4.30e-009 4.79e+014
x2 3.82e-004 2.62e+003 1.04e-015 1.40e+008
Rsquare= 0.005
(max possible= 0.132 )
Likelihood ratio test= 14.6 on 2 df,
p=0.00067
Wald test
= 0.56 on 2 df,
p=0.757
Score (logrank) test = 8.1 on 2 df,
p=0.0174
z1<-burn[,2]
z2<-burn[,3]
z3<-burn[,4]
t1<-burn[,13]
it1<-burn[,14]
t2<-burn[,15]
it2<-burn[,16]
t3<-burn[,17]
it3<-burn[,18]
burnnew<-data.frame(z1,z2,z3,t1,it1,t2,it2,t3,it3)
fit.cox=coxph(Surv(t3, it3) ~ z1 + z2 + z3, data=burnnew)
summary(fit.cox)
Call:
coxph(formula = Surv(t3, it3) ~ z1 + z2 + z3, data = burnnew)
n= 154, number of events= 48
coef exp(coef) se(coef)
z Pr(>|z|)
z1 -0.6254
0.5350
0.2944 -2.125
0.0336 *
z2 -0.6399
0.5273
0.3899 -1.641
0.1008
z3 2.1555
8.6325
1.0112 2.132
0.0330 *
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
z1
z2
z3
0;
<- stop <- event <-numeric(1);
<- tdcs[,seq(1, ncol(tdcs), 2)];
<-tdcs[,seq(2, ncol(tdcs), 2)];
if(is.vector(tdc.t)==T)
{
tdc.t=as.matrix(tdc.t)
tdc.e=as.matrix(tdc.e)
}
sort.time <- t(apply(cbind(t0=rep(0,n),tdc.t,t4=time), 1, sort));
temp <- rep(0, ntdcs);
for (i in 1:n)
{
tt <- unique(sort.time[i,])
for(j in 1:length(tt))
{
if(time[i] > tt[j])
{
ii <- ii+1;
start[ii] <- tt[j]
stop[ii] <- min(time[i], tt[j+1])
id[ii] <- i
if(time[i] > tt[j+1]) event[ii] <- 0
else event[ii] <- censor[i]
data1 <- rbind(data1, data[i,])
temp <-tdc.e[i,];
if(time[i]>stop[ii])
temp[tdc.t[i,]>=stop[ii]]=0
else temp[tdc.t[i,]>stop[ii]]=0
tdcs1 <- rbind(tdcs1, temp)
}
}
}
tdcs1 <- tdcs1[-1, ]
data1 <- data1[-1, ]
X=cbind(start=start, stop=stop, event=event, tdcs1, data1, id=id)
row.names(X)=1:dim(X)[1]
X
}
splitSuv<-function(time, event, data) #data contains the other covariates
{
#sort in ascending order
sort.ord = order(time);
n=length(time);
time1=sort(time);
id=(1:n)[sort.ord];
event1 = event[sort.ord];
data1=data[sort.ord,];
#variables required for time-dependent covariate analysis
stop.int = unique(time1);
start.int = c(0, stop.int[-length(stop.int)]);
nrep = rep(0, n);
for (i in 1:n)
{
nrep[i] = sum(stop.int<=time1[i]);
}
start.int1 = start.int[1:nrep[1]];
stop.int1 = stop.int[1:nrep[1]];
for (i in 2:n)
{
start.int1 = c(start.int1, start.int[1:nrep[i]]);
stop.int1 = c(stop.int1, stop.int[1:nrep[i]]);
}
id1 = rep(id, nrep);
data1 = data1[rep(1:n, nrep),];
event2 = rep(0, length(stop.int1));
event2[cumsum(nrep)]=event1;
X=cbind(start=start.int1, stop=stop.int1, event=event2, data1,
id=id1);
row.names(X)=1:nrow(X);
X
}
changePt<-function(data, indic) #the output data from splitSurv
{
stop=data$stop;
event.time=unique(stop[data$event==1]);
x1=data[,indic]
n = length(event.time);
logliks = rep(0, n);
for (i in 1:n)
{
x2=x1;
x2[stop<=event.time[i]]=0;
ph.cp = coxph(Surv(data$start, data$stop, data$event)~x1+
x2, method="breslow");
logliks[i] = ph.cp$loglik[2];
}
print(cbind(event.time, logliks))
best=(1:n)[logliks==max(logliks)];
print("best="); print(best);
x2=x1;
x2[stop<= (event.time[best])] = 0;
ph.cp = coxph(Surv(data$start, data$stop, data$event)~x1+x2,
method="breslow");
summary(ph.cp)
}